Built motion from commit 52c8a02d.|2.6.29
[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 _0x7267=['ShowDeskAccount','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','then','info','request\x20sent','debug','error','code','DeskAccount,\x20%s,\x20%s','message','catch','DeskAccount','options','raw','limit','include','model','attributes','map','GetDeskAccount','stringify','find','where'];(function(_0x2533d4,_0x2afa20){var _0x113f30=function(_0x228e6b){while(--_0x228e6b){_0x2533d4['push'](_0x2533d4['shift']());}};_0x113f30(++_0x2afa20);}(_0x7267,0x16c));var _0x7726=function(_0x2f3030,_0x4ba9e1){_0x2f3030=_0x2f3030-0x0;var _0x31f77b=_0x7267[_0x2f3030];return _0x31f77b;};'use strict';var _=require(_0x7726('0x0'));var util=require(_0x7726('0x1'));var moment=require('moment');var BPromise=require(_0x7726('0x2'));var rs=require(_0x7726('0x3'));var fs=require('fs');var Redis=require(_0x7726('0x4'));var db=require(_0x7726('0x5'))['db'];var utils=require(_0x7726('0x6'));var logger=require(_0x7726('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0x7726('0x8'));var client=jayson[_0x7726('0x9')][_0x7726('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1a5ae0,_0x8cfddf,_0x170571){return new BPromise(function(_0x74cbf7,_0x22eff8){return client['request'](_0x1a5ae0,_0x170571)[_0x7726('0xb')](function(_0xebce49){logger[_0x7726('0xc')]('DeskAccount,\x20%s,\x20%s',_0x8cfddf,_0x7726('0xd'));logger[_0x7726('0xe')]('DeskAccount,\x20%s,\x20%s,\x20%s',_0x8cfddf,'request\x20sent',JSON['stringify'](_0xebce49));if(_0xebce49[_0x7726('0xf')]){if(_0xebce49[_0x7726('0xf')][_0x7726('0x10')]===0x1f4){logger['error'](_0x7726('0x11'),_0x8cfddf,_0xebce49['error'][_0x7726('0x12')]);return _0x22eff8(_0xebce49['error']['message']);}logger['error'](_0x7726('0x11'),_0x8cfddf,_0xebce49[_0x7726('0xf')][_0x7726('0x12')]);return _0x74cbf7(_0xebce49['error']['message']);}else{logger[_0x7726('0xc')](_0x7726('0x11'),_0x8cfddf,_0x7726('0xd'));_0x74cbf7(_0xebce49['result']['message']);}})[_0x7726('0x13')](function(_0xaef3cc){logger[_0x7726('0xf')](_0x7726('0x11'),_0x8cfddf,_0xaef3cc);_0x22eff8(_0xaef3cc);});});}exports['GetDeskAccount']=function(_0x1cdac){var _0xe4fd7=this;return new Promise(function(_0x9b3fb7,_0x2ddfd1){return db[_0x7726('0x14')]['findAll']({'raw':_0x1cdac[_0x7726('0x15')]?_0x1cdac[_0x7726('0x15')][_0x7726('0x16')]===undefined?!![]:![]:!![],'where':_0x1cdac[_0x7726('0x15')]?_0x1cdac[_0x7726('0x15')]['where']||null:null,'attributes':_0x1cdac[_0x7726('0x15')]?_0x1cdac[_0x7726('0x15')]['attributes']||null:null,'limit':_0x1cdac[_0x7726('0x15')]?_0x1cdac['options'][_0x7726('0x17')]||null:null,'include':_0x1cdac['options']?_0x1cdac['options'][_0x7726('0x18')]?_['map'](_0x1cdac[_0x7726('0x15')][_0x7726('0x18')],function(_0x1c9add){return{'model':db[_0x1c9add[_0x7726('0x19')]],'as':_0x1c9add['as'],'attributes':_0x1c9add[_0x7726('0x1a')],'include':_0x1c9add['include']?_[_0x7726('0x1b')](_0x1c9add[_0x7726('0x18')],function(_0x5f04cb){return{'model':db[_0x5f04cb[_0x7726('0x19')]],'as':_0x5f04cb['as'],'attributes':_0x5f04cb[_0x7726('0x1a')],'include':_0x5f04cb['include']?_[_0x7726('0x1b')](_0x5f04cb[_0x7726('0x18')],function(_0x251614){return{'model':db[_0x251614[_0x7726('0x19')]],'as':_0x251614['as'],'attributes':_0x251614['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x134441){logger[_0x7726('0xc')](_0x7726('0x1c'),_0x1cdac);logger['debug'](_0x7726('0x1c'),_0x1cdac,JSON[_0x7726('0x1d')](_0x134441));_0x9b3fb7(_0x134441);})[_0x7726('0x13')](function(_0x243c9a){logger[_0x7726('0xf')](_0x7726('0x1c'),_0x243c9a[_0x7726('0x12')],_0x1cdac);_0x2ddfd1(_0xe4fd7[_0x7726('0xf')](0x1f4,_0x243c9a['message']));});});};exports['ShowDeskAccount']=function(_0x2967f1){var _0x5f1cdd=this;return new Promise(function(_0x38c542,_0x246782){return db[_0x7726('0x14')][_0x7726('0x1e')]({'raw':_0x2967f1['options']?_0x2967f1[_0x7726('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x2967f1[_0x7726('0x15')]?_0x2967f1['options'][_0x7726('0x1f')]||null:null,'attributes':_0x2967f1[_0x7726('0x15')]?_0x2967f1[_0x7726('0x15')][_0x7726('0x1a')]||null:null,'include':_0x2967f1[_0x7726('0x15')]?_0x2967f1[_0x7726('0x15')][_0x7726('0x18')]?_[_0x7726('0x1b')](_0x2967f1[_0x7726('0x15')][_0x7726('0x18')],function(_0x4df883){return{'model':db[_0x4df883['model']],'as':_0x4df883['as'],'attributes':_0x4df883[_0x7726('0x1a')],'include':_0x4df883[_0x7726('0x18')]?_[_0x7726('0x1b')](_0x4df883['include'],function(_0x345991){return{'model':db[_0x345991[_0x7726('0x19')]],'as':_0x345991['as'],'attributes':_0x345991[_0x7726('0x1a')],'include':_0x345991[_0x7726('0x18')]?_['map'](_0x345991[_0x7726('0x18')],function(_0x540b31){return{'model':db[_0x540b31['model']],'as':_0x540b31['as'],'attributes':_0x540b31['attributes']};}):[]};}):[]};}):[]:[]})[_0x7726('0xb')](function(_0x187db8){logger[_0x7726('0xc')](_0x7726('0x20'),_0x2967f1);logger['debug'](_0x7726('0x20'),_0x2967f1,JSON[_0x7726('0x1d')](_0x187db8));_0x38c542(_0x187db8);})[_0x7726('0x13')](function(_0x29e0d3){logger[_0x7726('0xf')]('ShowDeskAccount',_0x29e0d3[_0x7726('0x12')],_0x2967f1);_0x246782(_0x5f1cdd[_0x7726('0xf')](0x1f4,_0x29e0d3[_0x7726('0x12')]));});});};