Feat: Allow creating, linking, and unlinking groups from a community (#1729)

* feat: create group inside a community

* feat: link and unlink groups to a community
This commit is contained in:
Lucas Fochesatto
2025-09-07 08:08:34 -03:00
committed by GitHub
parent 50fc83b008
commit 2f2c1dc25e
+44
View File
@@ -149,6 +149,26 @@ export const makeCommunitiesSocket = (config: SocketConfig) => {
return await parseGroupResult(result)
},
communityCreateGroup: async (subject: string, participants: string[], parentCommunityJid: string) => {
const key = generateMessageIDV2()
const result = await communityQuery('@g.us', 'set', [
{
tag: 'create',
attrs: {
subject,
key
},
content: [
...participants.map(jid => ({
tag: 'participant',
attrs: { jid }
})),
{ tag: 'linked_parent', attrs: { jid: parentCommunityJid } }
]
}
])
return await parseGroupResult(result)
},
communityLeave: async (id: string) => {
await communityQuery('@g.us', 'set', [
{
@@ -167,6 +187,30 @@ export const makeCommunitiesSocket = (config: SocketConfig) => {
}
])
},
communityLinkGroup: async (groupJid: string, parentCommunityJid: string) => {
await communityQuery(parentCommunityJid, 'set', [
{
tag: 'links',
attrs: {},
content: [
{
tag: 'link',
attrs: { link_type: 'sub_group' },
content: [{ tag: 'group', attrs: { jid: groupJid } }]
}
]
}
])
},
communityUnlinkGroup: async (groupJid: string, parentCommunityJid: string) => {
await communityQuery(parentCommunityJid, 'set', [
{
tag: 'unlink',
attrs: { unlink_type: 'sub_group' },
content: [{ tag: 'group', attrs: { jid: groupJid } }]
}
])
},
communityRequestParticipantsList: async (jid: string) => {
const result = await communityQuery(jid, 'get', [
{