diff --git a/app/sql.js b/app/sql.js index 9781cba61..225fb7e45 100644 --- a/app/sql.js +++ b/app/sql.js @@ -129,6 +129,7 @@ module.exports = { removeMessage, getUnreadByConversation, getMessageBySender, + getMessagesBySender, getMessageIdsFromServerIds, getMessageById, getAllMessages, @@ -2411,6 +2412,20 @@ async function getMessageBySender({ source, sourceDevice, sent_at }) { return map(rows, row => jsonToObject(row.json)); } +async function getMessagesBySender({ source, sourceDevice }) { + const rows = await db.all( + `SELECT json FROM messages WHERE + source = $source AND + sourceDevice = $sourceDevice`, + { + $source: source, + $sourceDevice: sourceDevice, + } + ); + + return map(rows, row => jsonToObject(row.json)); +} + async function getAllUnsentMessages() { const rows = await db.all(` SELECT json FROM messages WHERE diff --git a/js/modules/data.js b/js/modules/data.js index cb2912fa5..8111770f5 100644 --- a/js/modules/data.js +++ b/js/modules/data.js @@ -1005,13 +1005,12 @@ async function getMessageBySender( async function getMessagesBySender( // eslint-disable-next-line camelcase - { source, sourceDevice, sent_at }, + { source, sourceDevice }, { Message } ) { - const messages = await channels.getMessageBySender({ + const messages = await channels.getMessagesBySender({ source, sourceDevice, - sent_at, }); if (!messages || !messages.length) { return null;