update sms
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-01-10 13:20:57 +01:00
parent 75de01ed72
commit fc69151f7f
3 changed files with 20 additions and 23 deletions

View File

@ -1,12 +1,13 @@
ALTER TABLE `vn`.`smsConfig` ADD apiKey varchar(50) NULL; ALTER TABLE `vn`.`smsConfig` ADD apiKey varchar(50) NULL;
UPDATE `vn`.`smsConfig` UPDATE `vn`.`smsConfig`
SET uri='https://api.gateway360.com/api/3.0/sms/send' SET `uri` = 'https://api.gateway360.com/api/3.0/sms/send'
WHERE id=1; WHERE `id` = 1;
UPDATE `vn`.`smsConfig` UPDATE `vn`.`smsConfig`
SET apiKey='5715476da95b46d686a5a255e6459523' SET `apiKey`='5715476da95b46d686a5a255e6459523'
WHERE id=1; 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 `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; 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;

View File

@ -35,21 +35,23 @@ module.exports = Self => {
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();
const params = { const params = {
'api_key': smsConfig.apiKey, api_key: smsConfig.apiKey,
'mensage': [ fake: '1',
{ messages: [{
'from': '693474205', from: '693474205',
'to': destination, to: destination,
'text': message text: message
} }]
]
}; };
try { try {
if (process.env.NODE_ENV !== 'production') /* if (process.env.NODE_ENV !== 'production')
params.fake = 1; 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) { } catch (e) {
console.error(e); console.error(e);
} }

View File

@ -16,13 +16,7 @@
"uri": { "uri": {
"type": "String" "type": "String"
}, },
"user": { "apiKey": {
"type": "String"
},
"password": {
"type": "String"
},
"title": {
"type": "String" "type": "String"
} }
} }