Handle storyMessageRecipient updates before handling story messages

Co-authored-by: Josh Perez <60019601+josh-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2022-10-07 12:12:11 -07:00 committed by GitHub
parent 8e09f761fb
commit 6ff86c3747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 15 deletions

View File

@ -2688,15 +2688,6 @@ export default class MessageReceiver
if (syncMessage.sent) { if (syncMessage.sent) {
const sentMessage = syncMessage.sent; const sentMessage = syncMessage.sent;
if (sentMessage.storyMessage) {
this.handleStoryMessage(
envelope,
sentMessage.storyMessage,
sentMessage
);
return;
}
if (sentMessage.storyMessageRecipients && sentMessage.isRecipientUpdate) { if (sentMessage.storyMessageRecipients && sentMessage.isRecipientUpdate) {
if (window.Events.getHasStoriesDisabled()) { if (window.Events.getHasStoriesDisabled()) {
log.info( log.info(
@ -2721,6 +2712,15 @@ export default class MessageReceiver
return this.dispatchAndWait(ev); return this.dispatchAndWait(ev);
} }
if (sentMessage.storyMessage) {
this.handleStoryMessage(
envelope,
sentMessage.storyMessage,
sentMessage
);
return;
}
if (!sentMessage || !sentMessage.message) { if (!sentMessage || !sentMessage.message) {
throw new Error( throw new Error(
'MessageReceiver.handleSyncMessage: sync sent message was missing message' 'MessageReceiver.handleSyncMessage: sync sent message was missing message'

View File

@ -76,15 +76,15 @@ export async function onStoryRecipientUpdate(
const messages = await window.Signal.Data.getMessagesBySentAt(timestamp); const messages = await window.Signal.Data.getMessagesBySentAt(timestamp);
// Now we figure out who needs to be added and who needs to removed // Now we figure out who needs to be added and who needs to removed
messages.forEach(item => { const handledMessages = messages.filter(item => {
if (!isStory(item)) { if (!isStory(item)) {
return; return false;
} }
const { sendStateByConversationId, storyDistributionListId } = item; const { sendStateByConversationId, storyDistributionListId } = item;
if (!sendStateByConversationId || !storyDistributionListId) { if (!sendStateByConversationId || !storyDistributionListId) {
return; return false;
} }
const nextSendStateByConversationId = { const nextSendStateByConversationId = {
@ -136,7 +136,7 @@ export async function onStoryRecipientUpdate(
log.info( log.info(
'onStoryRecipientUpdate: sendStateByConversationId does not need update' 'onStoryRecipientUpdate: sendStateByConversationId does not need update'
); );
return; return true;
} }
const message = window.MessageController.register(item.id, item); const message = window.MessageController.register(item.id, item);
@ -170,9 +170,13 @@ export async function onStoryRecipientUpdate(
}); });
queueUpdateMessage(message.attributes); queueUpdateMessage(message.attributes);
} }
return true;
}); });
window.Whisper.events.trigger('incrementProgress'); if (handledMessages.length) {
confirm(); window.Whisper.events.trigger('incrementProgress');
confirm();
}
}); });
} }