Fix check for universal timer notification
This commit is contained in:
parent
0f4a1d6e28
commit
a6ce00ff37
4 changed files with 49 additions and 3 deletions
|
@ -2797,12 +2797,11 @@ export class ConversationModel extends window.Backbone
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('pendingUniversalTimer') || this.get('expireTimer')) {
|
if (await window.Signal.Data.hasUserInitiatedMessages(this.get('id'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeAt = this.get('active_at');
|
if (this.get('pendingUniversalTimer') || this.get('expireTimer')) {
|
||||||
if (activeAt) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2824,6 +2823,9 @@ export class ConversationModel extends window.Backbone
|
||||||
const message = window.MessageController.getById(notificationId);
|
const message = window.MessageController.getById(notificationId);
|
||||||
if (message) {
|
if (message) {
|
||||||
message.cleanup();
|
message.cleanup();
|
||||||
|
window.Signal.Data.removeMessage(message.id, {
|
||||||
|
Message: window.Whisper.Message,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('expireTimer')) {
|
if (this.get('expireTimer')) {
|
||||||
|
|
|
@ -171,6 +171,7 @@ const dataInterface: ClientInterface = {
|
||||||
searchMessagesInConversation,
|
searchMessagesInConversation,
|
||||||
|
|
||||||
getMessageCount,
|
getMessageCount,
|
||||||
|
hasUserInitiatedMessages,
|
||||||
saveMessage,
|
saveMessage,
|
||||||
saveMessages,
|
saveMessages,
|
||||||
removeMessage,
|
removeMessage,
|
||||||
|
@ -976,6 +977,10 @@ async function getMessageCount(conversationId?: string) {
|
||||||
return channels.getMessageCount(conversationId);
|
return channels.getMessageCount(conversationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function hasUserInitiatedMessages(conversationId: string) {
|
||||||
|
return channels.hasUserInitiatedMessages(conversationId);
|
||||||
|
}
|
||||||
|
|
||||||
async function saveMessage(
|
async function saveMessage(
|
||||||
data: MessageType,
|
data: MessageType,
|
||||||
{ forceSave, Message }: { forceSave?: boolean; Message: typeof MessageModel }
|
{ forceSave, Message }: { forceSave?: boolean; Message: typeof MessageModel }
|
||||||
|
|
|
@ -215,6 +215,7 @@ export type DataInterface = {
|
||||||
) => Promise<Array<ConversationType>>;
|
) => Promise<Array<ConversationType>>;
|
||||||
|
|
||||||
getMessageCount: (conversationId?: string) => Promise<number>;
|
getMessageCount: (conversationId?: string) => Promise<number>;
|
||||||
|
hasUserInitiatedMessages: (conversationId: string) => Promise<boolean>;
|
||||||
saveMessages: (
|
saveMessages: (
|
||||||
arrayOfMessages: Array<MessageType>,
|
arrayOfMessages: Array<MessageType>,
|
||||||
options: { forceSave?: boolean }
|
options: { forceSave?: boolean }
|
||||||
|
|
|
@ -161,6 +161,7 @@ const dataInterface: ServerInterface = {
|
||||||
searchMessagesInConversation,
|
searchMessagesInConversation,
|
||||||
|
|
||||||
getMessageCount,
|
getMessageCount,
|
||||||
|
hasUserInitiatedMessages,
|
||||||
saveMessage,
|
saveMessage,
|
||||||
saveMessages,
|
saveMessages,
|
||||||
removeMessage,
|
removeMessage,
|
||||||
|
@ -2925,6 +2926,43 @@ async function getMessageCount(conversationId?: string): Promise<number> {
|
||||||
return row['count(*)'];
|
return row['count(*)'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called only for private conversations
|
||||||
|
async function hasUserInitiatedMessages(
|
||||||
|
conversationId: string
|
||||||
|
): Promise<boolean> {
|
||||||
|
const db = getInstance();
|
||||||
|
|
||||||
|
// We apply the limit in the sub-query so that `json_extract` wouldn't run
|
||||||
|
// for additional messages.
|
||||||
|
const row: { count: number } = db
|
||||||
|
.prepare<Query>(
|
||||||
|
`
|
||||||
|
SELECT COUNT(*) as count FROM
|
||||||
|
(
|
||||||
|
SELECT 1 FROM messages
|
||||||
|
WHERE
|
||||||
|
conversationId = $conversationId AND
|
||||||
|
(type IS NULL
|
||||||
|
OR
|
||||||
|
type NOT IN (
|
||||||
|
'profile-change',
|
||||||
|
'verified-change',
|
||||||
|
'message-history-unsynced',
|
||||||
|
'keychange',
|
||||||
|
'group-v1-migration',
|
||||||
|
'universal-timer-notification'
|
||||||
|
)
|
||||||
|
) AND
|
||||||
|
json_extract(json, '$.expirationTimerUpdate') IS NULL
|
||||||
|
LIMIT 1
|
||||||
|
);
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.get({ conversationId });
|
||||||
|
|
||||||
|
return row.count !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
function saveMessageSync(
|
function saveMessageSync(
|
||||||
data: MessageType,
|
data: MessageType,
|
||||||
options: { forceSave?: boolean; alreadyInTransaction?: boolean } = {}
|
options: { forceSave?: boolean; alreadyInTransaction?: boolean } = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue