Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop

This commit is contained in:
Davidson Gomes 2023-07-24 20:12:51 -03:00
commit 757a578c6e
3 changed files with 23 additions and 4 deletions

View File

@ -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,

View File

@ -1,7 +1,8 @@
export class CreateGroupDto {
subject: string;
description?: string;
participants: string[];
description?: string;
promoteParticipants?: boolean;
}
export class GroupPictureDto {

View File

@ -1517,14 +1517,22 @@ export class WAStartupService {
.split(/\:/)[0]
.split('@')[0];
// 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`;
}
number = number.replace(/\D/g, '');
this.logger.verbose('Jid created is whatsapp: ' + `${number}@s.whatsapp.net`);
return `${number}@s.whatsapp.net`;
}
@ -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());