Added MMS support for messaging. IO-538
This commit is contained in:
@@ -17,7 +17,13 @@ const client = twilio(
|
||||
const gqlClient = require("../graphql-client/graphql-client").client;
|
||||
|
||||
exports.send = (req, res) => {
|
||||
const { to, messagingServiceSid, body, conversationid } = req.body;
|
||||
const {
|
||||
to,
|
||||
messagingServiceSid,
|
||||
body,
|
||||
conversationid,
|
||||
selectedMedia,
|
||||
} = req.body;
|
||||
console.log("[Sending Sms] " + conversationid + " | " + body);
|
||||
if (!!to && !!messagingServiceSid && !!body && !!conversationid) {
|
||||
client.messages
|
||||
@@ -25,6 +31,7 @@ exports.send = (req, res) => {
|
||||
body: body,
|
||||
messagingServiceSid: messagingServiceSid,
|
||||
to: phone(to)[0],
|
||||
mediaUrl: selectedMedia.map((i) => i.src),
|
||||
})
|
||||
.then((message) => {
|
||||
let newMessage = {
|
||||
@@ -33,6 +40,11 @@ exports.send = (req, res) => {
|
||||
conversationid,
|
||||
isoutbound: true,
|
||||
userid: req.user.email,
|
||||
image: req.body.selectedMedia.length > 0,
|
||||
image_path:
|
||||
req.body.selectedMedia.length > 0
|
||||
? selectedMedia.map((i) => i.src)
|
||||
: [],
|
||||
};
|
||||
gqlClient
|
||||
.request(queries.INSERT_MESSAGE, { msg: newMessage })
|
||||
@@ -55,3 +67,23 @@ exports.send = (req, res) => {
|
||||
.json({ success: false, message: "Missing required parameter(s)." });
|
||||
}
|
||||
};
|
||||
|
||||
// //Image
|
||||
// acc.push({
|
||||
// src: `${process.env.REACT_APP_CLOUDINARY_ENDPOINT}/${DetermineFileType(
|
||||
// value.type
|
||||
// )}/upload/${value.key}`,
|
||||
// thumbnail: `${
|
||||
// process.env.REACT_APP_CLOUDINARY_ENDPOINT
|
||||
// }/${DetermineFileType(value.type)}/upload/${
|
||||
// process.env.REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS
|
||||
// }/${value.key}`,
|
||||
// thumbnailHeight: 225,
|
||||
// thumbnailWidth: 225,
|
||||
// isSelected: false,
|
||||
// key: value.key,
|
||||
// extension: value.extension,
|
||||
// id: value.id,
|
||||
// type: value.type,
|
||||
// tags: [{ value: value.type, title: value.type }],
|
||||
// });
|
||||
|
||||
Reference in New Issue
Block a user