* fix: improve message resend logic by adding checks for message IDs * Revert "fix: improve message resend logic by adding checks for message IDs" This reverts commit c03f9d8e6fc6cbfbb9d1f8f67c169700e704213d. * feat: add group member label update functionality and event emission * feat: refactor updateMemberLabel function for improved readability * feat: use optional chaining for label association message in processMessage * feat: add updateMemberLabel to makeMessagesSocket for enhanced functionality * fix: correct log message for group member tag update event Co-authored-by: FgsiDev
This commit is contained in:
@@ -223,6 +223,10 @@ const startSock = async() => {
|
|||||||
if(events['chats.delete']) {
|
if(events['chats.delete']) {
|
||||||
console.log('chats deleted ', events['chats.delete'])
|
console.log('chats deleted ', events['chats.delete'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(events['group.member-tag.update']) {
|
||||||
|
console.log('group member tag update', JSON.stringify(events['group.member-tag.update'], undefined, 2))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -383,6 +383,36 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
return deviceResults
|
return deviceResults
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Member Label
|
||||||
|
*/
|
||||||
|
const updateMemberLabel = (jid: string, memberLabel: string) => {
|
||||||
|
return relayMessage(
|
||||||
|
jid,
|
||||||
|
{
|
||||||
|
protocolMessage: {
|
||||||
|
type: proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE,
|
||||||
|
memberLabel: {
|
||||||
|
label: memberLabel?.slice(0, 30),
|
||||||
|
labelTimestamp: unixTimestampSeconds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
additionalNodes: [
|
||||||
|
{
|
||||||
|
tag: 'meta',
|
||||||
|
attrs: {
|
||||||
|
tag_reason: 'user_update',
|
||||||
|
appdata: 'member_tag'
|
||||||
|
},
|
||||||
|
content: undefined
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const assertSessions = async (jids: string[], force?: boolean) => {
|
const assertSessions = async (jids: string[], force?: boolean) => {
|
||||||
let didFetchNewSession = false
|
let didFetchNewSession = false
|
||||||
const uniqueJids = [...new Set(jids)] // Deduplicate JIDs
|
const uniqueJids = [...new Set(jids)] // Deduplicate JIDs
|
||||||
@@ -1069,6 +1099,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
createParticipantNodes,
|
createParticipantNodes,
|
||||||
getUSyncDevices,
|
getUSyncDevices,
|
||||||
messageRetryManager,
|
messageRetryManager,
|
||||||
|
updateMemberLabel,
|
||||||
updateMediaMessage: async (message: WAMessage) => {
|
updateMediaMessage: async (message: WAMessage) => {
|
||||||
const content = assertMediaContent(message.message)
|
const content = assertMediaContent(message.message)
|
||||||
const mediaKey = content.mediaKey!
|
const mediaKey = content.mediaKey!
|
||||||
|
|||||||
@@ -78,6 +78,14 @@ export type BaileysEventMap = {
|
|||||||
action: RequestJoinAction
|
action: RequestJoinAction
|
||||||
method: RequestJoinMethod
|
method: RequestJoinMethod
|
||||||
}
|
}
|
||||||
|
/* update the labels assigned to a group participant */
|
||||||
|
'group.member-tag.update': {
|
||||||
|
groupId: string
|
||||||
|
participant: string
|
||||||
|
participantAlt?: string
|
||||||
|
label: string
|
||||||
|
messageTimestamp?: number
|
||||||
|
}
|
||||||
|
|
||||||
'blocklist.set': { blocklist: string[] }
|
'blocklist.set': { blocklist: string[] }
|
||||||
'blocklist.update': { blocklist: string[]; type: 'add' | 'remove' }
|
'blocklist.update': { blocklist: string[]; type: 'add' | 'remove' }
|
||||||
|
|||||||
@@ -378,6 +378,19 @@ const processMessage = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
break
|
||||||
|
case proto.Message.ProtocolMessage.Type.GROUP_MEMBER_LABEL_CHANGE:
|
||||||
|
const labelAssociationMsg = protocolMsg.memberLabel
|
||||||
|
if (labelAssociationMsg?.label) {
|
||||||
|
ev.emit('group.member-tag.update', {
|
||||||
|
groupId: chat.id!,
|
||||||
|
label: labelAssociationMsg.label,
|
||||||
|
participant: message.key.participant!,
|
||||||
|
participantAlt: message.key.participantAlt!,
|
||||||
|
messageTimestamp: Number(message.messageTimestamp)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
|
case proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
|
||||||
const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload!
|
const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload!
|
||||||
|
|||||||
Reference in New Issue
Block a user