mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 19:19:24 -06:00
[Melhoria] Group Create
Verifica todos os participantes e pega apenas os que existe no WhatsApp
This commit is contained in:
parent
5bc33ac654
commit
d00e1df29c
@ -2969,7 +2969,9 @@ export class WAStartupService {
|
|||||||
public async createGroup(create: CreateGroupDto) {
|
public async createGroup(create: CreateGroupDto) {
|
||||||
this.logger.verbose('Creating group: ' + create.subject);
|
this.logger.verbose('Creating group: ' + create.subject);
|
||||||
try {
|
try {
|
||||||
const participants = create.participants.map((p) => this.createJid(p));
|
const participants = (await this.whatsappNumber({ numbers: create.participants }))
|
||||||
|
.filter((participant) => participant.exists)
|
||||||
|
.map((participant) => participant.jid);
|
||||||
const { id } = await this.client.groupCreate(create.subject, participants);
|
const { id } = await this.client.groupCreate(create.subject, participants);
|
||||||
this.logger.verbose('Group created: ' + id);
|
this.logger.verbose('Group created: ' + id);
|
||||||
|
|
||||||
@ -2979,7 +2981,7 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (create?.promoteParticipants) {
|
if (create?.promoteParticipants) {
|
||||||
this.logger.verbose('Prometing group participants: ' + create.description);
|
this.logger.verbose('Prometing group participants: ' + participants);
|
||||||
await this.updateGParticipant({
|
await this.updateGParticipant({
|
||||||
groupJid: id,
|
groupJid: id,
|
||||||
action: 'promote',
|
action: 'promote',
|
||||||
@ -2987,8 +2989,8 @@ export class WAStartupService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const group = await this.client.groupMetadata(id);
|
|
||||||
this.logger.verbose('Getting group metadata');
|
this.logger.verbose('Getting group metadata');
|
||||||
|
const group = await this.client.groupMetadata(id);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user