drop duplicate message with a timestamp close to the sent one
This commit is contained in:
parent
1e446b0a81
commit
b96ddf4f07
15
app/sql.js
15
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue