Built motion from commit 9d0783e6.|2.6.13
[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 _0x4bef=['defaults','socket.io-emitter','./smsAccount.socket','register','request','then','info','SmsAccount,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','SmsAccount','find','options','raw','where','attributes','include','map','model','ShowSmsAccount','debug','stringify','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http'];(function(_0x485b3e,_0x4e1670){var _0x1e1857=function(_0x4e955a){while(--_0x4e955a){_0x485b3e['push'](_0x485b3e['shift']());}};_0x1e1857(++_0x4e1670);}(_0x4bef,0x196));var _0xf4be=function(_0x4b2863,_0x494899){_0x4b2863=_0x4b2863-0x0;var _0x567d67=_0x4bef[_0x4b2863];return _0x567d67;};'use strict';var _=require(_0xf4be('0x0'));var util=require(_0xf4be('0x1'));var moment=require(_0xf4be('0x2'));var BPromise=require('bluebird');var rs=require(_0xf4be('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf4be('0x4'))['db'];var utils=require(_0xf4be('0x5'));var logger=require(_0xf4be('0x6'))(_0xf4be('0x7'));var config=require(_0xf4be('0x8'));var jayson=require(_0xf4be('0x9'));var client=jayson[_0xf4be('0xa')][_0xf4be('0xb')]({'port':0x232a});config['redis']=_[_0xf4be('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xf4be('0xd'))(new Redis(config['redis']));require(_0xf4be('0xe'))[_0xf4be('0xf')](socket);function respondWithRpcPromise(_0x25285e,_0x2d367f,_0x553b29){return new BPromise(function(_0x358759,_0x49fdca){return client[_0xf4be('0x10')](_0x25285e,_0x553b29)[_0xf4be('0x11')](function(_0x26056c){logger[_0xf4be('0x12')](_0xf4be('0x13'),_0x2d367f,_0xf4be('0x14'));logger['debug']('SmsAccount,\x20%s,\x20%s,\x20%s',_0x2d367f,_0xf4be('0x14'),JSON['stringify'](_0x26056c));if(_0x26056c[_0xf4be('0x15')]){if(_0x26056c[_0xf4be('0x15')][_0xf4be('0x16')]===0x1f4){logger[_0xf4be('0x15')]('SmsAccount,\x20%s,\x20%s',_0x2d367f,_0x26056c[_0xf4be('0x15')][_0xf4be('0x17')]);return _0x49fdca(_0x26056c['error'][_0xf4be('0x17')]);}logger['error'](_0xf4be('0x13'),_0x2d367f,_0x26056c[_0xf4be('0x15')]['message']);return _0x358759(_0x26056c['error'][_0xf4be('0x17')]);}else{logger[_0xf4be('0x12')]('SmsAccount,\x20%s,\x20%s',_0x2d367f,_0xf4be('0x14'));_0x358759(_0x26056c[_0xf4be('0x18')][_0xf4be('0x17')]);}})[_0xf4be('0x19')](function(_0x3d2791){logger[_0xf4be('0x15')]('SmsAccount,\x20%s,\x20%s',_0x2d367f,_0x3d2791);_0x49fdca(_0x3d2791);});});}exports['ShowSmsAccount']=function(_0x2dd7b7){var _0x25e2e5=this;return new Promise(function(_0x1ae355,_0x423fa8){return db[_0xf4be('0x1a')][_0xf4be('0x1b')]({'raw':_0x2dd7b7[_0xf4be('0x1c')]?_0x2dd7b7['options'][_0xf4be('0x1d')]===undefined?!![]:![]:!![],'where':_0x2dd7b7[_0xf4be('0x1c')]?_0x2dd7b7[_0xf4be('0x1c')][_0xf4be('0x1e')]||null:null,'attributes':_0x2dd7b7[_0xf4be('0x1c')]?_0x2dd7b7[_0xf4be('0x1c')][_0xf4be('0x1f')]||null:null,'include':_0x2dd7b7['options']?_0x2dd7b7[_0xf4be('0x1c')][_0xf4be('0x20')]?_[_0xf4be('0x21')](_0x2dd7b7['options']['include'],function(_0x556435){return{'model':db[_0x556435[_0xf4be('0x22')]],'as':_0x556435['as'],'attributes':_0x556435[_0xf4be('0x1f')],'include':_0x556435['include']?_[_0xf4be('0x21')](_0x556435[_0xf4be('0x20')],function(_0x4a40d0){return{'model':db[_0x4a40d0[_0xf4be('0x22')]],'as':_0x4a40d0['as'],'attributes':_0x4a40d0[_0xf4be('0x1f')],'include':_0x4a40d0[_0xf4be('0x20')]?_[_0xf4be('0x21')](_0x4a40d0[_0xf4be('0x20')],function(_0x1f0162){return{'model':db[_0x1f0162[_0xf4be('0x22')]],'as':_0x1f0162['as'],'attributes':_0x1f0162['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4aef7b){logger[_0xf4be('0x12')](_0xf4be('0x23'),_0x2dd7b7);logger[_0xf4be('0x24')](_0xf4be('0x23'),_0x2dd7b7,JSON[_0xf4be('0x25')](_0x4aef7b));_0x1ae355(_0x4aef7b);})['catch'](function(_0xfcb51e){logger[_0xf4be('0x15')](_0xf4be('0x23'),_0xfcb51e[_0xf4be('0x17')],_0x2dd7b7);_0x423fa8(_0x25e2e5[_0xf4be('0x15')](0x1f4,_0xfcb51e[_0xf4be('0x17')]));});});};