Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
DavidsonGomes committed Jul 24, 2023
2 parents c582476 + f8e1892 commit 757a578
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 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
23 changes: 20 additions & 3 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1517,14 +1517,22 @@ export class WAStartupService {
.split(/\:/)[0]
.split('@')[0];

if (number.length >= 18) {
// Verificação de Grupos Antigos
if(number.includes('-') && number.length >= 24){
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
number = number.replace(/[^\d-]/g, '');
return `${number}@g.us`;
}

number = number.replace(/\D/g, '');

// Verificação de Grupos Novos
if (number.length >= 18) {
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
number = number.replace(/[^\d-]/g, '');
return `${number}@g.us`;
}

this.logger.verbose('Jid created is whatsapp: ' + `${number}@s.whatsapp.net`);
return `${number}@s.whatsapp.net`;
}
Expand Down Expand Up @@ -2774,11 +2782,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 757a578

Please sign in to comment.