Add group calling events to the message timeline

This commit is contained in:
Evan Hahn 2020-12-07 14:43:19 -06:00 committed by GitHub
parent a2f285d243
commit 0c039bf431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 1275 additions and 239 deletions

View file

@ -145,6 +145,7 @@ const dataInterface: ServerInterface = {
getMessageMetricsForConversation,
getLastConversationActivity,
getLastConversationPreview,
hasGroupCallHistoryMessage,
migrateConversationMessages,
getUnprocessedCount,
@ -2880,6 +2881,34 @@ async function getMessageMetricsForConversation(conversationId: string) {
}
getMessageMetricsForConversation.needsSerial = true;
async function hasGroupCallHistoryMessage(
conversationId: string,
eraId: string
): Promise<boolean> {
const db = getInstance();
const row: unknown = await db.get(
`
SELECT count(*) FROM messages
WHERE conversationId = $conversationId
AND type = 'call-history'
AND json_extract(json, '$.callHistoryDetails.callMode') = 'Group'
AND json_extract(json, '$.callHistoryDetails.eraId') = $eraId
LIMIT 1;
`,
{
$conversationId: conversationId,
$eraId: eraId,
}
);
if (typeof row === 'object' && row && !Array.isArray(row)) {
const count = Number((row as Record<string, unknown>)['count(*)']);
return Boolean(count);
}
return false;
}
async function migrateConversationMessages(
obsoleteId: string,
currentId: string