Using the group story timestamp when adding to the conversation job queue

This commit is contained in:
Alvaro 2022-10-21 18:38:49 -06:00 committed by GitHub
parent e37e3dc82c
commit ba55285c74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View file

@ -82,11 +82,10 @@ export async function sendStory(
return; return;
} }
const messageTimestamp = message.get('timestamp');
const messageConversation = message.getConversation(); const messageConversation = message.getConversation();
if (messageConversation !== conversation) { if (messageConversation !== conversation) {
log.error( log.error(
`stories.sendStory(${messageTimestamp}): Message conversation '${messageConversation?.idForLogging()}' does not match job conversation ${conversation.idForLogging()}` `stories.sendStory(${timestamp}): Message conversation '${messageConversation?.idForLogging()}' does not match job conversation ${conversation.idForLogging()}`
); );
return; return;
} }
@ -96,7 +95,7 @@ export async function sendStory(
if (!attachment) { if (!attachment) {
log.info( log.info(
`stories.sendStory(${messageTimestamp}): message does not have any attachments to send. Giving up on sending it` `stories.sendStory(${timestamp}): message does not have any attachments to send. Giving up on sending it`
); );
return; return;
} }
@ -177,18 +176,26 @@ export async function sendStory(
return; return;
} }
const messageTimestamp = message.get('timestamp'); if (message.get('timestamp') !== timestamp) {
log.error(
`stories.sendStory(${timestamp}): Message timestamp ${message.get(
'timestamp'
)} does not match job timestamp`
);
return;
}
const messageConversation = message.getConversation(); const messageConversation = message.getConversation();
if (messageConversation !== conversation) { if (messageConversation !== conversation) {
log.error( log.error(
`stories.sendStory(${messageTimestamp}): Message conversation '${messageConversation?.idForLogging()}' does not match job conversation ${conversation.idForLogging()}` `stories.sendStory(${timestamp}): Message conversation '${messageConversation?.idForLogging()}' does not match job conversation ${conversation.idForLogging()}`
); );
return; return;
} }
if (message.isErased() || message.get('deletedForEveryone')) { if (message.isErased() || message.get('deletedForEveryone')) {
log.info( log.info(
`stories.sendStory(${messageTimestamp}): message was erased. Giving up on sending it` `stories.sendStory(${timestamp}): message was erased. Giving up on sending it`
); );
return; return;
} }
@ -200,7 +207,7 @@ export async function sendStory(
if (!receiverId) { if (!receiverId) {
log.info( log.info(
`stories.sendStory(${messageTimestamp}): did not get a valid recipient ID for message. Giving up on sending it` `stories.sendStory(${timestamp}): did not get a valid recipient ID for message. Giving up on sending it`
); );
return; return;
} }
@ -227,7 +234,7 @@ export async function sendStory(
if (!shouldContinue) { if (!shouldContinue) {
log.info( log.info(
`stories.sendStory(${messageTimestamp}): ran out of time. Giving up on sending it` `stories.sendStory(${timestamp}): ran out of time. Giving up on sending it`
); );
await markMessageFailed(message, [ await markMessageFailed(message, [
new Error('Message send ran out of time'), new Error('Message send ran out of time'),
@ -257,7 +264,7 @@ export async function sendStory(
} }
); );
throw new Error( throw new Error(
`stories.sendStory(${messageTimestamp}): sending blocked because ${untrustedUuids.length} conversation(s) were untrusted. Failing this attempt.` `stories.sendStory(${timestamp}): sending blocked because ${untrustedUuids.length} conversation(s) were untrusted. Failing this attempt.`
); );
} }
@ -282,7 +289,7 @@ export async function sendStory(
); );
log.info( log.info(
`stories.sendStory(${messageTimestamp}): sending story to ${receiverId}` `stories.sendStory(${timestamp}): sending story to ${receiverId}`
); );
const storyMessage = new Proto.StoryMessage(); const storyMessage = new Proto.StoryMessage();

View file

@ -310,7 +310,8 @@ export async function sendStoryMessage(
type: conversationQueueJobEnum.enum.Story, type: conversationQueueJobEnum.enum.Story,
conversationId, conversationId,
messageIds: [messageAttributes.id], messageIds: [messageAttributes.id],
timestamp, // using the group timestamp, which will differ from the 1:1 timestamp
timestamp: messageAttributes.timestamp,
}, },
async jobToInsert => { async jobToInsert => {
const model = new window.Whisper.Message(messageAttributes); const model = new window.Whisper.Message(messageAttributes);