Skip to content

Commit

Permalink
fix: Promote All Participants in Create Group
Browse files Browse the repository at this point in the history
Promote All Participants in Create Group
  • Loading branch information
DavidsonGomes authored Jul 24, 2023
2 parents 3d8e6f4 + ef4be6a commit 036a8ed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/validate/validate.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ export const createGroupSchema: JSONSchema7 = {
subject: { type: 'string' },
description: { type: 'string' },
profilePicture: { type: 'string' },
promoteParticipants: { type: 'boolean', enum: [true, false] },
participants: {
type: 'array',
minItems: 1,
Expand Down
3 changes: 2 additions & 1 deletion src/whatsapp/dto/group.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export class CreateGroupDto {
subject: string;
description?: string;
participants: string[];
description?: string;
promoteParticipants?: boolean;
}

export class GroupPictureDto {
Expand Down
11 changes: 10 additions & 1 deletion src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2774,11 +2774,20 @@ export class WAStartupService {
this.logger.verbose('Updating group description: ' + create.description);
await this.client.groupUpdateDescription(id, create.description);
}

if (create?.promoteParticipants) {
this.logger.verbose('Prometing group participants: ' + create.description);
await this.updateGParticipant({
groupJid: id,
action: "promote",
participants: participants
});
}

const group = await this.client.groupMetadata(id);
this.logger.verbose('Getting group metadata');

return { groupMetadata: group };
return group;
} catch (error) {
this.logger.error(error);
throw new InternalServerErrorException('Error creating group', error.toString());
Expand Down

0 comments on commit 036a8ed

Please sign in to comment.