Built motion from commit da617fac.|2.6.6
[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 _0x3e4f=['../../config/logger','rpc','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./voiceQueue.socket','request','then','info','VoiceQueue,\x20%s,\x20%s','request\x20sent','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','GetVoiceQueue','options','raw','where','attributes','limit','include','map','model','VoiceQueue','find','debug','ShowVoiceQueue','lodash','util','randomstring','../../mysqldb','../../config/utils'];(function(_0x3c5aa6,_0x4c4f86){var _0x49e397=function(_0x37004d){while(--_0x37004d){_0x3c5aa6['push'](_0x3c5aa6['shift']());}};_0x49e397(++_0x4c4f86);}(_0x3e4f,0x15a));var _0xf3e4=function(_0x42f274,_0x56e031){_0x42f274=_0x42f274-0x0;var _0xdbd107=_0x3e4f[_0x42f274];return _0xdbd107;};'use strict';var _=require(_0xf3e4('0x0'));var util=require(_0xf3e4('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xf3e4('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf3e4('0x3'))['db'];var utils=require(_0xf3e4('0x4'));var logger=require(_0xf3e4('0x5'))(_0xf3e4('0x6'));var config=require(_0xf3e4('0x7'));var jayson=require(_0xf3e4('0x8'));var client=jayson[_0xf3e4('0x9')]['http']({'port':0x232a});config['redis']=_[_0xf3e4('0xa')](config[_0xf3e4('0xb')],{'host':_0xf3e4('0xc'),'port':0x18eb});var socket=require(_0xf3e4('0xd'))(new Redis(config[_0xf3e4('0xb')]));require(_0xf3e4('0xe'))['register'](socket);function respondWithRpcPromise(_0x2147ef,_0x40ac9e,_0x4e91bb){return new BPromise(function(_0x1bd6fb,_0x30e81e){return client[_0xf3e4('0xf')](_0x2147ef,_0x4e91bb)[_0xf3e4('0x10')](function(_0x83b3a6){logger[_0xf3e4('0x11')](_0xf3e4('0x12'),_0x40ac9e,_0xf3e4('0x13'));logger['debug'](_0xf3e4('0x14'),_0x40ac9e,_0xf3e4('0x13'),JSON[_0xf3e4('0x15')](_0x83b3a6));if(_0x83b3a6[_0xf3e4('0x16')]){if(_0x83b3a6[_0xf3e4('0x16')]['code']===0x1f4){logger[_0xf3e4('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x40ac9e,_0x83b3a6[_0xf3e4('0x16')]['message']);return _0x30e81e(_0x83b3a6[_0xf3e4('0x16')]['message']);}logger[_0xf3e4('0x16')](_0xf3e4('0x12'),_0x40ac9e,_0x83b3a6[_0xf3e4('0x16')]['message']);return _0x1bd6fb(_0x83b3a6[_0xf3e4('0x16')][_0xf3e4('0x17')]);}else{logger[_0xf3e4('0x11')]('VoiceQueue,\x20%s,\x20%s',_0x40ac9e,'request\x20sent');_0x1bd6fb(_0x83b3a6[_0xf3e4('0x18')][_0xf3e4('0x17')]);}})[_0xf3e4('0x19')](function(_0x55d303){logger[_0xf3e4('0x16')]('VoiceQueue,\x20%s,\x20%s',_0x40ac9e,_0x55d303);_0x30e81e(_0x55d303);});});}exports[_0xf3e4('0x1a')]=function(_0x9f8f62){var _0x282e7e=this;return new Promise(function(_0xb4fea0,_0x338c27){return db['VoiceQueue']['findAll']({'raw':_0x9f8f62[_0xf3e4('0x1b')]?_0x9f8f62['options'][_0xf3e4('0x1c')]===undefined?!![]:![]:!![],'where':_0x9f8f62[_0xf3e4('0x1b')]?_0x9f8f62[_0xf3e4('0x1b')][_0xf3e4('0x1d')]||null:null,'attributes':_0x9f8f62[_0xf3e4('0x1b')]?_0x9f8f62[_0xf3e4('0x1b')][_0xf3e4('0x1e')]||null:null,'limit':_0x9f8f62[_0xf3e4('0x1b')]?_0x9f8f62['options'][_0xf3e4('0x1f')]||null:null,'include':_0x9f8f62[_0xf3e4('0x1b')]?_0x9f8f62[_0xf3e4('0x1b')][_0xf3e4('0x20')]?_[_0xf3e4('0x21')](_0x9f8f62[_0xf3e4('0x1b')][_0xf3e4('0x20')],function(_0x1b0b88){return{'model':db[_0x1b0b88[_0xf3e4('0x22')]],'as':_0x1b0b88['as'],'attributes':_0x1b0b88[_0xf3e4('0x1e')],'include':_0x1b0b88[_0xf3e4('0x20')]?_['map'](_0x1b0b88['include'],function(_0x58d68a){return{'model':db[_0x58d68a[_0xf3e4('0x22')]],'as':_0x58d68a['as'],'attributes':_0x58d68a[_0xf3e4('0x1e')],'include':_0x58d68a[_0xf3e4('0x20')]?_[_0xf3e4('0x21')](_0x58d68a['include'],function(_0x1c03e9){return{'model':db[_0x1c03e9[_0xf3e4('0x22')]],'as':_0x1c03e9['as'],'attributes':_0x1c03e9[_0xf3e4('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xf3e4('0x10')](function(_0x102021){logger[_0xf3e4('0x11')](_0xf3e4('0x1a'),_0x9f8f62);logger['debug'](_0xf3e4('0x1a'),_0x9f8f62,JSON[_0xf3e4('0x15')](_0x102021));_0xb4fea0(_0x102021);})[_0xf3e4('0x19')](function(_0x423b61){logger['error'](_0xf3e4('0x1a'),_0x423b61[_0xf3e4('0x17')],_0x9f8f62);_0x338c27(_0x282e7e['error'](0x1f4,_0x423b61['message']));});});};exports['ShowVoiceQueue']=function(_0x2f6aa6){var _0xbeb52=this;return new Promise(function(_0x4dfcf9,_0x31599c){return db[_0xf3e4('0x23')][_0xf3e4('0x24')]({'raw':_0x2f6aa6['options']?_0x2f6aa6['options'][_0xf3e4('0x1c')]===undefined?!![]:![]:!![],'where':_0x2f6aa6['options']?_0x2f6aa6[_0xf3e4('0x1b')][_0xf3e4('0x1d')]||null:null,'attributes':_0x2f6aa6[_0xf3e4('0x1b')]?_0x2f6aa6[_0xf3e4('0x1b')]['attributes']||null:null,'include':_0x2f6aa6[_0xf3e4('0x1b')]?_0x2f6aa6[_0xf3e4('0x1b')][_0xf3e4('0x20')]?_[_0xf3e4('0x21')](_0x2f6aa6[_0xf3e4('0x1b')][_0xf3e4('0x20')],function(_0x3b84df){return{'model':db[_0x3b84df['model']],'as':_0x3b84df['as'],'attributes':_0x3b84df[_0xf3e4('0x1e')],'include':_0x3b84df['include']?_[_0xf3e4('0x21')](_0x3b84df[_0xf3e4('0x20')],function(_0x46747f){return{'model':db[_0x46747f[_0xf3e4('0x22')]],'as':_0x46747f['as'],'attributes':_0x46747f[_0xf3e4('0x1e')],'include':_0x46747f[_0xf3e4('0x20')]?_[_0xf3e4('0x21')](_0x46747f[_0xf3e4('0x20')],function(_0x11d379){return{'model':db[_0x11d379[_0xf3e4('0x22')]],'as':_0x11d379['as'],'attributes':_0x11d379['attributes']};}):[]};}):[]};}):[]:[]})[_0xf3e4('0x10')](function(_0x130d9f){logger['info']('ShowVoiceQueue',_0x2f6aa6);logger[_0xf3e4('0x25')]('ShowVoiceQueue',_0x2f6aa6,JSON['stringify'](_0x130d9f));_0x4dfcf9(_0x130d9f);})[_0xf3e4('0x19')](function(_0x3dfd38){logger[_0xf3e4('0x16')](_0xf3e4('0x26'),_0x3dfd38[_0xf3e4('0x17')],_0x2f6aa6);_0x31599c(_0xbeb52[_0xf3e4('0x16')](0x1f4,_0x3dfd38[_0xf3e4('0x17')]));});});};