fix(all): TRUE multicloud.
This commit is contained in:
parent
babde3fa6c
commit
d3f6ce2799
1 changed files with 16 additions and 20 deletions
|
@ -808,29 +808,25 @@ export class WhatsappDirectLine extends GBService {
|
||||||
const templateExists = templates.data.find(template => template.name === name);
|
const templateExists = templates.data.find(template => template.name === name);
|
||||||
|
|
||||||
if (templateExists) {
|
if (templateExists) {
|
||||||
// Step 2: Update the template
|
// // Step 2: Update the template
|
||||||
const updateTemplateEndpoint = `${baseUrl}/${templateExists.id}`;
|
// const updateTemplateEndpoint = `${baseUrl}/${templateExists.id}`;
|
||||||
|
|
||||||
// Removes the first HEADER element.
|
// const updateResponse = await fetch(updateTemplateEndpoint, {
|
||||||
|
// method: 'POST',
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `Bearer ${accessToken}`,
|
||||||
|
// 'Content-Type': 'application/json'
|
||||||
|
// },
|
||||||
|
// body: JSON.stringify({
|
||||||
|
// components: data.components
|
||||||
|
// })
|
||||||
|
// });
|
||||||
|
|
||||||
data.components.shift();
|
// if (!updateResponse.ok) {
|
||||||
|
// throw new Error(`Failed to update template: ${name} ${await updateResponse.text()}`);
|
||||||
|
// }
|
||||||
|
|
||||||
const updateResponse = await fetch(updateTemplateEndpoint, {
|
GBLogEx.info(min, `Template update skiped: ${name}`);
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${accessToken}`,
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
components: data.components
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!updateResponse.ok) {
|
|
||||||
throw new Error(`Failed to update template: ${name} ${await updateResponse.text()}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
GBLogEx.info(min, `Template updated: ${name}`);
|
|
||||||
} else {
|
} else {
|
||||||
// Step 3: Create the template
|
// Step 3: Create the template
|
||||||
const createTemplateEndpoint = `${baseUrl}/${businessAccountId}/message_templates`;
|
const createTemplateEndpoint = `${baseUrl}/${businessAccountId}/message_templates`;
|
||||||
|
|
Loading…
Add table
Reference in a new issue