Built motion from commit (unavailable).|2.5.11
[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 _0x274f=['socket.io-emitter','register','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','VoiceQueue','findAll','options','raw','include','map','model','attributes','debug','GetVoiceQueue','catch','ShowVoiceQueue','find','where','randomstring','../../config/utils','../../config/logger','../../config/environment','client','http','defaults','redis','localhost'];(function(_0x19cf1f,_0x4105e3){var _0x234028=function(_0x24748c){while(--_0x24748c){_0x19cf1f['push'](_0x19cf1f['shift']());}};_0x234028(++_0x4105e3);}(_0x274f,0x1ef));var _0xf274=function(_0x18ed68,_0x2db4da){_0x18ed68=_0x18ed68-0x0;var _0x2df85b=_0x274f[_0x18ed68];return _0x2df85b;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf274('0x0'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xf274('0x1'));var logger=require(_0xf274('0x2'))('rpc');var config=require(_0xf274('0x3'));var jayson=require('jayson/promise');var client=jayson[_0xf274('0x4')][_0xf274('0x5')]({'port':0x232a});config['redis']=_[_0xf274('0x6')](config[_0xf274('0x7')],{'host':_0xf274('0x8'),'port':0x18eb});var socket=require(_0xf274('0x9'))(new Redis(config[_0xf274('0x7')]));require('./voiceQueue.socket')[_0xf274('0xa')](socket);function respondWithRpcPromise(_0x16c076,_0x5cacee,_0x572ca5){return new BPromise(function(_0x12d951,_0x5abeec){return client[_0xf274('0xb')](_0x16c076,_0x572ca5)[_0xf274('0xc')](function(_0x1b9d16){logger[_0xf274('0xd')](_0xf274('0xe'),_0x5cacee,_0xf274('0xf'));logger['debug'](_0xf274('0x10'),_0x5cacee,_0xf274('0xf'),JSON[_0xf274('0x11')](_0x1b9d16));if(_0x1b9d16[_0xf274('0x12')]){if(_0x1b9d16['error'][_0xf274('0x13')]===0x1f4){logger[_0xf274('0x12')](_0xf274('0xe'),_0x5cacee,_0x1b9d16['error'][_0xf274('0x14')]);return _0x5abeec(_0x1b9d16[_0xf274('0x12')][_0xf274('0x14')]);}logger[_0xf274('0x12')](_0xf274('0xe'),_0x5cacee,_0x1b9d16[_0xf274('0x12')][_0xf274('0x14')]);return _0x12d951(_0x1b9d16[_0xf274('0x12')][_0xf274('0x14')]);}else{logger[_0xf274('0xd')](_0xf274('0xe'),_0x5cacee,_0xf274('0xf'));_0x12d951(_0x1b9d16[_0xf274('0x15')][_0xf274('0x14')]);}})['catch'](function(_0x312dbc){logger[_0xf274('0x12')]('VoiceQueue,\x20%s,\x20%s',_0x5cacee,_0x312dbc);_0x5abeec(_0x312dbc);});});}exports['GetVoiceQueue']=function(_0x32e3cd){var _0x171f0e=this;return new Promise(function(_0x24bab4,_0x45734b){return db[_0xf274('0x16')][_0xf274('0x17')]({'raw':_0x32e3cd[_0xf274('0x18')]?_0x32e3cd[_0xf274('0x18')][_0xf274('0x19')]===undefined?!![]:![]:!![],'where':_0x32e3cd[_0xf274('0x18')]?_0x32e3cd[_0xf274('0x18')]['where']||null:null,'attributes':_0x32e3cd[_0xf274('0x18')]?_0x32e3cd['options']['attributes']||null:null,'limit':_0x32e3cd[_0xf274('0x18')]?_0x32e3cd['options']['limit']||null:null,'include':_0x32e3cd[_0xf274('0x18')]?_0x32e3cd[_0xf274('0x18')][_0xf274('0x1a')]?_[_0xf274('0x1b')](_0x32e3cd[_0xf274('0x18')]['include'],function(_0x33c443){return{'model':db[_0x33c443[_0xf274('0x1c')]],'as':_0x33c443['as'],'attributes':_0x33c443['attributes'],'include':_0x33c443['include']?_[_0xf274('0x1b')](_0x33c443[_0xf274('0x1a')],function(_0x1bddb5){return{'model':db[_0x1bddb5[_0xf274('0x1c')]],'as':_0x1bddb5['as'],'attributes':_0x1bddb5['attributes'],'include':_0x1bddb5['include']?_[_0xf274('0x1b')](_0x1bddb5[_0xf274('0x1a')],function(_0x51d554){return{'model':db[_0x51d554[_0xf274('0x1c')]],'as':_0x51d554['as'],'attributes':_0x51d554[_0xf274('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xf274('0xc')](function(_0x1eec34){logger['info']('GetVoiceQueue',_0x32e3cd);logger[_0xf274('0x1e')](_0xf274('0x1f'),_0x32e3cd,JSON[_0xf274('0x11')](_0x1eec34));_0x24bab4(_0x1eec34);})[_0xf274('0x20')](function(_0x46374a){logger[_0xf274('0x12')](_0xf274('0x1f'),_0x46374a[_0xf274('0x14')],_0x32e3cd);_0x45734b(_0x171f0e['error'](0x1f4,_0x46374a[_0xf274('0x14')]));});});};exports[_0xf274('0x21')]=function(_0x1de2d5){var _0x234a04=this;return new Promise(function(_0x2078f8,_0x3426dc){return db['VoiceQueue'][_0xf274('0x22')]({'raw':_0x1de2d5[_0xf274('0x18')]?_0x1de2d5[_0xf274('0x18')][_0xf274('0x19')]===undefined?!![]:![]:!![],'where':_0x1de2d5['options']?_0x1de2d5[_0xf274('0x18')][_0xf274('0x23')]||null:null,'attributes':_0x1de2d5[_0xf274('0x18')]?_0x1de2d5[_0xf274('0x18')][_0xf274('0x1d')]||null:null,'include':_0x1de2d5['options']?_0x1de2d5[_0xf274('0x18')][_0xf274('0x1a')]?_[_0xf274('0x1b')](_0x1de2d5['options'][_0xf274('0x1a')],function(_0x39e2ac){return{'model':db[_0x39e2ac[_0xf274('0x1c')]],'as':_0x39e2ac['as'],'attributes':_0x39e2ac[_0xf274('0x1d')],'include':_0x39e2ac[_0xf274('0x1a')]?_[_0xf274('0x1b')](_0x39e2ac['include'],function(_0x15e86e){return{'model':db[_0x15e86e[_0xf274('0x1c')]],'as':_0x15e86e['as'],'attributes':_0x15e86e[_0xf274('0x1d')],'include':_0x15e86e[_0xf274('0x1a')]?_['map'](_0x15e86e[_0xf274('0x1a')],function(_0x24a2d9){return{'model':db[_0x24a2d9[_0xf274('0x1c')]],'as':_0x24a2d9['as'],'attributes':_0x24a2d9['attributes']};}):[]};}):[]};}):[]:[]})[_0xf274('0xc')](function(_0x316844){logger[_0xf274('0xd')](_0xf274('0x21'),_0x1de2d5);logger[_0xf274('0x1e')](_0xf274('0x21'),_0x1de2d5,JSON[_0xf274('0x11')](_0x316844));_0x2078f8(_0x316844);})[_0xf274('0x20')](function(_0x3ee69b){logger['error'](_0xf274('0x21'),_0x3ee69b[_0xf274('0x14')],_0x1de2d5);_0x3426dc(_0x234a04['error'](0x1f4,_0x3ee69b[_0xf274('0x14')]));});});};