group events: fix serialization issue

This commit is contained in:
Rajeh Taher
2025-10-07 20:17:07 +03:00
parent 60c688b85d
commit acc5111792
4 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -393,7 +393,7 @@ export const makeCommunitiesSocket = (config: SocketConfig) => {
participant: key.remoteJid
},
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
messageStubParameters: [authState.creds.me!.id],
messageStubParameters: [JSON.stringify(authState.creds.me)],
participant: key.remoteJid,
messageTimestamp: unixTimestampSeconds()
},
+1 -1
View File
@@ -265,7 +265,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
participant: key.remoteJid
},
messageStubType: WAMessageStubType.GROUP_PARTICIPANT_ADD,
messageStubParameters: [authState.creds.me!.id],
messageStubParameters: [JSON.stringify(authState.creds.me)],
participant: key.remoteJid,
messageTimestamp: unixTimestampSeconds()
},
+3 -3
View File
@@ -629,7 +629,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
msg.messageStubType = WAMessageStubType.GROUP_PARTICIPANT_LEAVE
}
msg.messageStubParameters = participants
msg.messageStubParameters = participants.map(a => JSON.stringify(a))
break
case 'subject':
msg.messageStubType = WAMessageStubType.GROUP_CHANGE_SUBJECT
@@ -673,7 +673,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
case 'created_membership_requests':
msg.messageStubType = WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD
msg.messageStubParameters = [
{ lid: affectedParticipantLid, pn: affectedParticipantPn } as LIDMapping,
JSON.stringify({ lid: affectedParticipantLid, pn: affectedParticipantPn }),
'created',
child.attrs.request_method!
]
@@ -683,7 +683,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
// TODO: LIDMAPPING SUPPORT
msg.messageStubType = WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD
msg.messageStubParameters = [
{ lid: affectedParticipantLid, pn: affectedParticipantPn } as LIDMapping,
JSON.stringify({ lid: affectedParticipantLid, pn: affectedParticipantPn }),
isDenied ? 'revoked' : 'rejected'
]
break
+6 -6
View File
@@ -395,12 +395,12 @@ const processMessage = async (
switch (message.messageStubType) {
case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
participants = message.messageStubParameters || []
participants = message.messageStubParameters.map((a: any) => JSON.parse(a as string)) || []
emitParticipantsUpdate('modify')
break
case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
participants = message.messageStubParameters || []
participants = message.messageStubParameters.map((a: any) => JSON.parse(a as string)) || []
emitParticipantsUpdate('remove')
// mark the chat read only if you left the group
if (participantsIncludesMe()) {
@@ -411,7 +411,7 @@ const processMessage = async (
case WAMessageStubType.GROUP_PARTICIPANT_ADD:
case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
participants = message.messageStubParameters || []
participants = message.messageStubParameters.map((a: any) => JSON.parse(a as string)) || []
if (participantsIncludesMe()) {
chat.readOnly = false
}
@@ -419,11 +419,11 @@ const processMessage = async (
emitParticipantsUpdate('add')
break
case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
participants = message.messageStubParameters || []
participants = message.messageStubParameters.map((a: any) => JSON.parse(a as string)) || []
emitParticipantsUpdate('demote')
break
case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
participants = message.messageStubParameters || []
participants = message.messageStubParameters.map((a: any) => JSON.parse(a as string)) || []
emitParticipantsUpdate('promote')
break
case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
@@ -457,7 +457,7 @@ const processMessage = async (
emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' })
break
case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD: // TODO: Add other events
const participant = message.messageStubParameters?.[0] as LIDMapping
const participant = JSON.parse(message.messageStubParameters?.[0]) as LIDMapping
const action = message.messageStubParameters?.[1] as RequestJoinAction
const method = message.messageStubParameters?.[2] as RequestJoinMethod
emitGroupRequestJoin(participant, action, method)