Retry outbound reactions for up to a day
This commit is contained in:
parent
4a6b7968c1
commit
8670a4d864
25 changed files with 1444 additions and 473 deletions
46
ts/reactions/enqueueReactionForSend.ts
Normal file
46
ts/reactions/enqueueReactionForSend.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { ReactionModel } from '../messageModifiers/Reactions';
|
||||
import { ReactionSource } from './ReactionSource';
|
||||
import { getMessageById } from '../messages/getMessageById';
|
||||
import { strictAssert } from '../util/assert';
|
||||
|
||||
export async function enqueueReactionForSend({
|
||||
emoji,
|
||||
messageId,
|
||||
remove,
|
||||
}: Readonly<{
|
||||
emoji: string;
|
||||
messageId: string;
|
||||
remove: boolean;
|
||||
}>): Promise<void> {
|
||||
const message = await getMessageById(messageId);
|
||||
strictAssert(message, 'enqueueReactionForSend: no message found');
|
||||
|
||||
const targetAuthorUuid = message.getSourceUuid();
|
||||
strictAssert(
|
||||
targetAuthorUuid,
|
||||
`enqueueReactionForSend: message ${message.idForLogging()} had no source UUID`
|
||||
);
|
||||
|
||||
const targetTimestamp = message.get('sent_at') || message.get('timestamp');
|
||||
strictAssert(
|
||||
targetTimestamp,
|
||||
`enqueueReactionForSend: message ${message.idForLogging()} had no timestamp`
|
||||
);
|
||||
|
||||
const reaction = new ReactionModel({
|
||||
emoji,
|
||||
remove,
|
||||
targetAuthorUuid,
|
||||
targetTimestamp,
|
||||
fromId: window.ConversationController.getOurConversationIdOrThrow(),
|
||||
timestamp: Date.now(),
|
||||
source: ReactionSource.FromThisDevice,
|
||||
});
|
||||
|
||||
await message.getConversation()?.maybeApplyUniversalTimer(false);
|
||||
|
||||
await message.handleReaction(reaction);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue