8cae9ecd7e95a4d2326ef26b2c2282c9452662a7
[motion2.git] / server / api / voiceQueue / voiceQueue.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 _0x5cb3=['attributes','limit','include','map','model','then','GetVoiceQueue','ShowVoiceQueue','raw','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./voiceQueue.socket','request','info','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','VoiceQueue,\x20%s,\x20%s','message','result','catch','VoiceQueue','findAll','options','where'];(function(_0x400881,_0x313460){var _0x27c2c4=function(_0x3fa340){while(--_0x3fa340){_0x400881['push'](_0x400881['shift']());}};_0x27c2c4(++_0x313460);}(_0x5cb3,0x128));var _0x35cb=function(_0x542ea5,_0x405542){_0x542ea5=_0x542ea5-0x0;var _0x4dc38c=_0x5cb3[_0x542ea5];return _0x4dc38c;};'use strict';var _=require('lodash');var util=require(_0x35cb('0x0'));var moment=require(_0x35cb('0x1'));var BPromise=require(_0x35cb('0x2'));var rs=require(_0x35cb('0x3'));var fs=require('fs');var Redis=require(_0x35cb('0x4'));var db=require(_0x35cb('0x5'))['db'];var utils=require(_0x35cb('0x6'));var logger=require(_0x35cb('0x7'))(_0x35cb('0x8'));var config=require(_0x35cb('0x9'));var jayson=require(_0x35cb('0xa'));var client=jayson['client'][_0x35cb('0xb')]({'port':0x232a});config[_0x35cb('0xc')]=_['defaults'](config[_0x35cb('0xc')],{'host':_0x35cb('0xd'),'port':0x18eb});var socket=require(_0x35cb('0xe'))(new Redis(config[_0x35cb('0xc')]));require(_0x35cb('0xf'))['register'](socket);function respondWithRpcPromise(_0x253bc8,_0x34bdc9,_0xba47ec){return new BPromise(function(_0x2ae3b3,_0x37d529){return client[_0x35cb('0x10')](_0x253bc8,_0xba47ec)['then'](function(_0xa6243b){logger[_0x35cb('0x11')]('VoiceQueue,\x20%s,\x20%s',_0x34bdc9,_0x35cb('0x12'));logger[_0x35cb('0x13')](_0x35cb('0x14'),_0x34bdc9,_0x35cb('0x12'),JSON[_0x35cb('0x15')](_0xa6243b));if(_0xa6243b[_0x35cb('0x16')]){if(_0xa6243b[_0x35cb('0x16')][_0x35cb('0x17')]===0x1f4){logger[_0x35cb('0x16')](_0x35cb('0x18'),_0x34bdc9,_0xa6243b[_0x35cb('0x16')][_0x35cb('0x19')]);return _0x37d529(_0xa6243b[_0x35cb('0x16')][_0x35cb('0x19')]);}logger[_0x35cb('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x34bdc9,_0xa6243b[_0x35cb('0x16')]['message']);return _0x2ae3b3(_0xa6243b[_0x35cb('0x16')][_0x35cb('0x19')]);}else{logger[_0x35cb('0x11')](_0x35cb('0x18'),_0x34bdc9,'request\x20sent');_0x2ae3b3(_0xa6243b[_0x35cb('0x1a')][_0x35cb('0x19')]);}})[_0x35cb('0x1b')](function(_0x47cf27){logger['error'](_0x35cb('0x18'),_0x34bdc9,_0x47cf27);_0x37d529(_0x47cf27);});});}exports['GetVoiceQueue']=function(_0x3acd14){var _0x5d8ef1=this;return new Promise(function(_0x5f3f7a,_0x569a8d){return db[_0x35cb('0x1c')][_0x35cb('0x1d')]({'raw':_0x3acd14[_0x35cb('0x1e')]?_0x3acd14[_0x35cb('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x3acd14['options']?_0x3acd14['options'][_0x35cb('0x1f')]||null:null,'attributes':_0x3acd14[_0x35cb('0x1e')]?_0x3acd14['options'][_0x35cb('0x20')]||null:null,'limit':_0x3acd14['options']?_0x3acd14['options'][_0x35cb('0x21')]||null:null,'include':_0x3acd14[_0x35cb('0x1e')]?_0x3acd14[_0x35cb('0x1e')][_0x35cb('0x22')]?_['map'](_0x3acd14[_0x35cb('0x1e')][_0x35cb('0x22')],function(_0x43fced){return{'model':db[_0x43fced['model']],'as':_0x43fced['as'],'attributes':_0x43fced[_0x35cb('0x20')],'include':_0x43fced[_0x35cb('0x22')]?_[_0x35cb('0x23')](_0x43fced[_0x35cb('0x22')],function(_0xc01139){return{'model':db[_0xc01139[_0x35cb('0x24')]],'as':_0xc01139['as'],'attributes':_0xc01139[_0x35cb('0x20')],'include':_0xc01139[_0x35cb('0x22')]?_['map'](_0xc01139[_0x35cb('0x22')],function(_0x57b8a0){return{'model':db[_0x57b8a0['model']],'as':_0x57b8a0['as'],'attributes':_0x57b8a0[_0x35cb('0x20')]};}):[]};}):[]};}):[]:[]})[_0x35cb('0x25')](function(_0x10a48e){logger['info']('GetVoiceQueue',_0x3acd14);logger[_0x35cb('0x13')]('GetVoiceQueue',_0x3acd14,JSON['stringify'](_0x10a48e));_0x5f3f7a(_0x10a48e);})['catch'](function(_0x4e78d0){logger[_0x35cb('0x16')](_0x35cb('0x26'),_0x4e78d0[_0x35cb('0x19')],_0x3acd14);_0x569a8d(_0x5d8ef1['error'](0x1f4,_0x4e78d0[_0x35cb('0x19')]));});});};exports[_0x35cb('0x27')]=function(_0x39ca21){var _0x26b861=this;return new Promise(function(_0x583a72,_0x158f85){return db[_0x35cb('0x1c')]['find']({'raw':_0x39ca21['options']?_0x39ca21[_0x35cb('0x1e')][_0x35cb('0x28')]===undefined?!![]:![]:!![],'where':_0x39ca21[_0x35cb('0x1e')]?_0x39ca21['options'][_0x35cb('0x1f')]||null:null,'attributes':_0x39ca21[_0x35cb('0x1e')]?_0x39ca21[_0x35cb('0x1e')][_0x35cb('0x20')]||null:null,'include':_0x39ca21[_0x35cb('0x1e')]?_0x39ca21[_0x35cb('0x1e')][_0x35cb('0x22')]?_[_0x35cb('0x23')](_0x39ca21[_0x35cb('0x1e')][_0x35cb('0x22')],function(_0x177c64){return{'model':db[_0x177c64[_0x35cb('0x24')]],'as':_0x177c64['as'],'attributes':_0x177c64[_0x35cb('0x20')],'include':_0x177c64['include']?_[_0x35cb('0x23')](_0x177c64[_0x35cb('0x22')],function(_0x591a5a){return{'model':db[_0x591a5a[_0x35cb('0x24')]],'as':_0x591a5a['as'],'attributes':_0x591a5a[_0x35cb('0x20')],'include':_0x591a5a['include']?_[_0x35cb('0x23')](_0x591a5a[_0x35cb('0x22')],function(_0x18730c){return{'model':db[_0x18730c[_0x35cb('0x24')]],'as':_0x18730c['as'],'attributes':_0x18730c[_0x35cb('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3fe996){logger['info'](_0x35cb('0x27'),_0x39ca21);logger[_0x35cb('0x13')](_0x35cb('0x27'),_0x39ca21,JSON[_0x35cb('0x15')](_0x3fe996));_0x583a72(_0x3fe996);})[_0x35cb('0x1b')](function(_0x4bfd73){logger[_0x35cb('0x16')]('ShowVoiceQueue',_0x4bfd73['message'],_0x39ca21);_0x158f85(_0x26b861[_0x35cb('0x16')](0x1f4,_0x4bfd73['message']));});});};