@@ -16,18 +16,17 @@ export async function reply({ tmid }: { tmid?: string }, message: IMessage, pare
1616 const { rid, ts, u } = message ;
1717
1818 const { toAll, toHere, mentionIds } = await getMentions ( message ) ;
19-
20- const filterUsersInRoom = async ( {
21- roomId,
22- userIds,
23- room
24- } : {
25- roomId : string ;
26- userIds : string [ ] ;
27- room : IRoom | null
19+
20+ const filterUsersInRoom = async ( {
21+ roomId,
22+ userIds,
23+ room,
24+ } : {
25+ roomId : string ;
26+ userIds : string [ ] ;
27+ room : IRoom | null ;
2828 } ) => {
2929 try {
30-
3130 if ( ! userIds . length || ! room ) {
3231 return [ ] ;
3332 }
@@ -37,34 +36,31 @@ export async function reply({ tmid }: { tmid?: string }, message: IMessage, pare
3736 }
3837
3938 if ( room . t === 'p' || room . t === 'c' ) {
40-
4139 const subscriptions = await Subscriptions . findByRoomIdAndUserIds ( roomId , userIds , {
4240 projection : { u : 1 } ,
4341 } ) . toArray ( ) ;
44-
42+
4543 return subscriptions . map ( ( sub ) => sub . u . _id ) ;
4644 }
4745
4846 return [ ] ;
49-
50- } catch ( error ) {
47+ } catch ( error ) {
5148 console . error ( 'Error filtering users in room:' , { roomId, error } ) ;
5249 return [ ] ;
5350 }
54- }
55-
51+ } ;
52+
5653 const room = await Rooms . findOneById ( rid ) ;
5754 const [ highlightsUids , threadFollowers ] = await Promise . all ( [
5855 getUserIdsFromHighlights ( rid , message ) ,
5956 Messages . getThreadFollowsByThreadId ( tmid ) ,
6057 ] ) ;
61-
62-
58+
6359 const [ followersInRoom , mentionIdsInRoom , highlightsUidsInRoom ] = await Promise . all ( [
6460 filterUsersInRoom ( { roomId : rid , userIds : followers , room } ) ,
6561 filterUsersInRoom ( { roomId : rid , userIds : mentionIds , room } ) ,
66- filterUsersInRoom ( { roomId : rid , userIds : highlightsUids , room } ) , // ← Add here
67- ] ) ;
62+ filterUsersInRoom ( { roomId : rid , userIds : highlightsUids , room } ) ,
63+ ] ) ;
6864
6965 const addToReplies = [
7066 ...new Set ( [
@@ -76,8 +72,6 @@ export async function reply({ tmid }: { tmid?: string }, message: IMessage, pare
7672
7773 await Messages . updateRepliesByThreadId ( tmid , addToReplies , ts ) ;
7874
79-
80-
8175 const threadFollowersUids = threadFollowers ?. filter ( ( userId ) => userId !== u . _id && ! mentionIdsInRoom . includes ( userId ) ) || [ ] ;
8276
8377 // Notify everyone involved in the thread
@@ -143,4 +137,4 @@ export const readThread = async ({ userId, rid, tmid }: { userId: string; rid: s
143137 }
144138
145139 await NotificationQueue . clearQueueByUserId ( userId ) ;
146- } ;
140+ } ;
0 commit comments