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:
@@ -149,6 +149,26 @@ export const makeCommunitiesSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
return await parseGroupResult(result)
|
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) => {
|
communityLeave: async (id: string) => {
|
||||||
await communityQuery('@g.us', 'set', [
|
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) => {
|
communityRequestParticipantsList: async (jid: string) => {
|
||||||
const result = await communityQuery(jid, 'get', [
|
const result = await communityQuery(jid, 'get', [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user