Built motion from commit 746c7d2a.|2.5.35
[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 _0xfbf7=['where','limit','map','include','model','attributes','GetDeskAccount','ShowDeskAccount','find','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','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'];(function(_0x1734e9,_0x14bfe2){var _0x22e31f=function(_0x3e7c1a){while(--_0x3e7c1a){_0x1734e9['push'](_0x1734e9['shift']());}};_0x22e31f(++_0x14bfe2);}(_0xfbf7,0xf3));var _0x7fbf=function(_0x38eec6,_0x5a7765){_0x38eec6=_0x38eec6-0x0;var _0x558819=_0xfbf7[_0x38eec6];return _0x558819;};'use strict';var _=require(_0x7fbf('0x0'));var util=require(_0x7fbf('0x1'));var moment=require(_0x7fbf('0x2'));var BPromise=require(_0x7fbf('0x3'));var rs=require(_0x7fbf('0x4'));var fs=require('fs');var Redis=require(_0x7fbf('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x7fbf('0x6'));var logger=require(_0x7fbf('0x7'))(_0x7fbf('0x8'));var config=require(_0x7fbf('0x9'));var jayson=require(_0x7fbf('0xa'));var client=jayson[_0x7fbf('0xb')][_0x7fbf('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x3025c2,_0x520309,_0x18d71c){return new BPromise(function(_0x5991b5,_0x286e01){return client[_0x7fbf('0xd')](_0x3025c2,_0x18d71c)[_0x7fbf('0xe')](function(_0x1fced3){logger[_0x7fbf('0xf')](_0x7fbf('0x10'),_0x520309,_0x7fbf('0x11'));logger[_0x7fbf('0x12')](_0x7fbf('0x13'),_0x520309,_0x7fbf('0x11'),JSON[_0x7fbf('0x14')](_0x1fced3));if(_0x1fced3[_0x7fbf('0x15')]){if(_0x1fced3[_0x7fbf('0x15')][_0x7fbf('0x16')]===0x1f4){logger[_0x7fbf('0x15')](_0x7fbf('0x10'),_0x520309,_0x1fced3[_0x7fbf('0x15')][_0x7fbf('0x17')]);return _0x286e01(_0x1fced3[_0x7fbf('0x15')][_0x7fbf('0x17')]);}logger['error'](_0x7fbf('0x10'),_0x520309,_0x1fced3[_0x7fbf('0x15')][_0x7fbf('0x17')]);return _0x5991b5(_0x1fced3[_0x7fbf('0x15')][_0x7fbf('0x17')]);}else{logger['info'](_0x7fbf('0x10'),_0x520309,_0x7fbf('0x11'));_0x5991b5(_0x1fced3[_0x7fbf('0x18')]['message']);}})[_0x7fbf('0x19')](function(_0x4ffa7e){logger[_0x7fbf('0x15')](_0x7fbf('0x10'),_0x520309,_0x4ffa7e);_0x286e01(_0x4ffa7e);});});}exports['GetDeskAccount']=function(_0x3a678b){var _0x2f5ac9=this;return new Promise(function(_0x22cdc0,_0x58cf13){return db[_0x7fbf('0x1a')][_0x7fbf('0x1b')]({'raw':_0x3a678b[_0x7fbf('0x1c')]?_0x3a678b['options'][_0x7fbf('0x1d')]===undefined?!![]:![]:!![],'where':_0x3a678b[_0x7fbf('0x1c')]?_0x3a678b[_0x7fbf('0x1c')][_0x7fbf('0x1e')]||null:null,'attributes':_0x3a678b[_0x7fbf('0x1c')]?_0x3a678b['options']['attributes']||null:null,'limit':_0x3a678b[_0x7fbf('0x1c')]?_0x3a678b[_0x7fbf('0x1c')][_0x7fbf('0x1f')]||null:null,'include':_0x3a678b[_0x7fbf('0x1c')]?_0x3a678b[_0x7fbf('0x1c')]['include']?_[_0x7fbf('0x20')](_0x3a678b['options'][_0x7fbf('0x21')],function(_0x37c7cc){return{'model':db[_0x37c7cc[_0x7fbf('0x22')]],'as':_0x37c7cc['as'],'attributes':_0x37c7cc[_0x7fbf('0x23')],'include':_0x37c7cc[_0x7fbf('0x21')]?_[_0x7fbf('0x20')](_0x37c7cc[_0x7fbf('0x21')],function(_0x10b18f){return{'model':db[_0x10b18f[_0x7fbf('0x22')]],'as':_0x10b18f['as'],'attributes':_0x10b18f[_0x7fbf('0x23')],'include':_0x10b18f[_0x7fbf('0x21')]?_[_0x7fbf('0x20')](_0x10b18f[_0x7fbf('0x21')],function(_0x5d62b9){return{'model':db[_0x5d62b9[_0x7fbf('0x22')]],'as':_0x5d62b9['as'],'attributes':_0x5d62b9['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x4bc501){logger[_0x7fbf('0xf')]('GetDeskAccount',_0x3a678b);logger[_0x7fbf('0x12')]('GetDeskAccount',_0x3a678b,JSON[_0x7fbf('0x14')](_0x4bc501));_0x22cdc0(_0x4bc501);})['catch'](function(_0x2235e1){logger[_0x7fbf('0x15')](_0x7fbf('0x24'),_0x2235e1['message'],_0x3a678b);_0x58cf13(_0x2f5ac9[_0x7fbf('0x15')](0x1f4,_0x2235e1[_0x7fbf('0x17')]));});});};exports[_0x7fbf('0x25')]=function(_0x503d87){var _0x589975=this;return new Promise(function(_0x475732,_0x831225){return db[_0x7fbf('0x1a')][_0x7fbf('0x26')]({'raw':_0x503d87[_0x7fbf('0x1c')]?_0x503d87[_0x7fbf('0x1c')][_0x7fbf('0x1d')]===undefined?!![]:![]:!![],'where':_0x503d87[_0x7fbf('0x1c')]?_0x503d87[_0x7fbf('0x1c')][_0x7fbf('0x1e')]||null:null,'attributes':_0x503d87[_0x7fbf('0x1c')]?_0x503d87[_0x7fbf('0x1c')][_0x7fbf('0x23')]||null:null,'include':_0x503d87[_0x7fbf('0x1c')]?_0x503d87['options']['include']?_[_0x7fbf('0x20')](_0x503d87[_0x7fbf('0x1c')][_0x7fbf('0x21')],function(_0x21637b){return{'model':db[_0x21637b[_0x7fbf('0x22')]],'as':_0x21637b['as'],'attributes':_0x21637b[_0x7fbf('0x23')],'include':_0x21637b[_0x7fbf('0x21')]?_[_0x7fbf('0x20')](_0x21637b['include'],function(_0x55ba75){return{'model':db[_0x55ba75[_0x7fbf('0x22')]],'as':_0x55ba75['as'],'attributes':_0x55ba75[_0x7fbf('0x23')],'include':_0x55ba75[_0x7fbf('0x21')]?_[_0x7fbf('0x20')](_0x55ba75[_0x7fbf('0x21')],function(_0x205833){return{'model':db[_0x205833[_0x7fbf('0x22')]],'as':_0x205833['as'],'attributes':_0x205833[_0x7fbf('0x23')]};}):[]};}):[]};}):[]:[]})[_0x7fbf('0xe')](function(_0x3ac939){logger['info'](_0x7fbf('0x25'),_0x503d87);logger[_0x7fbf('0x12')](_0x7fbf('0x25'),_0x503d87,JSON[_0x7fbf('0x14')](_0x3ac939));_0x475732(_0x3ac939);})[_0x7fbf('0x19')](function(_0x416bb0){logger[_0x7fbf('0x15')](_0x7fbf('0x25'),_0x416bb0[_0x7fbf('0x17')],_0x503d87);_0x831225(_0x589975[_0x7fbf('0x15')](0x1f4,_0x416bb0[_0x7fbf('0x17')]));});});};