Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/api/dto/sendMessage.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class Options {
mentionsEveryOne?: boolean;
mentioned?: string[];
webhookUrl?: string;
messageId?: string;
}

export class MediaMessage {
Expand Down Expand Up @@ -45,6 +46,7 @@ export class Metadata {
mentioned?: string[];
encoding?: boolean;
notConvertSticker?: boolean;
messageId?: string;
}

export class SendTextDto extends Metadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class EvolutionStartupService extends ChannelStartupService {

let audioFile;

const messageId = v4();
const messageId = options?.messageId ?? v4();

let messageRaw: any;

Expand Down Expand Up @@ -548,6 +548,7 @@ export class EvolutionStartupService extends ChannelStartupService {
linkPreview: data?.linkPreview,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
null,
isIntegration,
Expand Down Expand Up @@ -613,6 +614,7 @@ export class EvolutionStartupService extends ChannelStartupService {
linkPreview: data?.linkPreview,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
file,
isIntegration,
Expand Down Expand Up @@ -711,6 +713,7 @@ export class EvolutionStartupService extends ChannelStartupService {
linkPreview: data?.linkPreview,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
file,
isIntegration,
Expand All @@ -736,6 +739,7 @@ export class EvolutionStartupService extends ChannelStartupService {
quoted: data?.quoted,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
null,
isIntegration,
Expand Down
6 changes: 6 additions & 0 deletions src/api/integrations/channel/whatsapp/baileys.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export class BaileysController {
return instance.baileysOnWhatsapp(body?.jid);
}

public async generateMessageID({ instanceName }: InstanceDto) {
const instance = this.waMonitor.waInstances[instanceName];

return instance.generateMessageID();
}

public async profilePictureUrl({ instanceName }: InstanceDto, body: any) {
const instance = this.waMonitor.waInstances[instanceName];

Expand Down
10 changes: 10 additions & 0 deletions src/api/integrations/channel/whatsapp/baileys.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ export class BaileysRouter extends RouterBroker {

res.status(HttpStatus.OK).json(response);
})
.get(this.routerPath('generateMessageID'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({
request: req,
schema: instanceSchema,
ClassRef: InstanceDto,
execute: (instance) => baileysController.generateMessageID(instance),
});

res.status(HttpStatus.OK).json(response);
})
.post(this.routerPath('profilePictureUrl'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({
request: req,
Expand Down
16 changes: 14 additions & 2 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import makeWASocket, {
DisconnectReason,
downloadContentFromMessage,
downloadMediaMessage,
generateMessageIDV2,
generateWAMessageFromContent,
getAggregateVotesInPollMessage,
GetCatalogOptions,
Expand Down Expand Up @@ -1978,6 +1979,11 @@ export class BaileysStartupService extends ChannelStartupService {
return error;
}
}
public generateMessageID() {
return {
id: generateMessageIDV2(this.client.user?.id),
};
}

private async sendMessage(
sender: string,
Expand Down Expand Up @@ -2242,7 +2248,7 @@ export class BaileysStartupService extends ChannelStartupService {
mentions,
linkPreview,
quoted,
null,
options?.messageId ?? null,
group?.ephemeralDuration,
// group?.participants,
);
Expand All @@ -2264,7 +2270,7 @@ export class BaileysStartupService extends ChannelStartupService {
mentions,
linkPreview,
quoted,
null,
options?.messageId ?? null,
undefined,
contextInfo,
);
Expand Down Expand Up @@ -2490,6 +2496,7 @@ export class BaileysStartupService extends ChannelStartupService {
linkPreview: data?.linkPreview,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
isIntegration,
);
Expand All @@ -2506,6 +2513,7 @@ export class BaileysStartupService extends ChannelStartupService {
linkPreview: data?.linkPreview,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
);
}
Expand Down Expand Up @@ -2819,6 +2827,7 @@ export class BaileysStartupService extends ChannelStartupService {
quoted: data?.quoted,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
);

Expand All @@ -2841,6 +2850,7 @@ export class BaileysStartupService extends ChannelStartupService {
quoted: data?.quoted,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
isIntegration,
);
Expand All @@ -2857,6 +2867,7 @@ export class BaileysStartupService extends ChannelStartupService {
quoted: data?.quoted,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
};

if (file) mediaData.media = file.buffer.toString('base64');
Expand All @@ -2872,6 +2883,7 @@ export class BaileysStartupService extends ChannelStartupService {
quoted: data?.quoted,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
messageId: data?.messageId,
},
isIntegration,
);
Expand Down
Loading