feat: add event that handles join approval requests (#802)

* initial commit

* lint

* add type in method

* add more actions / fixes participant jid / rename event

* fixes

* more fixes

* fix typing

* change 'reject' to 'rejected'

* chore:linting

---------

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
vini
2024-06-02 18:10:36 -03:00
committed by GitHub
parent 9065ab690f
commit ffec4af454
4 changed files with 28 additions and 2 deletions

View File

@@ -4,7 +4,7 @@ import { AuthenticationCreds } from './Auth'
import { WACallEvent } from './Call'
import { Chat, ChatUpdate, PresenceData } from './Chat'
import { Contact } from './Contact'
import { GroupMetadata, ParticipantAction } from './GroupMetadata'
import { GroupMetadata, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata'
import { Label } from './Label'
import { LabelAssociation } from './LabelAssociation'
import { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message'
@@ -52,6 +52,7 @@ export type BaileysEventMap = {
'groups.update': Partial<GroupMetadata>[]
/** apply an action to participants in a group */
'group-participants.update': { id: string, author: string, participants: string[], action: ParticipantAction }
'group.join-request': { id: string, author: string, participant: string, action: RequestJoinAction, method: RequestJoinMethod }
'blocklist.set': { blocklist: string[] }
'blocklist.update': { blocklist: string[], type: 'add' | 'remove' }

View File

@@ -4,6 +4,10 @@ export type GroupParticipant = (Contact & { isAdmin?: boolean, isSuperAdmin?: bo
export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote'
export type RequestJoinAction = 'created' | 'revoked' | 'rejected'
export type RequestJoinMethod = 'invite_link' | 'linked_group_join' | 'non_admin_add' | undefined
export interface GroupMetadata {
id: string
owner: string | undefined