bdc69b4a52b5465a9f73107dcd5ee22be27cfd76
[motion2.git] / server / api / smsApplication / smsApplication.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x7f3f=['ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','then','info','SmsApplication,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','catch','lodash','util','bluebird','randomstring'];(function(_0x4d30ac,_0x112604){var _0x279f70=function(_0x38475f){while(--_0x38475f){_0x4d30ac['push'](_0x4d30ac['shift']());}};_0x279f70(++_0x112604);}(_0x7f3f,0x1c8));var _0xf7f3=function(_0x20cf8a,_0x44cd6b){_0x20cf8a=_0x20cf8a-0x0;var _0x54e165=_0x7f3f[_0x20cf8a];return _0x54e165;};'use strict';var _=require(_0xf7f3('0x0'));var util=require(_0xf7f3('0x1'));var moment=require('moment');var BPromise=require(_0xf7f3('0x2'));var rs=require(_0xf7f3('0x3'));var fs=require('fs');var Redis=require(_0xf7f3('0x4'));var db=require(_0xf7f3('0x5'))['db'];var utils=require(_0xf7f3('0x6'));var logger=require('../../config/logger')(_0xf7f3('0x7'));var config=require(_0xf7f3('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xf7f3('0x9')][_0xf7f3('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xe75375,_0x32a035,_0x14b371){return new BPromise(function(_0x31beac,_0x464bf9){return client['request'](_0xe75375,_0x14b371)[_0xf7f3('0xb')](function(_0x468c0c){logger[_0xf7f3('0xc')](_0xf7f3('0xd'),_0x32a035,_0xf7f3('0xe'));logger[_0xf7f3('0xf')]('SmsApplication,\x20%s,\x20%s,\x20%s',_0x32a035,'request\x20sent',JSON[_0xf7f3('0x10')](_0x468c0c));if(_0x468c0c['error']){if(_0x468c0c['error']['code']===0x1f4){logger[_0xf7f3('0x11')](_0xf7f3('0xd'),_0x32a035,_0x468c0c[_0xf7f3('0x11')][_0xf7f3('0x12')]);return _0x464bf9(_0x468c0c[_0xf7f3('0x11')]['message']);}logger[_0xf7f3('0x11')](_0xf7f3('0xd'),_0x32a035,_0x468c0c['error']['message']);return _0x31beac(_0x468c0c['error']['message']);}else{logger['info'](_0xf7f3('0xd'),_0x32a035,_0xf7f3('0xe'));_0x31beac(_0x468c0c['result'][_0xf7f3('0x12')]);}})[_0xf7f3('0x13')](function(_0xd0d1b0){logger['error']('SmsApplication,\x20%s,\x20%s',_0x32a035,_0xd0d1b0);_0x464bf9(_0xd0d1b0);});});}