Built motion from commit (unavailable).|2.5.31
[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 _0xa275=['model','ShowDeskAccount','catch','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','then','info','DeskAccount,\x20%s,\x20%s','request\x20sent','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','GetDeskAccount','findAll','options','raw','where','attributes','limit','include','map'];(function(_0x373649,_0x53c05f){var _0x5c7fc8=function(_0x595bd9){while(--_0x595bd9){_0x373649['push'](_0x373649['shift']());}};_0x5c7fc8(++_0x53c05f);}(_0xa275,0xc3));var _0x5a27=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0xa275[_0x57b54c];return _0x59cc19;};'use strict';var _=require('lodash');var util=require(_0x5a27('0x0'));var moment=require(_0x5a27('0x1'));var BPromise=require(_0x5a27('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5a27('0x3'));var db=require(_0x5a27('0x4'))['db'];var utils=require(_0x5a27('0x5'));var logger=require(_0x5a27('0x6'))(_0x5a27('0x7'));var config=require('../../config/environment');var jayson=require(_0x5a27('0x8'));var client=jayson['client'][_0x5a27('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x62508f,_0x26c3ea,_0x304dfd){return new BPromise(function(_0x5f0ec6,_0x56b319){return client['request'](_0x62508f,_0x304dfd)[_0x5a27('0xa')](function(_0x6f7e14){logger[_0x5a27('0xb')](_0x5a27('0xc'),_0x26c3ea,_0x5a27('0xd'));logger[_0x5a27('0xe')](_0x5a27('0xf'),_0x26c3ea,_0x5a27('0xd'),JSON[_0x5a27('0x10')](_0x6f7e14));if(_0x6f7e14['error']){if(_0x6f7e14[_0x5a27('0x11')][_0x5a27('0x12')]===0x1f4){logger['error']('DeskAccount,\x20%s,\x20%s',_0x26c3ea,_0x6f7e14['error'][_0x5a27('0x13')]);return _0x56b319(_0x6f7e14[_0x5a27('0x11')][_0x5a27('0x13')]);}logger[_0x5a27('0x11')]('DeskAccount,\x20%s,\x20%s',_0x26c3ea,_0x6f7e14[_0x5a27('0x11')][_0x5a27('0x13')]);return _0x5f0ec6(_0x6f7e14[_0x5a27('0x11')][_0x5a27('0x13')]);}else{logger[_0x5a27('0xb')](_0x5a27('0xc'),_0x26c3ea,_0x5a27('0xd'));_0x5f0ec6(_0x6f7e14['result']['message']);}})['catch'](function(_0xf4a062){logger[_0x5a27('0x11')](_0x5a27('0xc'),_0x26c3ea,_0xf4a062);_0x56b319(_0xf4a062);});});}exports[_0x5a27('0x14')]=function(_0x41a58c){var _0x341687=this;return new Promise(function(_0x1212f2,_0x26af47){return db['DeskAccount'][_0x5a27('0x15')]({'raw':_0x41a58c['options']?_0x41a58c[_0x5a27('0x16')][_0x5a27('0x17')]===undefined?!![]:![]:!![],'where':_0x41a58c[_0x5a27('0x16')]?_0x41a58c[_0x5a27('0x16')][_0x5a27('0x18')]||null:null,'attributes':_0x41a58c['options']?_0x41a58c[_0x5a27('0x16')][_0x5a27('0x19')]||null:null,'limit':_0x41a58c[_0x5a27('0x16')]?_0x41a58c['options'][_0x5a27('0x1a')]||null:null,'include':_0x41a58c[_0x5a27('0x16')]?_0x41a58c[_0x5a27('0x16')][_0x5a27('0x1b')]?_[_0x5a27('0x1c')](_0x41a58c['options']['include'],function(_0x29203b){return{'model':db[_0x29203b[_0x5a27('0x1d')]],'as':_0x29203b['as'],'attributes':_0x29203b[_0x5a27('0x19')],'include':_0x29203b[_0x5a27('0x1b')]?_[_0x5a27('0x1c')](_0x29203b['include'],function(_0x3aa217){return{'model':db[_0x3aa217[_0x5a27('0x1d')]],'as':_0x3aa217['as'],'attributes':_0x3aa217['attributes'],'include':_0x3aa217[_0x5a27('0x1b')]?_['map'](_0x3aa217['include'],function(_0x15139c){return{'model':db[_0x15139c[_0x5a27('0x1d')]],'as':_0x15139c['as'],'attributes':_0x15139c[_0x5a27('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5be038){logger[_0x5a27('0xb')](_0x5a27('0x14'),_0x41a58c);logger[_0x5a27('0xe')]('GetDeskAccount',_0x41a58c,JSON[_0x5a27('0x10')](_0x5be038));_0x1212f2(_0x5be038);})['catch'](function(_0x37c915){logger[_0x5a27('0x11')](_0x5a27('0x14'),_0x37c915[_0x5a27('0x13')],_0x41a58c);_0x26af47(_0x341687[_0x5a27('0x11')](0x1f4,_0x37c915[_0x5a27('0x13')]));});});};exports[_0x5a27('0x1e')]=function(_0x19bc74){var _0x23a89e=this;return new Promise(function(_0x3bfab0,_0x4be6c2){return db['DeskAccount']['find']({'raw':_0x19bc74[_0x5a27('0x16')]?_0x19bc74[_0x5a27('0x16')][_0x5a27('0x17')]===undefined?!![]:![]:!![],'where':_0x19bc74['options']?_0x19bc74[_0x5a27('0x16')][_0x5a27('0x18')]||null:null,'attributes':_0x19bc74[_0x5a27('0x16')]?_0x19bc74[_0x5a27('0x16')][_0x5a27('0x19')]||null:null,'include':_0x19bc74['options']?_0x19bc74[_0x5a27('0x16')][_0x5a27('0x1b')]?_[_0x5a27('0x1c')](_0x19bc74[_0x5a27('0x16')][_0x5a27('0x1b')],function(_0x8508e8){return{'model':db[_0x8508e8[_0x5a27('0x1d')]],'as':_0x8508e8['as'],'attributes':_0x8508e8[_0x5a27('0x19')],'include':_0x8508e8[_0x5a27('0x1b')]?_[_0x5a27('0x1c')](_0x8508e8[_0x5a27('0x1b')],function(_0x4e9a39){return{'model':db[_0x4e9a39[_0x5a27('0x1d')]],'as':_0x4e9a39['as'],'attributes':_0x4e9a39['attributes'],'include':_0x4e9a39[_0x5a27('0x1b')]?_['map'](_0x4e9a39[_0x5a27('0x1b')],function(_0x5b8ef4){return{'model':db[_0x5b8ef4['model']],'as':_0x5b8ef4['as'],'attributes':_0x5b8ef4['attributes']};}):[]};}):[]};}):[]:[]})[_0x5a27('0xa')](function(_0x5555c8){logger['info'](_0x5a27('0x1e'),_0x19bc74);logger['debug'](_0x5a27('0x1e'),_0x19bc74,JSON[_0x5a27('0x10')](_0x5555c8));_0x3bfab0(_0x5555c8);})[_0x5a27('0x1f')](function(_0x5e863b){logger[_0x5a27('0x11')](_0x5a27('0x1e'),_0x5e863b['message'],_0x19bc74);_0x4be6c2(_0x23a89e[_0x5a27('0x11')](0x1f4,_0x5e863b['message']));});});};