add prefix +34
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
9e491082e7
commit
4f0edbda6b
|
@ -34,8 +34,12 @@ module.exports = Self => {
|
||||||
Self.send = async(ctx, destinationFk, destination, message) => {
|
Self.send = async(ctx, destinationFk, destination, message) => {
|
||||||
const userId = ctx.req.accessToken.userId;
|
const userId = ctx.req.accessToken.userId;
|
||||||
const smsConfig = await Self.app.models.SmsConfig.findOne();
|
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 = {
|
const params = {
|
||||||
api_key: smsConfig.apiKey,
|
api_key: smsConfig.apiKey,
|
||||||
messages: [{
|
messages: [{
|
||||||
|
|
|
@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('sms send()', () => {
|
describe('sms send()', () => {
|
||||||
it('should not return status error', async() => {
|
it('should not return status error', async() => {
|
||||||
const ctx = {req: {accessToken: {userId: 1}}};
|
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();
|
expect(result.status).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue