mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-18 07:36:00 +01:00
Simplify message deduplication
This commit is contained in:
@@ -458,7 +458,6 @@ export const DataReader: ServerReadableInterface = {
|
||||
getReactionByTimestamp,
|
||||
_getAllReactions,
|
||||
getMessageByAuthorAciAndSentAt,
|
||||
getMessageBySender,
|
||||
getMessageById,
|
||||
getMessagesById,
|
||||
_getAllMessages,
|
||||
@@ -3542,55 +3541,6 @@ function getMessageByAuthorAciAndSentAt(
|
||||
})();
|
||||
}
|
||||
|
||||
function getMessageBySender(
|
||||
db: ReadableDB,
|
||||
{
|
||||
source,
|
||||
sourceServiceId,
|
||||
sourceDevice,
|
||||
sent_at,
|
||||
}: {
|
||||
source?: string;
|
||||
sourceServiceId?: ServiceIdString;
|
||||
sourceDevice?: number;
|
||||
sent_at: number;
|
||||
}
|
||||
): MessageType | undefined {
|
||||
return db.transaction(() => {
|
||||
const rows: Array<MessageTypeUnhydrated> = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT ${MESSAGE_COLUMNS.join(', ')} FROM messages WHERE
|
||||
(source = $source OR sourceServiceId = $sourceServiceId) AND
|
||||
sourceDevice = $sourceDevice AND
|
||||
sent_at = $sent_at
|
||||
LIMIT 2;
|
||||
`
|
||||
)
|
||||
.all({
|
||||
source: source || null,
|
||||
sourceServiceId: sourceServiceId || null,
|
||||
sourceDevice: sourceDevice || null,
|
||||
sent_at,
|
||||
});
|
||||
|
||||
if (rows.length > 1) {
|
||||
logger.warn('getMessageBySender: More than one message found for', {
|
||||
sent_at,
|
||||
source,
|
||||
sourceServiceId,
|
||||
sourceDevice,
|
||||
});
|
||||
}
|
||||
|
||||
if (rows.length < 1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return hydrateMessage(db, rows[0]);
|
||||
})();
|
||||
}
|
||||
|
||||
export function _storyIdPredicate(
|
||||
storyId: string | undefined,
|
||||
includeStoryReplies: boolean
|
||||
|
||||
Reference in New Issue
Block a user