-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwilio.js
More file actions
39 lines (30 loc) · 851 Bytes
/
twilio.js
File metadata and controls
39 lines (30 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const re = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g
module.exports = function(io, db) {
var twilio = {};
twilio.POSTtext = function(req, res, _next) {
var startDate = new Date();
var endDate = new Date().setDate(startDate.getDate() + 7);
var data, flavor;
if (Number(req.body.NumMedia) > 0) {
data = { "Link": req.body['MediaUrl0'] };
flavor = "Image";
} else if (req.body['Body'].match(re)) {
data = { "Link": req.body['Body'] };
flavor = "Image";
} else {
data = { "Text": req.body['Body'] };
flavor = "Text";
}
var bob = {
data: data,
flavor: flavor,
startDate: startDate,
endDate: endDate,
tags: ["potluck"]
}
io.emit('add_element', bob);
db.Bob.saveBob(bob);
res.send('success');
};
return twilio;
};