afbe9eaa1bf4967e52e48d03d4df9fb7b1d460e2
[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 _0x7268=['code','message','catch','GetVoiceQueue','VoiceQueue','findAll','raw','options','where','attributes','limit','include','map','model','debug','stringify','ShowVoiceQueue','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','./voiceQueue.socket','register','request','then','info','VoiceQueue,\x20%s,\x20%s','VoiceQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error'];(function(_0x42c239,_0x403fdf){var _0x3cd9d8=function(_0x9b2f96){while(--_0x9b2f96){_0x42c239['push'](_0x42c239['shift']());}};_0x3cd9d8(++_0x403fdf);}(_0x7268,0x1d4));var _0x8726=function(_0x513ff4,_0x1c5464){_0x513ff4=_0x513ff4-0x0;var _0x1c4393=_0x7268[_0x513ff4];return _0x1c4393;};'use strict';var _=require(_0x8726('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x8726('0x1'));var rs=require(_0x8726('0x2'));var fs=require('fs');var Redis=require(_0x8726('0x3'));var db=require(_0x8726('0x4'))['db'];var utils=require(_0x8726('0x5'));var logger=require(_0x8726('0x6'))(_0x8726('0x7'));var config=require(_0x8726('0x8'));var jayson=require(_0x8726('0x9'));var client=jayson[_0x8726('0xa')][_0x8726('0xb')]({'port':0x232a});config['redis']=_[_0x8726('0xc')](config[_0x8726('0xd')],{'host':_0x8726('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x8726('0xf'))[_0x8726('0x10')](socket);function respondWithRpcPromise(_0x27aa21,_0x104f70,_0x2628b4){return new BPromise(function(_0x3cea8e,_0x3d224d){return client[_0x8726('0x11')](_0x27aa21,_0x2628b4)[_0x8726('0x12')](function(_0x5ad3c7){logger[_0x8726('0x13')](_0x8726('0x14'),_0x104f70,'request\x20sent');logger['debug'](_0x8726('0x15'),_0x104f70,_0x8726('0x16'),JSON['stringify'](_0x5ad3c7));if(_0x5ad3c7[_0x8726('0x17')]){if(_0x5ad3c7[_0x8726('0x17')][_0x8726('0x18')]===0x1f4){logger[_0x8726('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x104f70,_0x5ad3c7[_0x8726('0x17')][_0x8726('0x19')]);return _0x3d224d(_0x5ad3c7[_0x8726('0x17')]['message']);}logger['error'](_0x8726('0x14'),_0x104f70,_0x5ad3c7[_0x8726('0x17')][_0x8726('0x19')]);return _0x3cea8e(_0x5ad3c7[_0x8726('0x17')]['message']);}else{logger[_0x8726('0x13')](_0x8726('0x14'),_0x104f70,_0x8726('0x16'));_0x3cea8e(_0x5ad3c7['result'][_0x8726('0x19')]);}})[_0x8726('0x1a')](function(_0x44761f){logger[_0x8726('0x17')]('VoiceQueue,\x20%s,\x20%s',_0x104f70,_0x44761f);_0x3d224d(_0x44761f);});});}exports[_0x8726('0x1b')]=function(_0x16b2f8){var _0x4d1264=this;return new Promise(function(_0x11cfba,_0x15dc64){return db[_0x8726('0x1c')][_0x8726('0x1d')]({'raw':_0x16b2f8['options']?_0x16b2f8['options'][_0x8726('0x1e')]===undefined?!![]:![]:!![],'where':_0x16b2f8[_0x8726('0x1f')]?_0x16b2f8[_0x8726('0x1f')][_0x8726('0x20')]||null:null,'attributes':_0x16b2f8[_0x8726('0x1f')]?_0x16b2f8[_0x8726('0x1f')][_0x8726('0x21')]||null:null,'limit':_0x16b2f8[_0x8726('0x1f')]?_0x16b2f8[_0x8726('0x1f')][_0x8726('0x22')]||null:null,'include':_0x16b2f8['options']?_0x16b2f8['options'][_0x8726('0x23')]?_[_0x8726('0x24')](_0x16b2f8['options']['include'],function(_0x3146a9){return{'model':db[_0x3146a9[_0x8726('0x25')]],'as':_0x3146a9['as'],'attributes':_0x3146a9['attributes'],'include':_0x3146a9[_0x8726('0x23')]?_[_0x8726('0x24')](_0x3146a9[_0x8726('0x23')],function(_0x1e099f){return{'model':db[_0x1e099f[_0x8726('0x25')]],'as':_0x1e099f['as'],'attributes':_0x1e099f[_0x8726('0x21')],'include':_0x1e099f[_0x8726('0x23')]?_[_0x8726('0x24')](_0x1e099f[_0x8726('0x23')],function(_0x22abd0){return{'model':db[_0x22abd0['model']],'as':_0x22abd0['as'],'attributes':_0x22abd0[_0x8726('0x21')]};}):[]};}):[]};}):[]:[]})[_0x8726('0x12')](function(_0x16c75b){logger['info'](_0x8726('0x1b'),_0x16b2f8);logger[_0x8726('0x26')](_0x8726('0x1b'),_0x16b2f8,JSON[_0x8726('0x27')](_0x16c75b));_0x11cfba(_0x16c75b);})[_0x8726('0x1a')](function(_0x1702e9){logger[_0x8726('0x17')]('GetVoiceQueue',_0x1702e9[_0x8726('0x19')],_0x16b2f8);_0x15dc64(_0x4d1264[_0x8726('0x17')](0x1f4,_0x1702e9[_0x8726('0x19')]));});});};exports[_0x8726('0x28')]=function(_0x3817b1){var _0x2381fc=this;return new Promise(function(_0x3fbf2b,_0x47c079){return db['VoiceQueue']['find']({'raw':_0x3817b1[_0x8726('0x1f')]?_0x3817b1[_0x8726('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x3817b1[_0x8726('0x1f')]?_0x3817b1[_0x8726('0x1f')]['where']||null:null,'attributes':_0x3817b1['options']?_0x3817b1['options'][_0x8726('0x21')]||null:null,'include':_0x3817b1[_0x8726('0x1f')]?_0x3817b1['options']['include']?_[_0x8726('0x24')](_0x3817b1['options']['include'],function(_0x4df1ab){return{'model':db[_0x4df1ab[_0x8726('0x25')]],'as':_0x4df1ab['as'],'attributes':_0x4df1ab[_0x8726('0x21')],'include':_0x4df1ab[_0x8726('0x23')]?_[_0x8726('0x24')](_0x4df1ab['include'],function(_0x448d11){return{'model':db[_0x448d11['model']],'as':_0x448d11['as'],'attributes':_0x448d11['attributes'],'include':_0x448d11['include']?_['map'](_0x448d11['include'],function(_0x442467){return{'model':db[_0x442467[_0x8726('0x25')]],'as':_0x442467['as'],'attributes':_0x442467['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x993f0a){logger[_0x8726('0x13')](_0x8726('0x28'),_0x3817b1);logger[_0x8726('0x26')](_0x8726('0x28'),_0x3817b1,JSON[_0x8726('0x27')](_0x993f0a));_0x3fbf2b(_0x993f0a);})[_0x8726('0x1a')](function(_0x4ea840){logger[_0x8726('0x17')](_0x8726('0x28'),_0x4ea840[_0x8726('0x19')],_0x3817b1);_0x47c079(_0x2381fc['error'](0x1f4,_0x4ea840[_0x8726('0x19')]));});});};