77import type { DBThreadReaction } from 'shared/types' ;
88import { events } from 'shared/analytics' ;
99import { trackQueue } from 'shared/bull/queues' ;
10+ import { getThreadById } from './thread' ;
1011
1112type ThreadReactionType = 'like' ;
1213
@@ -34,6 +35,7 @@ export const addThreadReaction = (input: ThreadReactionInput, userId: string): P
3435 . filter ( { userId } )
3536 . run ( )
3637 . then ( async results => {
38+ const thread = await getThreadById ( input . threadId )
3739 // if the reaction already exists in the db, it was previously deleted
3840 // just remove the deletedAt field
3941 if ( results && results . length > 0 ) {
@@ -47,13 +49,15 @@ export const addThreadReaction = (input: ThreadReactionInput, userId: string): P
4749 } ,
4850 } ) ;
4951
50- sendThreadReactionNotificationQueue . add ( { threadReaction : thisReaction , userId } ) ;
52+ if ( thread && ( thread . creatorId !== userId ) ) {
53+ sendThreadReactionNotificationQueue . add ( { threadReaction : thisReaction , userId } ) ;
5154
52- processReputationEventQueue . add ( {
53- userId,
54- type : 'thread reaction created' ,
55- entityId : thisReaction . threadId ,
56- } ) ;
55+ processReputationEventQueue . add ( {
56+ userId,
57+ type : 'thread reaction created' ,
58+ entityId : thisReaction . threadId ,
59+ } ) ;
60+ }
5761
5862 return db
5963 . table ( 'threadReactions' )
@@ -84,13 +88,15 @@ export const addThreadReaction = (input: ThreadReactionInput, userId: string): P
8488 context : { threadReactionId : threadReaction . id } ,
8589 } ) ;
8690
87- sendThreadReactionNotificationQueue . add ( { threadReaction, userId } ) ;
88-
89- processReputationEventQueue . add ( {
90- userId,
91- type : 'thread reaction created' ,
92- entityId : threadReaction . threadId ,
93- } ) ;
91+ if ( thread && ( thread . creatorId !== userId ) ) {
92+ sendThreadReactionNotificationQueue . add ( { threadReaction : threadReaction , userId } ) ;
93+
94+ processReputationEventQueue . add ( {
95+ userId,
96+ type : 'thread reaction created' ,
97+ entityId : threadReaction . threadId ,
98+ } ) ;
99+ }
94100
95101 return threadReaction ;
96102 } ) ;
0 commit comments