Log sent sms #1324
This commit is contained in:
parent
34a630dcde
commit
90bbe1bd02
|
@ -6,11 +6,11 @@ module.exports = Self => {
|
|||
Self.remoteMethodCtx('send', {
|
||||
description: 'Sends SMS to a destination phone',
|
||||
accepts: [{
|
||||
arg: 'recipientFk',
|
||||
arg: 'destinationFk',
|
||||
type: 'Integer'
|
||||
},
|
||||
{
|
||||
arg: 'recipient',
|
||||
arg: 'destination',
|
||||
type: 'String',
|
||||
required: true,
|
||||
},
|
||||
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
|||
required: true,
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.send = async(ctx, recipientFk, recipient, message) => {
|
||||
Self.send = async(ctx, destinationFk, destination, message) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const smsConfig = await Self.app.models.SmsConfig.findOne();
|
||||
const soapClient = await soap.createClientAsync(smsConfig.uri);
|
||||
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
user: smsConfig.user,
|
||||
pass: smsConfig.password,
|
||||
src: smsConfig.title,
|
||||
dst: recipient,
|
||||
dst: destination,
|
||||
msg: message
|
||||
};
|
||||
|
||||
|
@ -61,18 +61,21 @@ module.exports = Self => {
|
|||
console.error(e);
|
||||
}
|
||||
|
||||
const statusCode = status.codigo[0];
|
||||
const statusDescription = status.descripcion[0];
|
||||
|
||||
const newSms = {
|
||||
senderFk: userId,
|
||||
destinationFk: recipientFk || null,
|
||||
destination: recipient,
|
||||
destinationFk: destinationFk || null,
|
||||
destination: destination,
|
||||
message: message,
|
||||
statusCode: status.codigo,
|
||||
status: status.descripcion
|
||||
statusCode: statusCode,
|
||||
status: statusDescription
|
||||
};
|
||||
|
||||
const sms = Self.create(newSms);
|
||||
const sms = await Self.create(newSms);
|
||||
|
||||
if (status.codigo != 200)
|
||||
if (statusCode != 200)
|
||||
throw new UserError(`We weren't able to send this SMS`);
|
||||
|
||||
return sms;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{
|
||||
"name": "Sms",
|
||||
"description": "Sms sent to client",
|
||||
"base": "VnModel",
|
||||
"base": "Loggable",
|
||||
"log": {
|
||||
"model":"ClientLog",
|
||||
"relation": "recipient"
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "sms"
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<h5 pad-small-v translate>Send SMS</h5>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one
|
||||
label="Recipient"
|
||||
model="$ctrl.sms.recipient">
|
||||
label="Destination"
|
||||
model="$ctrl.sms.destination">
|
||||
</vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal >
|
||||
|
|
|
@ -18,11 +18,7 @@ class Controller extends Component {
|
|||
|
||||
onResponse(response) {
|
||||
if (response === 'ACCEPT') {
|
||||
let params = {
|
||||
recipient: this.sms.recipient,
|
||||
message: this.sms.message
|
||||
};
|
||||
this.$http.post(`/client/api/Sms/send`, params).then(res => {
|
||||
this.$http.post(`/client/api/Sms/send`, this.sms).then(res => {
|
||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||
|
||||
if (res.data) this.emit('send', {response: res.data});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Send SMS: Enviar SMS
|
||||
Recipient: Destinatario
|
||||
Destination: Destinatario
|
||||
Message: Mensaje
|
||||
SMS sent!: ¡SMS enviado!
|
|
@ -182,7 +182,8 @@ class Controller {
|
|||
showSMSDialog() {
|
||||
const address = this.ticket.address;
|
||||
this.newSMS = {
|
||||
recipient: address.mobile || null,
|
||||
destinationFk: this.ticket.clientFk,
|
||||
destination: address.mobile || null,
|
||||
message: this.$translate.instant('SMSPayment')
|
||||
};
|
||||
this.$scope.sms.open();
|
||||
|
|
|
@ -331,7 +331,8 @@ class Controller {
|
|||
notAvailables
|
||||
};
|
||||
this.newSMS = {
|
||||
recipient: address.mobile || null,
|
||||
destinationFk: this.ticket.clientFk,
|
||||
destination: address.mobile || null,
|
||||
message: this.$translate.instant('SMSAvailability', params)
|
||||
};
|
||||
this.$scope.sms.open();
|
||||
|
|
Loading…
Reference in New Issue