9b575cd81619fbeeddcf6bffece82fc346ff7669
[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 _0xb8fd=['stringify','error','message','catch','findAll','options','raw','where','attributes','limit','include','map','model','GetDeskAccount','ShowDeskAccount','DeskAccount','find','lodash','moment','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','then','info','DeskAccount,\x20%s,\x20%s','debug','DeskAccount,\x20%s,\x20%s,\x20%s','request\x20sent'];(function(_0x46094e,_0x4396c1){var _0x4ee7c7=function(_0x2aefef){while(--_0x2aefef){_0x46094e['push'](_0x46094e['shift']());}};_0x4ee7c7(++_0x4396c1);}(_0xb8fd,0x119));var _0xdb8f=function(_0x32e2f7,_0x405470){_0x32e2f7=_0x32e2f7-0x0;var _0x4cad61=_0xb8fd[_0x32e2f7];return _0x4cad61;};'use strict';var _=require(_0xdb8f('0x0'));var util=require('util');var moment=require(_0xdb8f('0x1'));var BPromise=require('bluebird');var rs=require(_0xdb8f('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xdb8f('0x3'))['db'];var utils=require(_0xdb8f('0x4'));var logger=require(_0xdb8f('0x5'))(_0xdb8f('0x6'));var config=require('../../config/environment');var jayson=require(_0xdb8f('0x7'));var client=jayson[_0xdb8f('0x8')][_0xdb8f('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x166490,_0x35fbe5,_0x42e8cd){return new BPromise(function(_0x3c1329,_0x1889da){return client['request'](_0x166490,_0x42e8cd)[_0xdb8f('0xa')](function(_0x2762ea){logger[_0xdb8f('0xb')](_0xdb8f('0xc'),_0x35fbe5,'request\x20sent');logger[_0xdb8f('0xd')](_0xdb8f('0xe'),_0x35fbe5,_0xdb8f('0xf'),JSON[_0xdb8f('0x10')](_0x2762ea));if(_0x2762ea['error']){if(_0x2762ea[_0xdb8f('0x11')]['code']===0x1f4){logger[_0xdb8f('0x11')](_0xdb8f('0xc'),_0x35fbe5,_0x2762ea[_0xdb8f('0x11')][_0xdb8f('0x12')]);return _0x1889da(_0x2762ea[_0xdb8f('0x11')][_0xdb8f('0x12')]);}logger['error']('DeskAccount,\x20%s,\x20%s',_0x35fbe5,_0x2762ea['error'][_0xdb8f('0x12')]);return _0x3c1329(_0x2762ea[_0xdb8f('0x11')][_0xdb8f('0x12')]);}else{logger[_0xdb8f('0xb')](_0xdb8f('0xc'),_0x35fbe5,_0xdb8f('0xf'));_0x3c1329(_0x2762ea['result']['message']);}})[_0xdb8f('0x13')](function(_0x17d855){logger['error']('DeskAccount,\x20%s,\x20%s',_0x35fbe5,_0x17d855);_0x1889da(_0x17d855);});});}exports['GetDeskAccount']=function(_0x1b2582){var _0x28f9d7=this;return new Promise(function(_0xdc12df,_0x3e373e){return db['DeskAccount'][_0xdb8f('0x14')]({'raw':_0x1b2582[_0xdb8f('0x15')]?_0x1b2582[_0xdb8f('0x15')][_0xdb8f('0x16')]===undefined?!![]:![]:!![],'where':_0x1b2582[_0xdb8f('0x15')]?_0x1b2582[_0xdb8f('0x15')][_0xdb8f('0x17')]||null:null,'attributes':_0x1b2582[_0xdb8f('0x15')]?_0x1b2582['options'][_0xdb8f('0x18')]||null:null,'limit':_0x1b2582[_0xdb8f('0x15')]?_0x1b2582[_0xdb8f('0x15')][_0xdb8f('0x19')]||null:null,'include':_0x1b2582[_0xdb8f('0x15')]?_0x1b2582[_0xdb8f('0x15')][_0xdb8f('0x1a')]?_[_0xdb8f('0x1b')](_0x1b2582[_0xdb8f('0x15')]['include'],function(_0x1eb30e){return{'model':db[_0x1eb30e[_0xdb8f('0x1c')]],'as':_0x1eb30e['as'],'attributes':_0x1eb30e[_0xdb8f('0x18')],'include':_0x1eb30e['include']?_[_0xdb8f('0x1b')](_0x1eb30e['include'],function(_0x34991c){return{'model':db[_0x34991c[_0xdb8f('0x1c')]],'as':_0x34991c['as'],'attributes':_0x34991c[_0xdb8f('0x18')],'include':_0x34991c[_0xdb8f('0x1a')]?_[_0xdb8f('0x1b')](_0x34991c['include'],function(_0x23328c){return{'model':db[_0x23328c[_0xdb8f('0x1c')]],'as':_0x23328c['as'],'attributes':_0x23328c[_0xdb8f('0x18')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x64258b){logger['info'](_0xdb8f('0x1d'),_0x1b2582);logger['debug']('GetDeskAccount',_0x1b2582,JSON[_0xdb8f('0x10')](_0x64258b));_0xdc12df(_0x64258b);})[_0xdb8f('0x13')](function(_0x581614){logger[_0xdb8f('0x11')](_0xdb8f('0x1d'),_0x581614[_0xdb8f('0x12')],_0x1b2582);_0x3e373e(_0x28f9d7['error'](0x1f4,_0x581614['message']));});});};exports[_0xdb8f('0x1e')]=function(_0x28d8cb){var _0x297a7b=this;return new Promise(function(_0x16b760,_0x33f55a){return db[_0xdb8f('0x1f')][_0xdb8f('0x20')]({'raw':_0x28d8cb[_0xdb8f('0x15')]?_0x28d8cb[_0xdb8f('0x15')][_0xdb8f('0x16')]===undefined?!![]:![]:!![],'where':_0x28d8cb[_0xdb8f('0x15')]?_0x28d8cb[_0xdb8f('0x15')][_0xdb8f('0x17')]||null:null,'attributes':_0x28d8cb[_0xdb8f('0x15')]?_0x28d8cb[_0xdb8f('0x15')]['attributes']||null:null,'include':_0x28d8cb[_0xdb8f('0x15')]?_0x28d8cb['options']['include']?_[_0xdb8f('0x1b')](_0x28d8cb[_0xdb8f('0x15')]['include'],function(_0x2f45c6){return{'model':db[_0x2f45c6[_0xdb8f('0x1c')]],'as':_0x2f45c6['as'],'attributes':_0x2f45c6[_0xdb8f('0x18')],'include':_0x2f45c6['include']?_[_0xdb8f('0x1b')](_0x2f45c6['include'],function(_0x1816a2){return{'model':db[_0x1816a2[_0xdb8f('0x1c')]],'as':_0x1816a2['as'],'attributes':_0x1816a2[_0xdb8f('0x18')],'include':_0x1816a2[_0xdb8f('0x1a')]?_[_0xdb8f('0x1b')](_0x1816a2[_0xdb8f('0x1a')],function(_0x4058da){return{'model':db[_0x4058da[_0xdb8f('0x1c')]],'as':_0x4058da['as'],'attributes':_0x4058da[_0xdb8f('0x18')]};}):[]};}):[]};}):[]:[]})[_0xdb8f('0xa')](function(_0x1f0e42){logger[_0xdb8f('0xb')](_0xdb8f('0x1e'),_0x28d8cb);logger[_0xdb8f('0xd')](_0xdb8f('0x1e'),_0x28d8cb,JSON[_0xdb8f('0x10')](_0x1f0e42));_0x16b760(_0x1f0e42);})[_0xdb8f('0x13')](function(_0x526f36){logger[_0xdb8f('0x11')]('ShowDeskAccount',_0x526f36[_0xdb8f('0x12')],_0x28d8cb);_0x33f55a(_0x297a7b['error'](0x1f4,_0x526f36[_0xdb8f('0x12')]));});});};