Fix check for universal timer notification
This commit is contained in:
parent
0f4a1d6e28
commit
a6ce00ff37
4 changed files with 49 additions and 3 deletions
|
@ -161,6 +161,7 @@ const dataInterface: ServerInterface = {
|
|||
searchMessagesInConversation,
|
||||
|
||||
getMessageCount,
|
||||
hasUserInitiatedMessages,
|
||||
saveMessage,
|
||||
saveMessages,
|
||||
removeMessage,
|
||||
|
@ -2925,6 +2926,43 @@ async function getMessageCount(conversationId?: string): Promise<number> {
|
|||
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(
|
||||
data: MessageType,
|
||||
options: { forceSave?: boolean; alreadyInTransaction?: boolean } = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue