Message Requests improvements
This commit is contained in:
parent
b63291507a
commit
81cb7730a5
21 changed files with 302 additions and 263 deletions
|
@ -132,6 +132,8 @@ const dataInterface: ServerInterface = {
|
|||
getOlderMessagesByConversation,
|
||||
getNewerMessagesByConversation,
|
||||
getMessageMetricsForConversation,
|
||||
getLastConversationActivity,
|
||||
getLastConversationPreview,
|
||||
migrateConversationMessages,
|
||||
|
||||
getUnprocessedCount,
|
||||
|
@ -2749,6 +2751,50 @@ async function getNewestMessageForConversation(conversationId: string) {
|
|||
|
||||
return row;
|
||||
}
|
||||
|
||||
async function getLastConversationActivity(
|
||||
conversationId: string
|
||||
): Promise<MessageType | null> {
|
||||
const db = getInstance();
|
||||
const row = await db.get(
|
||||
`SELECT * FROM messages WHERE
|
||||
conversationId = $conversationId AND
|
||||
type NOT IN ('profile-change', 'verified-change', 'message-history-unsynced') AND
|
||||
json_extract(json, '$.expirationTimerUpdate.fromSync') != true
|
||||
ORDER BY received_at DESC
|
||||
LIMIT 1;`,
|
||||
{
|
||||
$conversationId: conversationId,
|
||||
}
|
||||
);
|
||||
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonToObject(row.json);
|
||||
}
|
||||
async function getLastConversationPreview(
|
||||
conversationId: string
|
||||
): Promise<MessageType | null> {
|
||||
const db = getInstance();
|
||||
const row = await db.get(
|
||||
`SELECT * FROM messages WHERE
|
||||
conversationId = $conversationId AND
|
||||
type NOT IN ('profile-change', 'verified-change', 'message-history-unsynced')
|
||||
ORDER BY received_at DESC
|
||||
LIMIT 1;`,
|
||||
{
|
||||
$conversationId: conversationId,
|
||||
}
|
||||
);
|
||||
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonToObject(row.json);
|
||||
}
|
||||
async function getOldestUnreadMessageForConversation(conversationId: string) {
|
||||
const db = getInstance();
|
||||
const row = await db.get(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue