diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 325e2e60d3..4e088d6ee3 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -34,8 +34,12 @@ module.exports = Self => { Self.send = async(ctx, destinationFk, destination, message) => { const userId = ctx.req.accessToken.userId; const smsConfig = await Self.app.models.SmsConfig.findOne(); - /* if (destination.length <= 9) - destination = '34' + destination;*/ + + if (destination.length == 9) { + const spainPrefix = '0034'; + destination = spainPrefix + destination; + } + const params = { api_key: smsConfig.apiKey, messages: [{ diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js index 910b7d7b21..7ca78b2149 100644 --- a/modules/client/back/methods/sms/send.spec.js +++ b/modules/client/back/methods/sms/send.spec.js @@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server'); describe('sms send()', () => { it('should not return status error', async() => { const ctx = {req: {accessToken: {userId: 1}}}; - const result = await app.models.Sms.send(ctx, 1105, '123123123', 'My SMS Body'); + const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body'); expect(result.status).toBeUndefined(); });