Skip to content

Commit ae07cf0

Browse files
committed
feat: send Button Message
1 parent d4dd734 commit ae07cf0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ import makeWASocket, {
114114
} from 'baileys';
115115
import { Label } from 'baileys/lib/Types/Label';
116116
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
117-
import { isBase64, isURL } from 'class-validator';
117+
import { isArray, isBase64, isURL } from 'class-validator';
118118
import { randomBytes } from 'crypto';
119119
import EventEmitter2 from 'eventemitter2';
120120
import { readFileSync } from 'fs';
@@ -1472,6 +1472,32 @@ export class BaileysStartupService extends ChannelStartupService {
14721472
if (messageId) option.messageId = messageId;
14731473
else option.messageId = '3EB0' + randomBytes(18).toString('hex').toUpperCase();
14741474

1475+
if (message['viewOnceMessage']) {
1476+
const m = generateWAMessageFromContent(sender, message, {
1477+
timestamp: new Date(),
1478+
userJid: this.instance.wuid,
1479+
messageId,
1480+
quoted,
1481+
});
1482+
1483+
const id = await this.client.relayMessage(sender, message, { messageId });
1484+
1485+
m.key = {
1486+
id: id,
1487+
remoteJid: sender,
1488+
participant: isJidUser(sender) ? sender : undefined,
1489+
fromMe: true,
1490+
};
1491+
1492+
for (const [key, value] of Object.entries(m)) {
1493+
if (!value || (isArray(value) && value.length) === 0) {
1494+
delete m[key];
1495+
}
1496+
}
1497+
1498+
return m;
1499+
}
1500+
14751501
if (
14761502
!message['audio'] &&
14771503
!message['poll'] &&

src/api/routes/sendMessage.router.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export class MessageRouter extends RouterBroker {
159159
return res.status(HttpStatus.CREATED).json(response);
160160
})
161161
.post(this.routerPath('sendButtons'), ...guards, async (req, res) => {
162-
console.log('Corpo da requisição recebido:', JSON.stringify(req.body, null, 2));
163162
try {
164163
const response = await this.dataValidate<SendButtonsDto>({
165164
request: req,

0 commit comments

Comments
 (0)