drop duplicate message with a timestamp close to the sent one

pull/1321/head
Audric Ackermann 5 years ago
parent 1e446b0a81
commit b96ddf4f07
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -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…
Cancel
Save