Skip to content

Commit

Permalink
Using the group story timestamp when adding to the conversation job q…
Browse files Browse the repository at this point in the history
…ueue

Co-authored-by: Alvaro <110414366+alvaro-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and alvaro-signal committed Oct 22, 2022
1 parent b4632cd commit 5e09bc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
27 changes: 17 additions & 10 deletions ts/jobs/helpers/sendStory.ts
Expand Up @@ -82,11 +82,10 @@ export async function sendStory(
return;
}

const messageTimestamp = message.get('timestamp');
const messageConversation = message.getConversation();
if (messageConversation !== conversation) {
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;
}
Expand All @@ -96,7 +95,7 @@ export async function sendStory(

if (!attachment) {
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;
}
Expand Down Expand Up @@ -177,18 +176,26 @@ export async function sendStory(
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();
if (messageConversation !== conversation) {
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;
}

if (message.isErased() || message.get('deletedForEveryone')) {
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;
}
Expand All @@ -200,7 +207,7 @@ export async function sendStory(

if (!receiverId) {
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;
}
Expand All @@ -227,7 +234,7 @@ export async function sendStory(

if (!shouldContinue) {
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, [
new Error('Message send ran out of time'),
Expand Down Expand Up @@ -257,7 +264,7 @@ export async function sendStory(
}
);
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.`
);
}

Expand All @@ -282,7 +289,7 @@ export async function sendStory(
);

log.info(
`stories.sendStory(${messageTimestamp}): sending story to ${receiverId}`
`stories.sendStory(${timestamp}): sending story to ${receiverId}`
);

const storyMessage = new Proto.StoryMessage();
Expand Down
3 changes: 2 additions & 1 deletion ts/util/sendStoryMessage.ts
Expand Up @@ -310,7 +310,8 @@ export async function sendStoryMessage(
type: conversationQueueJobEnum.enum.Story,
conversationId,
messageIds: [messageAttributes.id],
timestamp,
// using the group timestamp, which will differ from the 1:1 timestamp
timestamp: messageAttributes.timestamp,
},
async jobToInsert => {
const model = new window.Whisper.Message(messageAttributes);
Expand Down

0 comments on commit 5e09bc8

Please sign in to comment.