@@ -228,43 +228,40 @@ export async function onReaction(
228228
229229 const logId = `Reactions.onReaction(timestamp=${ reaction . timestamp } ;target=${ reaction . targetTimestamp } )` ;
230230
231- try {
232- const matchingMessage = await findMessageForReaction ( {
233- targetTimestamp : reaction . targetTimestamp ,
234- targetAuthorAci : reaction . targetAuthorAci ,
235- reactionSenderConversationId : reaction . fromId ,
236- logId,
237- } ) ;
238-
239- if ( ! matchingMessage ) {
240- log . info (
241- `${ logId } : No message for reaction` ,
242- 'targeting' ,
243- reaction . targetAuthorAci
244- ) ;
245- return ;
246- }
231+ const matchingMessage = await findMessageForReaction ( {
232+ targetTimestamp : reaction . targetTimestamp ,
233+ targetAuthorAci : reaction . targetAuthorAci ,
234+ reactionSenderConversationId : reaction . fromId ,
235+ logId,
236+ } ) ;
247237
248- const matchingMessageConversation = window . ConversationController . get (
249- matchingMessage . conversationId
238+ if ( ! matchingMessage ) {
239+ log . info (
240+ `${ logId } : No message for reaction` ,
241+ 'targeting' ,
242+ reaction . targetAuthorAci
250243 ) ;
244+ return ;
245+ }
251246
252- if ( ! matchingMessageConversation ) {
253- log . info (
254- `${ logId } : No target conversation for reaction` ,
255- reaction . targetAuthorAci ,
256- reaction . targetTimestamp
257- ) ;
258- remove ( reaction ) ;
259- return undefined ;
260- }
247+ const matchingMessageConversation = window . ConversationController . get (
248+ matchingMessage . conversationId
249+ ) ;
261250
262- // awaiting is safe since `onReaction` is never called from inside the queue
263- await matchingMessageConversation . queueJob (
264- 'Reactions.onReaction' ,
265- async ( ) => {
266- log . info ( `${ logId } : handling` ) ;
251+ if ( ! matchingMessageConversation ) {
252+ log . info (
253+ `${ logId } : No target conversation for reaction` ,
254+ reaction . targetAuthorAci ,
255+ reaction . targetTimestamp
256+ ) ;
257+ remove ( reaction ) ;
258+ return undefined ;
259+ }
267260
261+ drop (
262+ matchingMessageConversation . queueJob ( 'Reactions.onReaction' , async ( ) => {
263+ log . info ( `${ logId } : handling` ) ;
264+ try {
268265 // Message is fetched inside the conversation queue so we have the
269266 // most recent data
270267 const targetMessage = await findMessageForReaction ( {
@@ -302,12 +299,12 @@ export async function onReaction(
302299 }
303300
304301 remove ( reaction ) ;
302+ } catch ( error ) {
303+ remove ( reaction ) ;
304+ log . error ( `${ logId } error:` , Errors . toLogFormat ( error ) ) ;
305305 }
306- ) ;
307- } catch ( error ) {
308- remove ( reaction ) ;
309- log . error ( `${ logId } error:` , Errors . toLogFormat ( error ) ) ;
310- }
306+ } )
307+ ) ;
311308}
312309
313310export async function handleReaction (
0 commit comments