Log when message lacks sent_at or timestamp on send

This commit is contained in:
Evan Hahn 2021-10-13 13:50:58 -05:00 committed by GitHub
parent 99934ced90
commit 95b761b62e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -225,7 +225,7 @@ export class NormalMessageSendJobQueue extends JobQueue<NormalMessageSendJobData
profileKey, profileKey,
quote, quote,
sticker, sticker,
} = await getMessageSendData({ conversation, message }); } = await getMessageSendData({ conversation, log, message });
let messageSendPromise: Promise<unknown>; let messageSendPromise: Promise<unknown>;
@ -453,9 +453,11 @@ function getMessageRecipients({
async function getMessageSendData({ async function getMessageSendData({
conversation, conversation,
log,
message, message,
}: Readonly<{ }: Readonly<{
conversation: ConversationModel; conversation: ConversationModel;
log: LoggerType;
message: MessageModel; message: MessageModel;
}>): Promise<{ }>): Promise<{
attachments: Array<AttachmentType>; attachments: Array<AttachmentType>;
@ -469,8 +471,20 @@ async function getMessageSendData({
quote: WhatIsThis; quote: WhatIsThis;
sticker: WhatIsThis; sticker: WhatIsThis;
}> { }> {
const messageTimestamp = let messageTimestamp: number;
message.get('sent_at') || message.get('timestamp') || Date.now(); const sentAt = message.get('sent_at');
const timestamp = message.get('timestamp');
if (sentAt) {
messageTimestamp = sentAt;
} else if (timestamp) {
log.error('message lacked sent_at. Falling back to timestamp');
messageTimestamp = timestamp;
} else {
log.error(
'message lacked sent_at and timestamp. Falling back to current time'
);
messageTimestamp = Date.now();
}
const [ const [
attachmentsWithData, attachmentsWithData,