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;
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;
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 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);
}

View File

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