mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 02:57:34 +00:00
feat(twilio): add support to have multiple numbers (#1450)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -17,17 +17,24 @@ export function sendTwilioMessage(link: Link, store: Store) {
|
|||||||
(async () => {
|
(async () => {
|
||||||
const givenUrl = link.cartUrl ? link.cartUrl : link.url;
|
const givenUrl = link.cartUrl ? link.cartUrl : link.url;
|
||||||
const message = `${Print.inStock(link, store)}\n${givenUrl}`;
|
const message = `${Print.inStock(link, store)}\n${givenUrl}`;
|
||||||
|
const numbers = twilio.to.split(',');
|
||||||
|
const results = [];
|
||||||
|
for (const number of numbers) {
|
||||||
try {
|
try {
|
||||||
await client.messages.create({
|
results.push(
|
||||||
|
client.messages.create({
|
||||||
body: message,
|
body: message,
|
||||||
from: twilio.from,
|
from: twilio.from,
|
||||||
to: twilio.to
|
to: number
|
||||||
});
|
})
|
||||||
|
);
|
||||||
logger.info('✔ twilio message sent');
|
logger.info('✔ twilio message sent');
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error("✖ couldn't send twilio message", error);
|
logger.error("✖ couldn't send twilio message", error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(results);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user