Built motion from commit 85328c08.|2.5.50
[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 _0x4ffb=['info','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','VoiceQueue','findAll','options','where','include','map','model','attributes','then','GetVoiceQueue','ShowVoiceQueue','find','raw','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter'];(function(_0x58e9b8,_0x402cfa){var _0x5caa62=function(_0x4af6d0){while(--_0x4af6d0){_0x58e9b8['push'](_0x58e9b8['shift']());}};_0x5caa62(++_0x402cfa);}(_0x4ffb,0x16d));var _0xb4ff=function(_0x1a08ad,_0x21d209){_0x1a08ad=_0x1a08ad-0x0;var _0x521649=_0x4ffb[_0x1a08ad];return _0x521649;};'use strict';var _=require(_0xb4ff('0x0'));var util=require(_0xb4ff('0x1'));var moment=require('moment');var BPromise=require(_0xb4ff('0x2'));var rs=require(_0xb4ff('0x3'));var fs=require('fs');var Redis=require(_0xb4ff('0x4'));var db=require(_0xb4ff('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xb4ff('0x6'))(_0xb4ff('0x7'));var config=require(_0xb4ff('0x8'));var jayson=require(_0xb4ff('0x9'));var client=jayson[_0xb4ff('0xa')][_0xb4ff('0xb')]({'port':0x232a});config[_0xb4ff('0xc')]=_[_0xb4ff('0xd')](config[_0xb4ff('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xb4ff('0xe'))(new Redis(config[_0xb4ff('0xc')]));require('./voiceQueue.socket')['register'](socket);function respondWithRpcPromise(_0xc20797,_0x34ed94,_0x5a6479){return new BPromise(function(_0xc75975,_0x30197e){return client['request'](_0xc20797,_0x5a6479)['then'](function(_0x58d555){logger[_0xb4ff('0xf')](_0xb4ff('0x10'),_0x34ed94,_0xb4ff('0x11'));logger[_0xb4ff('0x12')](_0xb4ff('0x13'),_0x34ed94,_0xb4ff('0x11'),JSON[_0xb4ff('0x14')](_0x58d555));if(_0x58d555['error']){if(_0x58d555[_0xb4ff('0x15')][_0xb4ff('0x16')]===0x1f4){logger['error'](_0xb4ff('0x10'),_0x34ed94,_0x58d555[_0xb4ff('0x15')]['message']);return _0x30197e(_0x58d555['error'][_0xb4ff('0x17')]);}logger[_0xb4ff('0x15')](_0xb4ff('0x10'),_0x34ed94,_0x58d555[_0xb4ff('0x15')][_0xb4ff('0x17')]);return _0xc75975(_0x58d555['error']['message']);}else{logger[_0xb4ff('0xf')](_0xb4ff('0x10'),_0x34ed94,_0xb4ff('0x11'));_0xc75975(_0x58d555['result'][_0xb4ff('0x17')]);}})[_0xb4ff('0x18')](function(_0x3f75f3){logger['error'](_0xb4ff('0x10'),_0x34ed94,_0x3f75f3);_0x30197e(_0x3f75f3);});});}exports['GetVoiceQueue']=function(_0x1c0a23){var _0x4a07f8=this;return new Promise(function(_0x5ad11b,_0x552c06){return db[_0xb4ff('0x19')][_0xb4ff('0x1a')]({'raw':_0x1c0a23['options']?_0x1c0a23[_0xb4ff('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x1c0a23[_0xb4ff('0x1b')]?_0x1c0a23[_0xb4ff('0x1b')][_0xb4ff('0x1c')]||null:null,'attributes':_0x1c0a23[_0xb4ff('0x1b')]?_0x1c0a23[_0xb4ff('0x1b')]['attributes']||null:null,'limit':_0x1c0a23[_0xb4ff('0x1b')]?_0x1c0a23[_0xb4ff('0x1b')]['limit']||null:null,'include':_0x1c0a23['options']?_0x1c0a23['options'][_0xb4ff('0x1d')]?_[_0xb4ff('0x1e')](_0x1c0a23[_0xb4ff('0x1b')][_0xb4ff('0x1d')],function(_0x5bfddb){return{'model':db[_0x5bfddb[_0xb4ff('0x1f')]],'as':_0x5bfddb['as'],'attributes':_0x5bfddb['attributes'],'include':_0x5bfddb[_0xb4ff('0x1d')]?_[_0xb4ff('0x1e')](_0x5bfddb[_0xb4ff('0x1d')],function(_0x80926c){return{'model':db[_0x80926c['model']],'as':_0x80926c['as'],'attributes':_0x80926c[_0xb4ff('0x20')],'include':_0x80926c[_0xb4ff('0x1d')]?_['map'](_0x80926c['include'],function(_0x8e043a){return{'model':db[_0x8e043a[_0xb4ff('0x1f')]],'as':_0x8e043a['as'],'attributes':_0x8e043a[_0xb4ff('0x20')]};}):[]};}):[]};}):[]:[]})[_0xb4ff('0x21')](function(_0x4153a0){logger[_0xb4ff('0xf')]('GetVoiceQueue',_0x1c0a23);logger[_0xb4ff('0x12')](_0xb4ff('0x22'),_0x1c0a23,JSON['stringify'](_0x4153a0));_0x5ad11b(_0x4153a0);})[_0xb4ff('0x18')](function(_0x4c5b5d){logger[_0xb4ff('0x15')](_0xb4ff('0x22'),_0x4c5b5d[_0xb4ff('0x17')],_0x1c0a23);_0x552c06(_0x4a07f8['error'](0x1f4,_0x4c5b5d[_0xb4ff('0x17')]));});});};exports[_0xb4ff('0x23')]=function(_0x4b8650){var _0x38df1d=this;return new Promise(function(_0x2bfb46,_0x555a23){return db[_0xb4ff('0x19')][_0xb4ff('0x24')]({'raw':_0x4b8650[_0xb4ff('0x1b')]?_0x4b8650['options'][_0xb4ff('0x25')]===undefined?!![]:![]:!![],'where':_0x4b8650[_0xb4ff('0x1b')]?_0x4b8650[_0xb4ff('0x1b')][_0xb4ff('0x1c')]||null:null,'attributes':_0x4b8650[_0xb4ff('0x1b')]?_0x4b8650[_0xb4ff('0x1b')]['attributes']||null:null,'include':_0x4b8650[_0xb4ff('0x1b')]?_0x4b8650[_0xb4ff('0x1b')]['include']?_[_0xb4ff('0x1e')](_0x4b8650[_0xb4ff('0x1b')]['include'],function(_0x2524eb){return{'model':db[_0x2524eb['model']],'as':_0x2524eb['as'],'attributes':_0x2524eb[_0xb4ff('0x20')],'include':_0x2524eb[_0xb4ff('0x1d')]?_[_0xb4ff('0x1e')](_0x2524eb['include'],function(_0x5e2e6d){return{'model':db[_0x5e2e6d['model']],'as':_0x5e2e6d['as'],'attributes':_0x5e2e6d[_0xb4ff('0x20')],'include':_0x5e2e6d['include']?_[_0xb4ff('0x1e')](_0x5e2e6d[_0xb4ff('0x1d')],function(_0x37fdd4){return{'model':db[_0x37fdd4['model']],'as':_0x37fdd4['as'],'attributes':_0x37fdd4[_0xb4ff('0x20')]};}):[]};}):[]};}):[]:[]})[_0xb4ff('0x21')](function(_0x590c98){logger['info']('ShowVoiceQueue',_0x4b8650);logger[_0xb4ff('0x12')]('ShowVoiceQueue',_0x4b8650,JSON[_0xb4ff('0x14')](_0x590c98));_0x2bfb46(_0x590c98);})[_0xb4ff('0x18')](function(_0x20d7f4){logger[_0xb4ff('0x15')](_0xb4ff('0x23'),_0x20d7f4['message'],_0x4b8650);_0x555a23(_0x38df1d['error'](0x1f4,_0x20d7f4[_0xb4ff('0x17')]));});});};