diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2024-03-07 22:31:06 +0000 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2024-03-07 22:31:06 +0000 |
| commit | d2afcc667672145c784cfa9cd503ef881dea34f5 (patch) | |
| tree | cee506f25c0407337e8a88330bec5e12988a7ee0 /src/app.js | |
| parent | 426c77554bdb2bf06b97ba49d15407150b4f4bf9 (diff) | |
sends text messages
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -20,7 +20,7 @@ app.post('/sms', (req, res) => { console.debug(` Received a text from ${senderCountry} on number ${senderPhoneNumber}. Message content: ${body}. End of message - `.replace(/ +/g, ' ')); + `.replace(/\s+/g, ' ')); if (isSubscribed(senderPhoneNumber)) { const senderSubscription = getSubscriptionFromNumber(senderPhoneNumber); @@ -30,11 +30,11 @@ app.post('/sms', (req, res) => { const forwardedMessage = `${senderSubscription.name} said: ${body}`; sendTextMessage(otherSubscriptions, forwardedMessage); - const abbreviatedBody = body.length > 10 ? `${body.slice(0, 8)}...` : body; + const abbreviatedBody = body.length > 16 ? `${body.slice(0, 14)}...` : body; const confirmationMessage = ` Your message was forwarded to ${otherSubscriptions.length} recipients: "${abbreviatedBody}". Only you can see this message. - `.replace(/ +/g, ' '); + `.replace(/\s+/g, ' '); sendTextMessage([senderSubscription], confirmationMessage); } else { if (body.toLocaleLowerCase().startsWith('my name is ') || body.toLocaleLowerCase().startsWith('my name is: ')) { @@ -52,14 +52,14 @@ app.post('/sms', (req, res) => { Well done, ${senderName}! You have successfully subscribed to the Glen Coe meet texting group. You will now be able to send and receive messages to and from the group. - `.replace(/ +/g, ' '); + `.replace(/\s+/g, ' '); sendTextMessage([subscription], welcomeMessage); } else { const twiml = new MessagingResponse(); twiml.message(` You are not subscribed to this texting group. To subscribe, send a text to this number with this syntax: my name is <your name> - `.replace(/ +/g, ' ')); + `.replace(/\s+/g, ' ')); res.type('text/xml').send(twiml.toString()); return; } |
