Add caching CNAM
This commit is contained in:
parent
988bbb71e6
commit
e3d4007f31
7
index.js
7
index.js
|
@ -13,9 +13,14 @@ const fs = require('fs');
|
|||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
cnamCache = {};
|
||||
|
||||
app.post('/sms', async (req, res) => {
|
||||
data = req.body;
|
||||
// Get the CNAM record for the number
|
||||
if (cnamCache[data.From]) {
|
||||
cnam = cnamCache[data.From];
|
||||
} else {
|
||||
cnam = data.From;
|
||||
await axios.get(`https://cnam.bulkvs.com/?id=${config.bulkvs.id}&did=${data.From}&format=json`, {
|
||||
headers: {
|
||||
|
@ -27,6 +32,8 @@ app.post('/sms', async (req, res) => {
|
|||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
cnamCache[data.From] = cnam;
|
||||
}
|
||||
if (data.MediaURLs) { // It's an MMS
|
||||
out = {
|
||||
"text": "",
|
||||
|
|
Loading…
Reference in a new issue