Built motion from commit c738b9ac.|2.6.25
[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 _0xac6f=['../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./smsAccount.socket','register','request','info','SmsAccount,\x20%s,\x20%s','SmsAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','SmsAccount','find','options','attributes','include','model','map','then','ShowSmsAccount','debug','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc'];(function(_0x5cf90e,_0x5df405){var _0xae958d=function(_0x52c27c){while(--_0x52c27c){_0x5cf90e['push'](_0x5cf90e['shift']());}};_0xae958d(++_0x5df405);}(_0xac6f,0x14d));var _0xfac6=function(_0x2e288c,_0x5442d6){_0x2e288c=_0x2e288c-0x0;var _0x507d40=_0xac6f[_0x2e288c];return _0x507d40;};'use strict';var _=require(_0xfac6('0x0'));var util=require(_0xfac6('0x1'));var moment=require(_0xfac6('0x2'));var BPromise=require(_0xfac6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xfac6('0x4'));var db=require(_0xfac6('0x5'))['db'];var utils=require(_0xfac6('0x6'));var logger=require(_0xfac6('0x7'))(_0xfac6('0x8'));var config=require(_0xfac6('0x9'));var jayson=require(_0xfac6('0xa'));var client=jayson[_0xfac6('0xb')][_0xfac6('0xc')]({'port':0x232a});config[_0xfac6('0xd')]=_['defaults'](config[_0xfac6('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0xfac6('0xe'))(new Redis(config[_0xfac6('0xd')]));require(_0xfac6('0xf'))[_0xfac6('0x10')](socket);function respondWithRpcPromise(_0x1a4fa1,_0x2f0071,_0x51dc2c){return new BPromise(function(_0x1fac2a,_0x20afb9){return client[_0xfac6('0x11')](_0x1a4fa1,_0x51dc2c)['then'](function(_0x306184){logger[_0xfac6('0x12')](_0xfac6('0x13'),_0x2f0071,'request\x20sent');logger['debug'](_0xfac6('0x14'),_0x2f0071,_0xfac6('0x15'),JSON[_0xfac6('0x16')](_0x306184));if(_0x306184[_0xfac6('0x17')]){if(_0x306184['error'][_0xfac6('0x18')]===0x1f4){logger[_0xfac6('0x17')](_0xfac6('0x13'),_0x2f0071,_0x306184['error'][_0xfac6('0x19')]);return _0x20afb9(_0x306184[_0xfac6('0x17')]['message']);}logger['error'](_0xfac6('0x13'),_0x2f0071,_0x306184[_0xfac6('0x17')][_0xfac6('0x19')]);return _0x1fac2a(_0x306184['error']['message']);}else{logger[_0xfac6('0x12')](_0xfac6('0x13'),_0x2f0071,_0xfac6('0x15'));_0x1fac2a(_0x306184[_0xfac6('0x1a')][_0xfac6('0x19')]);}})[_0xfac6('0x1b')](function(_0x1bd64f){logger['error'](_0xfac6('0x13'),_0x2f0071,_0x1bd64f);_0x20afb9(_0x1bd64f);});});}exports['ShowSmsAccount']=function(_0x122d77){var _0x212edd=this;return new Promise(function(_0x7b347a,_0x24b131){return db[_0xfac6('0x1c')][_0xfac6('0x1d')]({'raw':_0x122d77['options']?_0x122d77[_0xfac6('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x122d77['options']?_0x122d77['options']['where']||null:null,'attributes':_0x122d77[_0xfac6('0x1e')]?_0x122d77[_0xfac6('0x1e')][_0xfac6('0x1f')]||null:null,'include':_0x122d77['options']?_0x122d77[_0xfac6('0x1e')][_0xfac6('0x20')]?_['map'](_0x122d77[_0xfac6('0x1e')][_0xfac6('0x20')],function(_0x1a1dca){return{'model':db[_0x1a1dca[_0xfac6('0x21')]],'as':_0x1a1dca['as'],'attributes':_0x1a1dca[_0xfac6('0x1f')],'include':_0x1a1dca['include']?_[_0xfac6('0x22')](_0x1a1dca[_0xfac6('0x20')],function(_0xe083a4){return{'model':db[_0xe083a4['model']],'as':_0xe083a4['as'],'attributes':_0xe083a4[_0xfac6('0x1f')],'include':_0xe083a4['include']?_[_0xfac6('0x22')](_0xe083a4[_0xfac6('0x20')],function(_0x13434a){return{'model':db[_0x13434a[_0xfac6('0x21')]],'as':_0x13434a['as'],'attributes':_0x13434a['attributes']};}):[]};}):[]};}):[]:[]})[_0xfac6('0x23')](function(_0x271b45){logger[_0xfac6('0x12')](_0xfac6('0x24'),_0x122d77);logger[_0xfac6('0x25')](_0xfac6('0x24'),_0x122d77,JSON[_0xfac6('0x16')](_0x271b45));_0x7b347a(_0x271b45);})[_0xfac6('0x1b')](function(_0x20d392){logger['error'](_0xfac6('0x24'),_0x20d392[_0xfac6('0x19')],_0x122d77);_0x24b131(_0x212edd[_0xfac6('0x17')](0x1f4,_0x20d392[_0xfac6('0x19')]));});});};