@harisenin/twilio
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@harisenin/twilio", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Twilio SDK for harisenincom", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -81,4 +81,3 @@ "use strict"; | ||
const Ws = use("Ws"); | ||
const Email = use("App/Libraries/SendEmail"); | ||
const ConstantVariable = use('App/Variables/ConstantsVariable') | ||
const EmailNotification = use("App/Libraries/EmailNotification"); | ||
@@ -248,2 +247,7 @@ | ||
const payload = request.post(); | ||
if(payload.user_ids.length > 1){ | ||
for (let i = 0; i < payload.user_ids.length; i++) { | ||
await Twilio.generateToken(user_ids[i]); | ||
} | ||
} | ||
let [userBuyer,userPartner] = await Promise.all([User.query() | ||
@@ -341,3 +345,3 @@ .with("user_profile") | ||
try { | ||
if (userPartner.toJSON().twilio_user) { | ||
if (userPartner.toJSON().twilio_user && userPartner.toJSON().twilio_user.sid != "") { | ||
newPromises.push(Twilio.updateUser(user[1].id, dataUser.partner)); | ||
@@ -347,3 +351,3 @@ } else { | ||
} | ||
if (userBuyer.toJSON().twilio_user) { | ||
if (userBuyer.toJSON().twilio_user && userBuyer.toJSON().twilio_user.sid != "") { | ||
newPromises.push(Twilio.updateUser(user[0].id, dataUser.buyer)); | ||
@@ -611,3 +615,2 @@ } else { | ||
await Promise.all(promises); | ||
const constantVariable = new ConstantVariable() | ||
const userReceiver = await User.query() | ||
@@ -622,13 +625,9 @@ .where("id", receiver[0].identity) | ||
file_name: r2.media.filename, | ||
}, | ||
url: process.env.BASE_URL, | ||
} | ||
}; | ||
// console.log(media) | ||
let view = "message.new_message_file"; | ||
const notif = new Email( | ||
`${userReceiver.toJSON().user_email}`, | ||
"Pesan Baru","bcc" | ||
); | ||
r2.direct_media_url = await media; | ||
await notif.sendEmail(view, mailData,constantVariable.bccToInfo()); | ||
const notificationEmail = new EmailNotification(); | ||
await notificationEmail.emailNotifChatMedia(`${userReceiver.toJSON().user_email}`,mailData); | ||
broadcast("onMessageSent", r2); | ||
@@ -635,0 +634,0 @@ return response.ok({ result: r2 }); |
const Ws = use("Ws"); | ||
const User = use("App/Models/User"); | ||
const Env = use("Env"); | ||
const Email = use("App/Libraries/SendEmail"); | ||
const EmailNotification = use("App/Libraries/EmailNotification"); | ||
const Twilio = use("Adonis/TwilioService"); | ||
const ConstantVariable = use('App/Variables/ConstantsVariable') | ||
@@ -41,34 +39,23 @@ const TwilioWebhook = { | ||
.first(); | ||
// const partner = await UserPartner.query() | ||
// .with("partner") | ||
// .where("user_id", user.id) | ||
// .first(); | ||
let mailData = {}; | ||
let view = ""; | ||
if (payload.Attributes === "{}") { | ||
//type text | ||
mailData.message = payload.Body; | ||
mailData.fullname = receiver[0].user.friendlyName; // penerima | ||
mailData.sender = sender[0].user.friendlyName; // pengirim | ||
mailData.url = Env.get("BASE_URL"); | ||
mailData.year = new Date().getFullYear(); | ||
view = "message.info_new_message"; | ||
} else { | ||
//type card | ||
mailData.fullname = receiver[0].user.friendlyName; | ||
mailData.sender = sender[0].user.friendlyName; | ||
mailData.payload = JSON.parse(payload.Attributes); | ||
mailData.url = Env.get("BASE_URL"); | ||
mailData.year = new Date().getFullYear(); | ||
// Env.get("BASE_URL") + | ||
// "/partner/" + | ||
// partner.toJSON().partner.partner_name + | ||
// "/chat?room_id=" + | ||
// d.room_id; | ||
view = "message.new_message_card"; | ||
} | ||
// const received_email = user | ||
const constantVariable = new ConstantVariable() | ||
const notif = new Email(`${user.toJSON().user_email}`, "Pesan Baru","bcc"); | ||
await notif.sendEmail(view, mailData,constantVariable.bccToInfo()); | ||
let payloadEmail = {}; | ||
const notificationEmail = new EmailNotification(); | ||
if (payload.Attributes === "{}") { | ||
console.log('send text msg'); | ||
//type text | ||
payloadEmail.Body = payload.Body; | ||
payloadEmail.receiver_name = receiver[0].user.friendlyName; | ||
payloadEmail.sender_name = sender[0].user.friendlyName; | ||
payloadEmail.Attributes = "{}" | ||
await notificationEmail.emailNewChat(`${user.toJSON().user_email}`,payloadEmail); | ||
return false; | ||
} | ||
if(payload.Attributes != "{}"){ | ||
console.log('send text card'); | ||
//type card | ||
payloadEmail.receiver_name = receiver[0].user.friendlyName; | ||
payloadEmail.sender_name = sender[0].user.friendlyName; | ||
payloadEmail.Attributes = JSON.parse(payload.Attributes); | ||
await notificationEmail.emailNewChat(`${user.toJSON().user_email}`,payloadEmail); | ||
return false; | ||
} | ||
break; | ||
@@ -75,0 +62,0 @@ case payload.EventType === "onMediaMessageSent": |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2
68822
2014