mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 01:47:39 +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 () => {
|
||||
const givenUrl = link.cartUrl ? link.cartUrl : link.url;
|
||||
const message = `${Print.inStock(link, store)}\n${givenUrl}`;
|
||||
|
||||
const numbers = twilio.to.split(',');
|
||||
const results = [];
|
||||
for (const number of numbers) {
|
||||
try {
|
||||
await client.messages.create({
|
||||
results.push(
|
||||
client.messages.create({
|
||||
body: message,
|
||||
from: twilio.from,
|
||||
to: twilio.to
|
||||
});
|
||||
to: number
|
||||
})
|
||||
);
|
||||
logger.info('✔ twilio message sent');
|
||||
} catch (error: unknown) {
|
||||
logger.error("✖ couldn't send twilio message", error);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(results);
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user