@@ -38,14 +38,14 @@ function hitRateLimit(): boolean {
38
38
*/
39
39
const getMessageByReaction = async (
40
40
reaction : SignalService . DataMessage . IReaction ,
41
- isOpenGroup : boolean
41
+ openGroupConversationId ?: string
42
42
) : Promise < MessageModel | null > => {
43
43
let originalMessage = null ;
44
44
const originalMessageId = Number ( reaction . id ) ;
45
45
const originalMessageAuthor = reaction . author ;
46
46
47
- if ( isOpenGroup ) {
48
- originalMessage = await Data . getMessageByServerId ( originalMessageId ) ;
47
+ if ( openGroupConversationId && ! isEmpty ( openGroupConversationId ) ) {
48
+ originalMessage = await Data . getMessageByServerId ( openGroupConversationId , originalMessageId ) ;
49
49
} else {
50
50
const collection = await Data . getMessagesBySentAt ( originalMessageId ) ;
51
51
originalMessage = collection . find ( ( item : MessageModel ) => {
@@ -152,19 +152,19 @@ const handleMessageReaction = async ({
152
152
reaction,
153
153
sender,
154
154
you,
155
- isOpenGroup ,
155
+ openGroupConversationId ,
156
156
} : {
157
157
reaction : SignalService . DataMessage . IReaction ;
158
158
sender : string ;
159
159
you : boolean ;
160
- isOpenGroup : boolean ;
160
+ openGroupConversationId ?: string ;
161
161
} ) => {
162
162
if ( ! reaction . emoji ) {
163
163
window ?. log ?. warn ( `There is no emoji for the reaction ${ reaction } .` ) ;
164
164
return ;
165
165
}
166
166
167
- const originalMessage = await getMessageByReaction ( reaction , isOpenGroup ) ;
167
+ const originalMessage = await getMessageByReaction ( reaction , openGroupConversationId ) ;
168
168
if ( ! originalMessage ) {
169
169
return ;
170
170
}
@@ -240,10 +240,12 @@ const handleMessageReaction = async ({
240
240
* Handles updating the UI when clearing all reactions for a certain emoji
241
241
* Only usable by moderators in opengroups and runs on their client
242
242
*/
243
- const handleClearReaction = async ( serverId : number , emoji : string ) => {
244
- const originalMessage = await Data . getMessageByServerId ( serverId ) ;
243
+ const handleClearReaction = async ( conversationId : string , serverId : number , emoji : string ) => {
244
+ const originalMessage = await Data . getMessageByServerId ( conversationId , serverId ) ;
245
245
if ( ! originalMessage ) {
246
- window ?. log ?. warn ( `Cannot find the original reacted message ${ serverId } .` ) ;
246
+ window ?. log ?. warn (
247
+ `Cannot find the original reacted message ${ serverId } in conversation ${ conversationId } .`
248
+ ) ;
247
249
return ;
248
250
}
249
251
@@ -265,14 +267,18 @@ const handleClearReaction = async (serverId: number, emoji: string) => {
265
267
266
268
/**
267
269
* Handles all message reaction updates/responses for opengroups
270
+ * serverIds are not unique so we need the conversationId
268
271
*/
269
272
const handleOpenGroupMessageReactions = async (
270
- reactions : OpenGroupReactionList ,
271
- serverId : number
273
+ conversationId : string ,
274
+ serverId : number ,
275
+ reactions : OpenGroupReactionList
272
276
) => {
273
- const originalMessage = await Data . getMessageByServerId ( serverId ) ;
277
+ const originalMessage = await Data . getMessageByServerId ( conversationId , serverId ) ;
274
278
if ( ! originalMessage ) {
275
- window ?. log ?. warn ( `Cannot find the original reacted message ${ serverId } .` ) ;
279
+ window ?. log ?. warn (
280
+ `Cannot find the original reacted message ${ serverId } in conversation ${ conversationId } .`
281
+ ) ;
276
282
return ;
277
283
}
278
284
0 commit comments