Skip to content

Commit 5759341

Browse files
committed
feat: accept invite code
1 parent ea9ba27 commit 5759341

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Route to update the privacy settings
1010
* Route to update group subject
1111
* Route to update group description
12+
* Route to accept invite code
1213

1314
### Fixed
1415

src/whatsapp/controllers/group.controller.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ export class GroupController {
5656
return await this.waMonitor.waInstances[instance.instanceName].inviteInfo(inviteCode);
5757
}
5858

59+
public async acceptInvite(instance: InstanceDto, inviteCode: GroupInvite) {
60+
return await this.waMonitor.waInstances[instance.instanceName].acceptInvite(
61+
inviteCode,
62+
);
63+
}
64+
5965
public async revokeInviteCode(instance: InstanceDto, groupJid: GroupJid) {
6066
return await this.waMonitor.waInstances[instance.instanceName].revokeInviteCode(
6167
groupJid,

src/whatsapp/routers/group.router.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ export class GroupRouter extends RouterBroker {
120120

121121
res.status(HttpStatus.OK).json(response);
122122
})
123+
.get(this.routerPath('acceptInvite'), ...guards, async (req, res) => {
124+
const response = await this.inviteCodeValidate<GroupInvite>({
125+
request: req,
126+
schema: groupInviteSchema,
127+
ClassRef: GroupInvite,
128+
execute: (instance, data) => groupController.acceptInvite(instance, data),
129+
});
130+
131+
res.status(HttpStatus.OK).json(response);
132+
})
123133
.put(this.routerPath('revokeInviteCode'), ...guards, async (req, res) => {
124134
const response = await this.groupValidate<GroupJid>({
125135
request: req,

src/whatsapp/services/whatsapp.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,14 @@ export class WAStartupService {
17021702
}
17031703
}
17041704

1705+
public async acceptInvite(id: GroupInvite) {
1706+
try {
1707+
return await this.client.groupAcceptInvite(id.inviteCode);
1708+
} catch (error) {
1709+
throw new NotFoundException('No invite info', id.inviteCode);
1710+
}
1711+
}
1712+
17051713
public async revokeInviteCode(id: GroupJid) {
17061714
try {
17071715
const inviteCode = await this.client.groupRevokeInvite(id.groupJid);

0 commit comments

Comments
 (0)