|
|
|
@ -160,20 +160,18 @@ export const sentMsgTypeMapped = {
|
|
|
|
|
msgcontent: {
|
|
|
|
|
...msg.template,
|
|
|
|
|
components: [
|
|
|
|
|
...msg.template.components.filter((com) => !['footer', 'buttons', 'header'].includes(com.type.toLowerCase())),
|
|
|
|
|
...(msg.template.components.filter((com) => 'header' === com.type.toLowerCase()).length > 0
|
|
|
|
|
? msg.template.components
|
|
|
|
|
.filter((com) => 'header' === com.type.toLowerCase())
|
|
|
|
|
.map((ele) => ({ type: 'header', parameters: [{ text: ele.text, type: ele.format.toLowerCase(), [ele.format.toLowerCase()]: { link: ele.example.header_url[0] } }] }))
|
|
|
|
|
: []),
|
|
|
|
|
...msg.template.components.filter((com) => !['footer', 'buttons'].includes(com.type.toLowerCase())),
|
|
|
|
|
...(msg.template.components.filter((com) => 'buttons' === com.type.toLowerCase()).length > 0
|
|
|
|
|
? msg.template.components
|
|
|
|
|
.filter((com) => 'buttons' === com.type.toLowerCase())[0]
|
|
|
|
|
// .buttons.filter((btns) => ! ['phone_number', 'url'].includes( btns.type.toLowerCase()))
|
|
|
|
|
.buttons.filter((btns) => ! isEmpty(btns.example)) // 静态按钮不发
|
|
|
|
|
.map((btn, btnI) => ({ type: 'button', sub_type: btn.type.toLowerCase(), index: btnI,
|
|
|
|
|
// parameters: [{ text: 'lq1FTtA8', type: 'text' }]
|
|
|
|
|
}))
|
|
|
|
|
.buttons.filter((btns) => !isEmpty(btns.example)) // 静态按钮不发
|
|
|
|
|
.map((btn, btnI) => ({
|
|
|
|
|
type: 'button',
|
|
|
|
|
sub_type: btn.type.toLowerCase(),
|
|
|
|
|
index: btnI,
|
|
|
|
|
// parameters: [{ text: 'lq1FTtA8', type: 'text' }]
|
|
|
|
|
}))
|
|
|
|
|
: []),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
@ -188,20 +186,18 @@ export const sentMsgTypeMapped = {
|
|
|
|
|
template: {
|
|
|
|
|
...msg.template,
|
|
|
|
|
components: [
|
|
|
|
|
...msg.template.components.filter((com) => !['footer', 'buttons', 'header'].includes(com.type.toLowerCase())),
|
|
|
|
|
...(msg.template.components.filter((com) => 'header' === com.type.toLowerCase()).length > 0
|
|
|
|
|
? msg.template.components
|
|
|
|
|
.filter((com) => 'header' === com.type.toLowerCase())
|
|
|
|
|
.map((ele) => ({ type: 'header', parameters: [{ text: ele.text, type: ele.format.toLowerCase(), [ele.format.toLowerCase()]: { link: ele.example.header_url[0] } }] }))
|
|
|
|
|
: []),
|
|
|
|
|
...msg.template.components.filter((com) => !['footer', 'buttons'].includes(com.type.toLowerCase())),
|
|
|
|
|
...(msg.template.components.filter((com) => 'buttons' === com.type.toLowerCase()).length > 0
|
|
|
|
|
? msg.template.components
|
|
|
|
|
.filter((com) => 'buttons' === com.type.toLowerCase())[0]
|
|
|
|
|
// .buttons.filter((btns) => ! ['phone_number', 'url'].includes( btns.type.toLowerCase()))
|
|
|
|
|
.buttons.filter((btns) => ! isEmpty(btns.example)) // 静态按钮不发
|
|
|
|
|
.map((btn, btnI) => ({ type: 'button', sub_type: btn.type.toLowerCase(), index: btnI,
|
|
|
|
|
// parameters: [{ text: 'lq1FTtA8', type: 'text' }]
|
|
|
|
|
}))
|
|
|
|
|
.buttons.filter((btns) => !isEmpty(btns.example)) // 静态按钮不发
|
|
|
|
|
.map((btn, btnI) => ({
|
|
|
|
|
type: 'button',
|
|
|
|
|
sub_type: btn.type.toLowerCase(),
|
|
|
|
|
index: btnI,
|
|
|
|
|
// parameters: [{ text: 'lq1FTtA8', type: 'text' }]
|
|
|
|
|
}))
|
|
|
|
|
: []),
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|