Built motion from commit ab870f9e.|2.5.44
[motion2.git] / server / api / smsAccount / smsAccount.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 _0x8506=['lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','debug','SmsAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','SmsAccount','options','raw','where','attributes','include','map','model','ShowSmsAccount','catch'];(function(_0x546882,_0x44155d){var _0x29c388=function(_0x10d7da){while(--_0x10d7da){_0x546882['push'](_0x546882['shift']());}};_0x29c388(++_0x44155d);}(_0x8506,0x1d4));var _0x6850=function(_0x133535,_0x47defd){_0x133535=_0x133535-0x0;var _0x30201a=_0x8506[_0x133535];return _0x30201a;};'use strict';var _=require(_0x6850('0x0'));var util=require(_0x6850('0x1'));var moment=require(_0x6850('0x2'));var BPromise=require(_0x6850('0x3'));var rs=require(_0x6850('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6850('0x5'))['db'];var utils=require(_0x6850('0x6'));var logger=require('../../config/logger')(_0x6850('0x7'));var config=require(_0x6850('0x8'));var jayson=require(_0x6850('0x9'));var client=jayson[_0x6850('0xa')][_0x6850('0xb')]({'port':0x232a});config[_0x6850('0xc')]=_[_0x6850('0xd')](config[_0x6850('0xc')],{'host':_0x6850('0xe'),'port':0x18eb});var socket=require(_0x6850('0xf'))(new Redis(config[_0x6850('0xc')]));require('./smsAccount.socket')[_0x6850('0x10')](socket);function respondWithRpcPromise(_0x309ad9,_0x2cbbe4,_0x3526e8){return new BPromise(function(_0xe02b04,_0x457276){return client['request'](_0x309ad9,_0x3526e8)[_0x6850('0x11')](function(_0x45cce8){logger[_0x6850('0x12')](_0x6850('0x13'),_0x2cbbe4,_0x6850('0x14'));logger[_0x6850('0x15')](_0x6850('0x16'),_0x2cbbe4,_0x6850('0x14'),JSON[_0x6850('0x17')](_0x45cce8));if(_0x45cce8[_0x6850('0x18')]){if(_0x45cce8[_0x6850('0x18')]['code']===0x1f4){logger[_0x6850('0x18')](_0x6850('0x13'),_0x2cbbe4,_0x45cce8[_0x6850('0x18')][_0x6850('0x19')]);return _0x457276(_0x45cce8[_0x6850('0x18')][_0x6850('0x19')]);}logger[_0x6850('0x18')](_0x6850('0x13'),_0x2cbbe4,_0x45cce8['error'][_0x6850('0x19')]);return _0xe02b04(_0x45cce8['error'][_0x6850('0x19')]);}else{logger['info'](_0x6850('0x13'),_0x2cbbe4,_0x6850('0x14'));_0xe02b04(_0x45cce8['result']['message']);}})['catch'](function(_0x10ea95){logger['error'](_0x6850('0x13'),_0x2cbbe4,_0x10ea95);_0x457276(_0x10ea95);});});}exports['ShowSmsAccount']=function(_0x1ac683){var _0xd11247=this;return new Promise(function(_0x458aeb,_0x3ef644){return db[_0x6850('0x1a')]['find']({'raw':_0x1ac683[_0x6850('0x1b')]?_0x1ac683['options'][_0x6850('0x1c')]===undefined?!![]:![]:!![],'where':_0x1ac683[_0x6850('0x1b')]?_0x1ac683['options'][_0x6850('0x1d')]||null:null,'attributes':_0x1ac683[_0x6850('0x1b')]?_0x1ac683[_0x6850('0x1b')][_0x6850('0x1e')]||null:null,'include':_0x1ac683['options']?_0x1ac683[_0x6850('0x1b')][_0x6850('0x1f')]?_[_0x6850('0x20')](_0x1ac683[_0x6850('0x1b')][_0x6850('0x1f')],function(_0x1218c9){return{'model':db[_0x1218c9[_0x6850('0x21')]],'as':_0x1218c9['as'],'attributes':_0x1218c9[_0x6850('0x1e')],'include':_0x1218c9[_0x6850('0x1f')]?_[_0x6850('0x20')](_0x1218c9[_0x6850('0x1f')],function(_0x39d6eb){return{'model':db[_0x39d6eb[_0x6850('0x21')]],'as':_0x39d6eb['as'],'attributes':_0x39d6eb[_0x6850('0x1e')],'include':_0x39d6eb[_0x6850('0x1f')]?_[_0x6850('0x20')](_0x39d6eb[_0x6850('0x1f')],function(_0x521995){return{'model':db[_0x521995[_0x6850('0x21')]],'as':_0x521995['as'],'attributes':_0x521995[_0x6850('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x6850('0x11')](function(_0x4d4a59){logger['info'](_0x6850('0x22'),_0x1ac683);logger[_0x6850('0x15')](_0x6850('0x22'),_0x1ac683,JSON[_0x6850('0x17')](_0x4d4a59));_0x458aeb(_0x4d4a59);})[_0x6850('0x23')](function(_0x44dc5e){logger['error']('ShowSmsAccount',_0x44dc5e['message'],_0x1ac683);_0x3ef644(_0xd11247[_0x6850('0x18')](0x1f4,_0x44dc5e[_0x6850('0x19')]));});});};