Skip to content

Commit 7bcbc88

Browse files
committed
refactor: Simplificar estrutura de mensagens interativas no serviço Baileys
1 parent 2e4e4ed commit 7bcbc88

1 file changed

Lines changed: 39 additions & 43 deletions

File tree

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

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,20 +3095,18 @@ export class BaileysStartupService extends ChannelStartupService {
30953095
}
30963096

30973097
const message: proto.IMessage = {
3098-
message: {
3099-
interactiveMessage: {
3100-
nativeFlowMessage: {
3101-
buttons: [
3102-
{
3103-
name: this.mapType.get('pix'),
3104-
buttonParamsJson: this.toJSONString(data.buttons[0]),
3105-
},
3106-
],
3107-
messageParamsJson: JSON.stringify({
3108-
from: 'api',
3109-
templateId: v4(),
3110-
}),
3111-
},
3098+
interactiveMessage: {
3099+
nativeFlowMessage: {
3100+
buttons: [
3101+
{
3102+
name: this.mapType.get('pix'),
3103+
buttonParamsJson: this.toJSONString(data.buttons[0]),
3104+
},
3105+
],
3106+
messageParamsJson: JSON.stringify({
3107+
from: 'api',
3108+
templateId: v4(),
3109+
}),
31123110
},
31133111
},
31143112
};
@@ -3139,37 +3137,35 @@ export class BaileysStartupService extends ChannelStartupService {
31393137
});
31403138

31413139
const message: proto.IMessage = {
3142-
message: {
3143-
interactiveMessage: {
3144-
body: {
3145-
text: (() => {
3146-
let t = '*' + data.title + '*';
3147-
if (data?.description) {
3148-
t += '\n\n';
3149-
t += data.description;
3150-
t += '\n';
3151-
}
3152-
return t;
3153-
})(),
3154-
},
3155-
footer: {
3156-
text: data?.footer,
3157-
},
3158-
header: (() => {
3159-
if (generate?.message?.imageMessage) {
3160-
return {
3161-
hasMediaAttachment: !!generate.message.imageMessage,
3162-
imageMessage: generate.message.imageMessage,
3163-
};
3140+
interactiveMessage: {
3141+
body: {
3142+
text: (() => {
3143+
let t = '*' + data.title + '*';
3144+
if (data?.description) {
3145+
t += '\n\n';
3146+
t += data.description;
3147+
t += '\n';
31643148
}
3149+
return t;
31653150
})(),
3166-
nativeFlowMessage: {
3167-
buttons: buttons,
3168-
messageParamsJson: JSON.stringify({
3169-
from: 'api',
3170-
templateId: v4(),
3171-
}),
3172-
},
3151+
},
3152+
footer: {
3153+
text: data?.footer,
3154+
},
3155+
header: (() => {
3156+
if (generate?.message?.imageMessage) {
3157+
return {
3158+
hasMediaAttachment: !!generate.message.imageMessage,
3159+
imageMessage: generate.message.imageMessage,
3160+
};
3161+
}
3162+
})(),
3163+
nativeFlowMessage: {
3164+
buttons: buttons,
3165+
messageParamsJson: JSON.stringify({
3166+
from: 'api',
3167+
templateId: v4(),
3168+
}),
31733169
},
31743170
},
31753171
};

0 commit comments

Comments
 (0)