Built motion from commit f0b1811d.|2.6.6
[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 _0x764f=['model','GetDeskAccount','ShowDeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','DeskAccount','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x2aefb6,_0x1bd384){var _0x202772=function(_0x507d3f){while(--_0x507d3f){_0x2aefb6['push'](_0x2aefb6['shift']());}};_0x202772(++_0x1bd384);}(_0x764f,0x70));var _0xf764=function(_0x562087,_0x1e1739){_0x562087=_0x562087-0x0;var _0x3f62d4=_0x764f[_0x562087];return _0x3f62d4;};'use strict';var _=require(_0xf764('0x0'));var util=require(_0xf764('0x1'));var moment=require(_0xf764('0x2'));var BPromise=require(_0xf764('0x3'));var rs=require(_0xf764('0x4'));var fs=require('fs');var Redis=require(_0xf764('0x5'));var db=require(_0xf764('0x6'))['db'];var utils=require(_0xf764('0x7'));var logger=require(_0xf764('0x8'))(_0xf764('0x9'));var config=require(_0xf764('0xa'));var jayson=require(_0xf764('0xb'));var client=jayson['client'][_0xf764('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x5dff4d,_0x1728ae,_0x33ce79){return new BPromise(function(_0x5d44af,_0x1ee8a8){return client['request'](_0x5dff4d,_0x33ce79)[_0xf764('0xd')](function(_0x31b55e){logger[_0xf764('0xe')](_0xf764('0xf'),_0x1728ae,_0xf764('0x10'));logger[_0xf764('0x11')](_0xf764('0x12'),_0x1728ae,_0xf764('0x10'),JSON[_0xf764('0x13')](_0x31b55e));if(_0x31b55e[_0xf764('0x14')]){if(_0x31b55e[_0xf764('0x14')]['code']===0x1f4){logger[_0xf764('0x14')](_0xf764('0xf'),_0x1728ae,_0x31b55e[_0xf764('0x14')][_0xf764('0x15')]);return _0x1ee8a8(_0x31b55e['error'][_0xf764('0x15')]);}logger[_0xf764('0x14')](_0xf764('0xf'),_0x1728ae,_0x31b55e[_0xf764('0x14')][_0xf764('0x15')]);return _0x5d44af(_0x31b55e[_0xf764('0x14')][_0xf764('0x15')]);}else{logger[_0xf764('0xe')](_0xf764('0xf'),_0x1728ae,_0xf764('0x10'));_0x5d44af(_0x31b55e['result'][_0xf764('0x15')]);}})[_0xf764('0x16')](function(_0x419835){logger[_0xf764('0x14')](_0xf764('0xf'),_0x1728ae,_0x419835);_0x1ee8a8(_0x419835);});});}exports['GetDeskAccount']=function(_0x3dbee7){var _0x5a4641=this;return new Promise(function(_0x27ba70,_0x269ab5){return db[_0xf764('0x17')][_0xf764('0x18')]({'raw':_0x3dbee7['options']?_0x3dbee7[_0xf764('0x19')][_0xf764('0x1a')]===undefined?!![]:![]:!![],'where':_0x3dbee7['options']?_0x3dbee7[_0xf764('0x19')][_0xf764('0x1b')]||null:null,'attributes':_0x3dbee7[_0xf764('0x19')]?_0x3dbee7['options'][_0xf764('0x1c')]||null:null,'limit':_0x3dbee7[_0xf764('0x19')]?_0x3dbee7[_0xf764('0x19')][_0xf764('0x1d')]||null:null,'include':_0x3dbee7[_0xf764('0x19')]?_0x3dbee7[_0xf764('0x19')][_0xf764('0x1e')]?_[_0xf764('0x1f')](_0x3dbee7[_0xf764('0x19')][_0xf764('0x1e')],function(_0x2549dc){return{'model':db[_0x2549dc[_0xf764('0x20')]],'as':_0x2549dc['as'],'attributes':_0x2549dc[_0xf764('0x1c')],'include':_0x2549dc[_0xf764('0x1e')]?_[_0xf764('0x1f')](_0x2549dc[_0xf764('0x1e')],function(_0x952b91){return{'model':db[_0x952b91[_0xf764('0x20')]],'as':_0x952b91['as'],'attributes':_0x952b91[_0xf764('0x1c')],'include':_0x952b91[_0xf764('0x1e')]?_['map'](_0x952b91['include'],function(_0x531e1a){return{'model':db[_0x531e1a[_0xf764('0x20')]],'as':_0x531e1a['as'],'attributes':_0x531e1a[_0xf764('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xf764('0xd')](function(_0x511521){logger['info'](_0xf764('0x21'),_0x3dbee7);logger[_0xf764('0x11')](_0xf764('0x21'),_0x3dbee7,JSON[_0xf764('0x13')](_0x511521));_0x27ba70(_0x511521);})[_0xf764('0x16')](function(_0x2526e9){logger[_0xf764('0x14')](_0xf764('0x21'),_0x2526e9['message'],_0x3dbee7);_0x269ab5(_0x5a4641[_0xf764('0x14')](0x1f4,_0x2526e9[_0xf764('0x15')]));});});};exports[_0xf764('0x22')]=function(_0x6813a4){var _0x15a8c7=this;return new Promise(function(_0x3a645c,_0x58c5e5){return db[_0xf764('0x17')][_0xf764('0x23')]({'raw':_0x6813a4['options']?_0x6813a4['options'][_0xf764('0x1a')]===undefined?!![]:![]:!![],'where':_0x6813a4[_0xf764('0x19')]?_0x6813a4[_0xf764('0x19')]['where']||null:null,'attributes':_0x6813a4['options']?_0x6813a4['options'][_0xf764('0x1c')]||null:null,'include':_0x6813a4[_0xf764('0x19')]?_0x6813a4[_0xf764('0x19')]['include']?_[_0xf764('0x1f')](_0x6813a4[_0xf764('0x19')][_0xf764('0x1e')],function(_0x23f0ff){return{'model':db[_0x23f0ff['model']],'as':_0x23f0ff['as'],'attributes':_0x23f0ff[_0xf764('0x1c')],'include':_0x23f0ff[_0xf764('0x1e')]?_[_0xf764('0x1f')](_0x23f0ff[_0xf764('0x1e')],function(_0x3c921f){return{'model':db[_0x3c921f['model']],'as':_0x3c921f['as'],'attributes':_0x3c921f[_0xf764('0x1c')],'include':_0x3c921f[_0xf764('0x1e')]?_['map'](_0x3c921f['include'],function(_0x127238){return{'model':db[_0x127238['model']],'as':_0x127238['as'],'attributes':_0x127238['attributes']};}):[]};}):[]};}):[]:[]})[_0xf764('0xd')](function(_0x38e19a){logger[_0xf764('0xe')](_0xf764('0x22'),_0x6813a4);logger[_0xf764('0x11')](_0xf764('0x22'),_0x6813a4,JSON[_0xf764('0x13')](_0x38e19a));_0x3a645c(_0x38e19a);})[_0xf764('0x16')](function(_0x3bdaeb){logger[_0xf764('0x14')]('ShowDeskAccount',_0x3bdaeb[_0xf764('0x15')],_0x6813a4);_0x58c5e5(_0x15a8c7['error'](0x1f4,_0x3bdaeb[_0xf764('0x15')]));});});};