Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(baileys): answer 404 when a group write targets an unknown group
Yudhi Armyndharis412df5f6f98c
diff --git a/openapi.json b/openapi.jsonindex 2438f824c..57d7ea315 100644--- a/openapi.json+++ b/openapi.json@@ -5359,6 +5359,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5420,6 +5423,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5483,6 +5489,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5546,6 +5555,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5600,6 +5612,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5661,6 +5676,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5722,6 +5740,9 @@"403": {"description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5782,6 +5803,9 @@"403": {"description": "The engine refused the change — admin rights are required"},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5842,6 +5866,9 @@"403": {"description": "The engine refused the change — admin rights are required"},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -5889,6 +5916,9 @@}}},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -6110,6 +6140,9 @@"403": {"description": "The engine refused the request — admin rights required for this group"},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -6160,6 +6193,9 @@"403": {"description": "The engine refused the request — admin rights required for this group"},+ "404": {+ "description": "No such group — the id is unknown."+ },"409": {"description": "The session is not connected: an engine exists for it but is not `ready`, meaning disconnected, reconnecting, or still initializing, so the request never reached WhatsApp. Wait for `ready` and retry. A session that was never started answers `400` instead, and the session lifecycle routes answer `409` for a conflicting state rather than this. One window answers this while the session still reads `ready`: WhatsApp Web periodically reloads its own page and the engine re-injects into it, and for those few seconds the answer is a `409` naming the reload; retry shortly."},@@ -7491,6 +7527,9 @@}}},+ "403": {+ "description": "WhatsApp refused the operation. The request was well formed — the refusal happened WhatsApp-side, most often because the account lacks the admin rights the operation requires."+ },"404": {"description": "The invite code does not resolve to a channel — it is wrong, expired, or revoked. This route takes an invite code rather than a channel id."},diff --git a/src/engine/adapters/baileys-groups.ts b/src/engine/adapters/baileys-groups.tsindex 4fcab66db..0bf6e1a29 100644--- a/src/engine/adapters/baileys-groups.ts+++ b/src/engine/adapters/baileys-groups.ts@@ -72,16 +72,23 @@ export function refusedStatusCode(error: unknown): number | undefined {* adapter gives these causes — instead of letting the raw Boom escape as a 500. Transport/local* failures (dropped socket, timeout) propagate untouched: folding them in would report a dead* connection as a permissions problem.+ *+ * `notFound`, when given, takes WA code 404 (item-not-found) instead: a caller whose request names a+ * single resource maps it to that resource's not-found error rather than a permissions refusal.*/export async function mapServerRefusal<T>(operation: string,op: () => Promise<T>,classify: (error: unknown) => number | undefined = refusedStatusCode,+ notFound?: () => Error,): Promise<T> {try {return await op();} catch (error) {const code = classify(error);+ if (code === 404 && notFound) {+ throw notFound();+ }if (code !== undefined && code >= 400 && code < 500) {throw new EngineRefusedError(`${operation} was refused by WhatsApp (code ${code}) — admin rights or permissions may be missing`,@@ -152,6 +159,16 @@ export class BaileysGroups {return this.host.getSocket();}+ /**+ * {@link mapServerRefusal} for a request that names one group: WhatsApp's item-not-found (404)+ * means the group does not exist or is not visible to the account, which getGroupInfo already+ * reads as not-found, so it answers 404 as whatsapp-web.js does rather than a 403 permissions+ * refusal. The w:g2 group IQs are addressed to the group jid, and a leave names only that group.+ */+ private groupWrite<T>(groupId: string, operation: string, op: () => Promise<T>): Promise<T> {+ return mapServerRefusal(operation, op, refusedStatusCode, () => new GroupNotFoundError(groupId));+ }+/** Neutral → engine id fold for participant/mention lists. */private toEngineParticipants(participants: string[]): string[] {return toEngineParticipants(participants, jid => this.host.toEngineJid(jid));@@ -252,7 +269,7 @@ export class BaileysGroups {this.host.ensureReady();// An unanswered query yields [], which the empty-results guard below would report as a refusal// — a dead transport sold to the caller as a permissions problem.- const raw = await mapServerRefusal(`The participant ${action}`, () =>+ const raw = await this.groupWrite(groupId, `The participant ${action}`, () =>withQueryDeadline(this.sock().groupParticipantsUpdate(groupId, this.toEngineParticipants(participants), action),this.queryBudgetMs,@@ -281,23 +298,23 @@ export class BaileysGroups {async leaveGroup(groupId: string): Promise<void> {this.host.ensureReady();// Wrapped like every other group write in this file. Without it WhatsApp's refusal for an- // unknown or already-left group reached the client as an opaque 500, while whatsapp-web.js- // resolves the chat first and answers 404.- await mapServerRefusal('Leaving the group', () =>+ // unknown or already-left group reached the client as an opaque 500; its not-found answers 404,+ // as whatsapp-web.js does after resolving the chat.+ await this.groupWrite(groupId, 'Leaving the group', () =>this.confirmed(this.sock().groupLeave(groupId), 'leaving the group'),);}async setGroupSubject(groupId: string, subject: string): Promise<void> {this.host.ensureReady();- await mapServerRefusal('Setting the group subject', () =>+ await this.groupWrite(groupId, 'Setting the group subject', () =>this.confirmed(this.sock().groupUpdateSubject(groupId, subject), 'the group subject change'),);}async setGroupDescription(groupId: string, description: string): Promise<void> {this.host.ensureReady();- await mapServerRefusal('Setting the group description', () =>+ await this.groupWrite(groupId, 'Setting the group description', () =>this.confirmed(this.sock().groupUpdateDescription(groupId, description), 'the group description change'),);}@@ -312,7 +329,9 @@ export class BaileysGroups {*/async getGroupInviteCode(groupId: string): Promise<string> {this.host.ensureReady();- const code = await mapServerRefusal('Fetching the group invite code', () => this.sock().groupInviteCode(groupId));+ const code = await this.groupWrite(groupId, 'Fetching the group invite code', () =>+ this.sock().groupInviteCode(groupId),+ );if (!code) {throw new EngineTransportError('WhatsApp did not answer the group invite-code query');}@@ -321,7 +340,9 @@ export class BaileysGroups {async revokeGroupInviteCode(groupId: string): Promise<string> {this.host.ensureReady();- const code = await mapServerRefusal('Revoking the group invite code', () => this.sock().groupRevokeInvite(groupId));+ const code = await this.groupWrite(groupId, 'Revoking the group invite code', () =>+ this.sock().groupRevokeInvite(groupId),+ );if (!code) {throw new EngineTransportError('WhatsApp did not answer the group invite-code revocation');}@@ -404,7 +425,7 @@ export class BaileysGroups {async setGroupMessagesAdminsOnly(groupId: string, adminsOnly: boolean): Promise<void> {this.host.ensureReady();- await mapServerRefusal('Setting who may send messages', () =>+ await this.groupWrite(groupId, 'Setting who may send messages', () =>this.confirmed(this.sock().groupSettingUpdate(groupId, adminsOnly ? 'announcement' : 'not_announcement'),'the who-may-send change',@@ -414,7 +435,7 @@ export class BaileysGroups {async setGroupInfoAdminsOnly(groupId: string, adminsOnly: boolean): Promise<void> {this.host.ensureReady();- await mapServerRefusal('Setting who may edit group info', () =>+ await this.groupWrite(groupId, 'Setting who may edit group info', () =>this.confirmed(this.sock().groupSettingUpdate(groupId, adminsOnly ? 'locked' : 'unlocked'),'the who-may-edit change',@@ -426,6 +447,8 @@ export class BaileysGroups {this.host.ensureReady();// Same socket call as the own-account picture, addressed at the group JID.const { data } = await resolveMediaBuffer(media, this.host.sessionProxyUrl());+ // Not groupWrite: the w:profile:picture IQ goes to the server with the group as `target`, so a+ // 404 there is not known to mean the group is gone (on a removal it may mean "no picture").await mapServerRefusal('Setting the group picture', () =>this.confirmed(this.sock().updateProfilePicture(groupId, data), 'the group picture change'),);@@ -441,7 +464,7 @@ export class BaileysGroups {async setGroupMemberAddMode(groupId: string, mode: GroupMemberAddMode): Promise<void> {this.host.ensureReady();// A dedicated socket call, not a groupSettingUpdate option.- await mapServerRefusal('Setting the member-add mode', () =>+ await this.groupWrite(groupId, 'Setting the member-add mode', () =>this.confirmed(this.sock().groupMemberAddMode(groupId, mode === 'admins' ? 'admin_add' : 'all_member_add'),'the member-add-mode change',@@ -451,14 +474,14 @@ export class BaileysGroups {async setGroupEphemeral(groupId: string, durationSec: number): Promise<void> {this.host.ensureReady();- await mapServerRefusal('Setting the disappearing-message timer', () =>+ await this.groupWrite(groupId, 'Setting the disappearing-message timer', () =>this.confirmed(this.sock().groupToggleEphemeral(groupId, durationSec), 'the disappearing-message timer change'),);}async getGroupMembershipRequests(groupId: string): Promise<GroupMembershipRequest[]> {this.host.ensureReady();- const raw = await mapServerRefusal('Listing the membership requests', () =>+ const raw = await this.groupWrite(groupId, 'Listing the membership requests', () =>withQueryDeadline(this.sock().groupRequestParticipantsList(groupId),this.queryBudgetMs,@@ -511,7 +534,7 @@ export class BaileysGroups {if (participants) {targets = this.toEngineParticipants(participants);} else {- const pending = await mapServerRefusal(`Listing the membership requests to ${action}`, () =>+ const pending = await this.groupWrite(groupId, `Listing the membership requests to ${action}`, () =>withQueryDeadline(this.sock().groupRequestParticipantsList(groupId),this.queryBudgetMs,@@ -523,7 +546,7 @@ export class BaileysGroups {return [];}}- const raw = await mapServerRefusal(`Membership-request ${action}`, () =>+ const raw = await this.groupWrite(groupId, `Membership-request ${action}`, () =>withQueryDeadline(this.sock().groupRequestParticipantsUpdate(groupId, targets, action),this.queryBudgetMs,diff --git a/src/engine/adapters/baileys-refused-status.spec.ts b/src/engine/adapters/baileys-refused-status.spec.tsindex d4e7e97f0..f50677169 100644--- a/src/engine/adapters/baileys-refused-status.spec.ts+++ b/src/engine/adapters/baileys-refused-status.spec.ts@@ -54,6 +54,18 @@ describe('mapServerRefusal', () => {);});+ it('maps 404 to the not-found error when the caller supplies one, and only 404', async () => {+ const notFound = () => new Error('no such group');+ const reject = (code: number) => () => Promise.reject(new Boom('refused', { data: code }));+ await expect(mapServerRefusal('Leaving the group', reject(404), undefined, notFound)).rejects.toThrow(+ 'no such group',+ );+ await expect(mapServerRefusal('Leaving the group', reject(403), undefined, notFound)).rejects.toBeInstanceOf(+ EngineRefusedError,+ );+ await expect(mapServerRefusal('Leaving the group', reject(404))).rejects.toBeInstanceOf(EngineRefusedError);+ });+it('lets an unanswered query through untouched', async () => {const noAnswer = new Boom('Invalid group metadata response: missing <group> node', { data: undefined });await expect(mapServerRefusal('Setting the group subject', () => Promise.reject(noAnswer))).rejects.toBe(noAnswer);diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.tsindex 57ad5d364..2871f3f7b 100644--- a/src/engine/adapters/baileys.adapter.spec.ts+++ b/src/engine/adapters/baileys.adapter.spec.ts@@ -4359,8 +4359,7 @@ describe('BaileysAdapter group management', () => {// non-admin with an error node, which reached the caller as a bare 500.['getGroupInviteCode', (a: BaileysAdapter) => a.getGroupInviteCode('[email protected]'), 'groupInviteCode'],['revokeGroupInviteCode', (a: BaileysAdapter) => a.revokeGroupInviteCode('[email protected]'), 'groupRevokeInvite'],- // Was the one group write with no refusal mapping: an unknown or already-left group answered- // an opaque 500 while whatsapp-web.js resolves the chat first and answers 404.+ // Was the one group write with no refusal mapping: a refused leave answered an opaque 500.['leaveGroup', (a: BaileysAdapter) => a.leaveGroup('[email protected]'), 'groupLeave'],])('%s maps an admin-refused operation to EngineRefusedError (403)', async (_name, call, sockMethod) => {(fakeSock as unknown as Record<string, jest.Mock>)[sockMethod].mockRejectedValueOnce(@@ -4370,6 +4369,53 @@ describe('BaileysAdapter group management', () => {await expect(call(adapter)).rejects.toBeInstanceOf(EngineRefusedError);});+ // WhatsApp's item-not-found on a request addressed to the group means the group is gone: the read+ // path already answers 404 for it, and whatsapp-web.js answers 404 for an unknown group id.+ it.each([+ ['setGroupSubject', (a: BaileysAdapter) => a.setGroupSubject('[email protected]', 'X'), 'groupUpdateSubject'],+ [+ 'setGroupDescription',+ (a: BaileysAdapter) => a.setGroupDescription('[email protected]', 'X'),+ 'groupUpdateDescription',+ ],+ [+ 'setGroupMessagesAdminsOnly',+ (a: BaileysAdapter) => a.setGroupMessagesAdminsOnly('[email protected]', true),+ 'groupSettingUpdate',+ ],+ [+ 'setGroupInfoAdminsOnly',+ (a: BaileysAdapter) => a.setGroupInfoAdminsOnly('[email protected]', true),+ 'groupSettingUpdate',+ ],+ [+ 'setGroupMemberAddMode',+ (a: BaileysAdapter) => a.setGroupMemberAddMode('[email protected]', 'admins'),+ 'groupMemberAddMode',+ ],+ ['setGroupEphemeral', (a: BaileysAdapter) => a.setGroupEphemeral('[email protected]', 86400), 'groupToggleEphemeral'],+ ['getGroupInviteCode', (a: BaileysAdapter) => a.getGroupInviteCode('[email protected]'), 'groupInviteCode'],+ ['revokeGroupInviteCode', (a: BaileysAdapter) => a.revokeGroupInviteCode('[email protected]'), 'groupRevokeInvite'],+ ['leaveGroup', (a: BaileysAdapter) => a.leaveGroup('[email protected]'), 'groupLeave'],+ [+ 'addParticipants',+ (a: BaileysAdapter) => a.addParticipants('[email protected]', ['[email protected]']),+ 'groupParticipantsUpdate',+ ],+ ])('%s maps an unknown group to GroupNotFoundError (404)', async (_name, call, sockMethod) => {+ (fakeSock as unknown as Record<string, jest.Mock>)[sockMethod].mockRejectedValueOnce(+ Object.assign(new Error('item-not-found'), { data: 404 }),+ );+ const adapter = await ready();+ await expect(call(adapter)).rejects.toBeInstanceOf(GroupNotFoundError);+ });++ it('deleteGroupPicture keeps a 404 as a refusal: that IQ is not addressed to the group', async () => {+ fakeSock.removeProfilePicture.mockRejectedValueOnce(Object.assign(new Error('item-not-found'), { data: 404 }));+ const adapter = await ready();+ await expect(adapter.deleteGroupPicture('[email protected]')).rejects.toBeInstanceOf(EngineRefusedError);+ });+// The channel writes map WhatsApp's refusal; these two did not, so unfollowing a channel the// account no longer follows answered 500 where whatsapp-web.js answers the documented 403.it.each([diff --git a/src/engine/adapters/membership-requests.spec.ts b/src/engine/adapters/membership-requests.spec.tsindex 994e638eb..586293123 100644--- a/src/engine/adapters/membership-requests.spec.ts+++ b/src/engine/adapters/membership-requests.spec.ts@@ -237,6 +237,21 @@ function makeBaileysGroups(): { groups: BaileysGroups; sock: BaileysSockStub } {}describe('BaileysGroups membership requests', () => {+ it.each([+ ['listing', (g: BaileysGroups) => g.getGroupMembershipRequests('[email protected]')],+ ['acting on every pending request', (g: BaileysGroups) => g.approveGroupMembershipRequests('[email protected]')],+ [+ 'acting on named requesters',+ (g: BaileysGroups) => g.rejectGroupMembershipRequests('[email protected]', ['[email protected]']),+ ],+ ])('answers GroupNotFoundError when WhatsApp reports the group gone (404) while %s', async (_n, call) => {+ const { groups, sock } = makeBaileysGroups();+ const gone = Object.assign(new Error('item-not-found'), { data: 404 });+ sock.groupRequestParticipantsList.mockRejectedValue(gone);+ sock.groupRequestParticipantsUpdate.mockRejectedValue(gone);+ await expect(call(groups)).rejects.toBeInstanceOf(GroupNotFoundError);+ });+it('lists membership requests, neutralising jids and parsing the stringly wire attrs', async () => {const { groups, sock } = makeBaileysGroups();sock.groupRequestParticipantsList.mockResolvedValue([diff --git a/src/modules/channel/channel.controller.ts b/src/modules/channel/channel.controller.tsindex e1478353d..20fb5e0ff 100644--- a/src/modules/channel/channel.controller.ts+++ b/src/modules/channel/channel.controller.ts@@ -272,6 +272,7 @@ export class ChannelController {})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 404, description: CHANNEL_INVITE_NOT_FOUND_404 })+ @ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })async subscribe(@Param('sessionId') sessionId: string, @Body() body: SubscribeChannelDto) {return this.channelService.subscribeToChannel(sessionId, body.inviteCode);}diff --git a/src/modules/group/group.controller.ts b/src/modules/group/group.controller.tsindex 3766a6c54..01c3a7c5a 100644--- a/src/modules/group/group.controller.ts+++ b/src/modules/group/group.controller.ts@@ -202,6 +202,7 @@ export class GroupController {@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })@ApiResponse({ status: 400, description: PARTICIPANT_ID_400 })@HttpCode(HttpStatus.OK)+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async addParticipants(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -227,6 +228,7 @@ export class GroupController {@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })@ApiResponse({ status: 400, description: PARTICIPANT_ID_400 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async removeParticipants(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -253,6 +255,7 @@ export class GroupController {@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })@HttpCode(HttpStatus.OK)@ApiResponse({ status: 400, description: PARTICIPANT_ID_400 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async promoteParticipants(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -279,6 +282,7 @@ export class GroupController {@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })@HttpCode(HttpStatus.OK)@ApiResponse({ status: 400, description: PARTICIPANT_ID_400 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async demoteParticipants(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -302,6 +306,7 @@ export class GroupController {@ApiResponse({ status: 503, description: 'WhatsApp did not answer within the request budget — retry shortly' })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async getMembershipRequests(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {return this.groupService.getGroupMembershipRequests(sessionId, groupId);}@@ -329,6 +334,7 @@ export class GroupController {@ApiResponse({ status: 503, description: PARTICIPANTS_503 })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async approveMembershipRequests(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -361,6 +367,7 @@ export class GroupController {@ApiResponse({ status: 503, description: PARTICIPANTS_503 })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })@ApiResponse({ status: 403, description: ENGINE_REFUSED_403 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async rejectMembershipRequests(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -385,6 +392,7 @@ export class GroupController {'the gateway stopped waiting for a confirmation that never came.',})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async setSubject(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -409,6 +417,7 @@ export class GroupController {'the gateway stopped waiting for a confirmation that never came.',})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async setDescription(@Param('sessionId') sessionId: string,@Param('groupId') groupId: string,@@ -432,6 +441,7 @@ export class GroupController {'the gateway stopped waiting for a confirmation that never came.',})@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async leave(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {await this.groupService.leaveGroup(sessionId, groupId);return { success: true, message: 'Left the group' };@@ -521,6 +531,7 @@ export class GroupController {@ApiResponse({ status: 403, description: INVITE_CODE_403 })@ApiResponse({ status: 503, description: INVITE_CODE_503 })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async getInviteCode(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {const inviteCode = await this.groupService.getGroupInviteCode(sessionId, groupId);return {@@ -539,6 +550,7 @@ export class GroupController {@ApiResponse({ status: 403, description: INVITE_CODE_403 })@ApiResponse({ status: 503, description: INVITE_CODE_503 })@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })+ @ApiResponse({ status: 404, description: GROUP_NOT_FOUND_404 })async revokeInviteCode(@Param('sessionId') sessionId: string, @Param('groupId') groupId: string) {const newCode = await this.groupService.revokeGroupInviteCode(sessionId, groupId);return {