diff --git a/db/changes/10410-noname/00-smsConfig.sql b/db/changes/10410-noname/00-smsConfig.sql index 0798bcd31..0cbfbc19d 100644 --- a/db/changes/10410-noname/00-smsConfig.sql +++ b/db/changes/10410-noname/00-smsConfig.sql @@ -1,12 +1,13 @@ ALTER TABLE `vn`.`smsConfig` ADD apiKey varchar(50) NULL; UPDATE `vn`.`smsConfig` - SET uri='https://api.gateway360.com/api/3.0/sms/send' - WHERE id=1; + SET `uri` = 'https://api.gateway360.com/api/3.0/sms/send' + WHERE `id` = 1; UPDATE `vn`.`smsConfig` - SET apiKey='5715476da95b46d686a5a255e6459523' - WHERE id=1; + SET `apiKey`='5715476da95b46d686a5a255e6459523' + WHERE `id` = 1; ALTER TABLE `vn`.`smsConfig` CHANGE `user` user__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; -ALTER TABLE `vn`.`smsConfig` CHANGE password password__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; \ No newline at end of file +ALTER TABLE `vn`.`smsConfig` CHANGE password password__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; +ALTER TABLE `vn`.`smsConfig` CHANGE title title__ varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; \ No newline at end of file diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 40a49ce1d..e992b22b8 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -35,21 +35,23 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const smsConfig = await Self.app.models.SmsConfig.findOne(); const params = { - 'api_key': smsConfig.apiKey, - 'mensage': [ - { - 'from': '693474205', - 'to': destination, - 'text': message - } - ] + api_key: smsConfig.apiKey, + fake: '1', + messages: [{ + from: '693474205', + to: destination, + text: message + }] }; try { - if (process.env.NODE_ENV !== 'production') - params.fake = 1; + /* if (process.env.NODE_ENV !== 'production') + params.fake = 1;*/ + const paramsJson = JSON.stringify(params); + console.log(paramsJson); + const response = await got.post(smsConfig.uri, paramsJson); - const response = got.post(smsConfig.uri, params); + console.log(response); } catch (e) { console.error(e); } diff --git a/modules/client/back/models/sms-config.json b/modules/client/back/models/sms-config.json index 3134f8674..a137492f6 100644 --- a/modules/client/back/models/sms-config.json +++ b/modules/client/back/models/sms-config.json @@ -16,13 +16,7 @@ "uri": { "type": "String" }, - "user": { - "type": "String" - }, - "password": { - "type": "String" - }, - "title": { + "apiKey": { "type": "String" } }