95e7c2872f518761827804261d617b8febc6330a
[motion2.git] / server / api / intDeskAccount / intDeskAccount.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 _0x097b=['include','map','model','attributes','GetDeskAccount','ShowDeskAccount','find','lodash','util','moment','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','http','request','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','DeskAccount','findAll','options','raw','where','limit'];(function(_0x487b0c,_0x14ff74){var _0x1adbdc=function(_0x2e7b9d){while(--_0x2e7b9d){_0x487b0c['push'](_0x487b0c['shift']());}};_0x1adbdc(++_0x14ff74);}(_0x097b,0xfc));var _0xb097=function(_0x523f15,_0x547987){_0x523f15=_0x523f15-0x0;var _0x4092e6=_0x097b[_0x523f15];return _0x4092e6;};'use strict';var _=require(_0xb097('0x0'));var util=require(_0xb097('0x1'));var moment=require(_0xb097('0x2'));var BPromise=require('bluebird');var rs=require(_0xb097('0x3'));var fs=require('fs');var Redis=require(_0xb097('0x4'));var db=require(_0xb097('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xb097('0x6'));var config=require(_0xb097('0x7'));var jayson=require('jayson/promise');var client=jayson['client'][_0xb097('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1977e5,_0x595074,_0x546c50){return new BPromise(function(_0xaa3c5a,_0x5b11dc){return client[_0xb097('0x9')](_0x1977e5,_0x546c50)[_0xb097('0xa')](function(_0x22432b){logger[_0xb097('0xb')](_0xb097('0xc'),_0x595074,_0xb097('0xd'));logger[_0xb097('0xe')](_0xb097('0xf'),_0x595074,_0xb097('0xd'),JSON[_0xb097('0x10')](_0x22432b));if(_0x22432b[_0xb097('0x11')]){if(_0x22432b[_0xb097('0x11')][_0xb097('0x12')]===0x1f4){logger['error'](_0xb097('0xc'),_0x595074,_0x22432b[_0xb097('0x11')]['message']);return _0x5b11dc(_0x22432b[_0xb097('0x11')][_0xb097('0x13')]);}logger[_0xb097('0x11')](_0xb097('0xc'),_0x595074,_0x22432b[_0xb097('0x11')]['message']);return _0xaa3c5a(_0x22432b[_0xb097('0x11')]['message']);}else{logger[_0xb097('0xb')](_0xb097('0xc'),_0x595074,_0xb097('0xd'));_0xaa3c5a(_0x22432b[_0xb097('0x14')][_0xb097('0x13')]);}})[_0xb097('0x15')](function(_0x3dab51){logger['error']('DeskAccount,\x20%s,\x20%s',_0x595074,_0x3dab51);_0x5b11dc(_0x3dab51);});});}exports['GetDeskAccount']=function(_0x2f5df0){var _0x374b5e=this;return new Promise(function(_0x1c186d,_0x17d7af){return db[_0xb097('0x16')][_0xb097('0x17')]({'raw':_0x2f5df0['options']?_0x2f5df0[_0xb097('0x18')][_0xb097('0x19')]===undefined?!![]:![]:!![],'where':_0x2f5df0[_0xb097('0x18')]?_0x2f5df0[_0xb097('0x18')][_0xb097('0x1a')]||null:null,'attributes':_0x2f5df0['options']?_0x2f5df0[_0xb097('0x18')]['attributes']||null:null,'limit':_0x2f5df0['options']?_0x2f5df0[_0xb097('0x18')][_0xb097('0x1b')]||null:null,'include':_0x2f5df0[_0xb097('0x18')]?_0x2f5df0['options'][_0xb097('0x1c')]?_[_0xb097('0x1d')](_0x2f5df0[_0xb097('0x18')]['include'],function(_0x373dfc){return{'model':db[_0x373dfc[_0xb097('0x1e')]],'as':_0x373dfc['as'],'attributes':_0x373dfc[_0xb097('0x1f')],'include':_0x373dfc[_0xb097('0x1c')]?_[_0xb097('0x1d')](_0x373dfc[_0xb097('0x1c')],function(_0x26ad2b){return{'model':db[_0x26ad2b['model']],'as':_0x26ad2b['as'],'attributes':_0x26ad2b['attributes'],'include':_0x26ad2b['include']?_[_0xb097('0x1d')](_0x26ad2b[_0xb097('0x1c')],function(_0x2dbbc5){return{'model':db[_0x2dbbc5[_0xb097('0x1e')]],'as':_0x2dbbc5['as'],'attributes':_0x2dbbc5[_0xb097('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb097('0xa')](function(_0xab1b02){logger[_0xb097('0xb')](_0xb097('0x20'),_0x2f5df0);logger[_0xb097('0xe')](_0xb097('0x20'),_0x2f5df0,JSON[_0xb097('0x10')](_0xab1b02));_0x1c186d(_0xab1b02);})[_0xb097('0x15')](function(_0x408d19){logger[_0xb097('0x11')](_0xb097('0x20'),_0x408d19[_0xb097('0x13')],_0x2f5df0);_0x17d7af(_0x374b5e[_0xb097('0x11')](0x1f4,_0x408d19[_0xb097('0x13')]));});});};exports[_0xb097('0x21')]=function(_0x7020aa){var _0x285b8a=this;return new Promise(function(_0x2c3521,_0x394ae8){return db[_0xb097('0x16')][_0xb097('0x22')]({'raw':_0x7020aa[_0xb097('0x18')]?_0x7020aa[_0xb097('0x18')][_0xb097('0x19')]===undefined?!![]:![]:!![],'where':_0x7020aa['options']?_0x7020aa[_0xb097('0x18')]['where']||null:null,'attributes':_0x7020aa[_0xb097('0x18')]?_0x7020aa['options'][_0xb097('0x1f')]||null:null,'include':_0x7020aa['options']?_0x7020aa[_0xb097('0x18')][_0xb097('0x1c')]?_[_0xb097('0x1d')](_0x7020aa[_0xb097('0x18')][_0xb097('0x1c')],function(_0x157257){return{'model':db[_0x157257[_0xb097('0x1e')]],'as':_0x157257['as'],'attributes':_0x157257[_0xb097('0x1f')],'include':_0x157257[_0xb097('0x1c')]?_[_0xb097('0x1d')](_0x157257[_0xb097('0x1c')],function(_0x5d0733){return{'model':db[_0x5d0733[_0xb097('0x1e')]],'as':_0x5d0733['as'],'attributes':_0x5d0733[_0xb097('0x1f')],'include':_0x5d0733[_0xb097('0x1c')]?_[_0xb097('0x1d')](_0x5d0733[_0xb097('0x1c')],function(_0x37ab81){return{'model':db[_0x37ab81[_0xb097('0x1e')]],'as':_0x37ab81['as'],'attributes':_0x37ab81[_0xb097('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb097('0xa')](function(_0x1aef3b){logger['info'](_0xb097('0x21'),_0x7020aa);logger[_0xb097('0xe')](_0xb097('0x21'),_0x7020aa,JSON[_0xb097('0x10')](_0x1aef3b));_0x2c3521(_0x1aef3b);})['catch'](function(_0x537669){logger[_0xb097('0x11')]('ShowDeskAccount',_0x537669[_0xb097('0x13')],_0x7020aa);_0x394ae8(_0x285b8a[_0xb097('0x11')](0x1f4,_0x537669[_0xb097('0x13')]));});});};