mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
feat: accept invite code
This commit is contained in:
parent
ea9ba27f22
commit
5759341c52
@ -9,6 +9,7 @@
|
||||
* Route to update the privacy settings
|
||||
* Route to update group subject
|
||||
* Route to update group description
|
||||
* Route to accept invite code
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -56,6 +56,12 @@ export class GroupController {
|
||||
return await this.waMonitor.waInstances[instance.instanceName].inviteInfo(inviteCode);
|
||||
}
|
||||
|
||||
public async acceptInvite(instance: InstanceDto, inviteCode: GroupInvite) {
|
||||
return await this.waMonitor.waInstances[instance.instanceName].acceptInvite(
|
||||
inviteCode,
|
||||
);
|
||||
}
|
||||
|
||||
public async revokeInviteCode(instance: InstanceDto, groupJid: GroupJid) {
|
||||
return await this.waMonitor.waInstances[instance.instanceName].revokeInviteCode(
|
||||
groupJid,
|
||||
|
@ -120,6 +120,16 @@ export class GroupRouter extends RouterBroker {
|
||||
|
||||
res.status(HttpStatus.OK).json(response);
|
||||
})
|
||||
.get(this.routerPath('acceptInvite'), ...guards, async (req, res) => {
|
||||
const response = await this.inviteCodeValidate<GroupInvite>({
|
||||
request: req,
|
||||
schema: groupInviteSchema,
|
||||
ClassRef: GroupInvite,
|
||||
execute: (instance, data) => groupController.acceptInvite(instance, data),
|
||||
});
|
||||
|
||||
res.status(HttpStatus.OK).json(response);
|
||||
})
|
||||
.put(this.routerPath('revokeInviteCode'), ...guards, async (req, res) => {
|
||||
const response = await this.groupValidate<GroupJid>({
|
||||
request: req,
|
||||
|
@ -1702,6 +1702,14 @@ export class WAStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
public async acceptInvite(id: GroupInvite) {
|
||||
try {
|
||||
return await this.client.groupAcceptInvite(id.inviteCode);
|
||||
} catch (error) {
|
||||
throw new NotFoundException('No invite info', id.inviteCode);
|
||||
}
|
||||
}
|
||||
|
||||
public async revokeInviteCode(id: GroupJid) {
|
||||
try {
|
||||
const inviteCode = await this.client.groupRevokeInvite(id.groupJid);
|
||||
|
Loading…
Reference in New Issue
Block a user