Built motion from commit (unavailable).|2.6.0
[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 _0x5089=['message','info','result','GetVoiceQueue','VoiceQueue','findAll','options','where','attributes','limit','include','map','model','catch','ShowVoiceQueue','find','raw','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./voiceQueue.socket','request','then','VoiceQueue,\x20%s,\x20%s','request\x20sent','debug','VoiceQueue,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0xdc2ce,_0x56d099){var _0xafc124=function(_0xf29a87){while(--_0xf29a87){_0xdc2ce['push'](_0xdc2ce['shift']());}};_0xafc124(++_0x56d099);}(_0x5089,0x1bf));var _0x9508=function(_0x397f37,_0x3cf86d){_0x397f37=_0x397f37-0x0;var _0x31cae6=_0x5089[_0x397f37];return _0x31cae6;};'use strict';var _=require('lodash');var util=require(_0x9508('0x0'));var moment=require(_0x9508('0x1'));var BPromise=require(_0x9508('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9508('0x3'));var db=require(_0x9508('0x4'))['db'];var utils=require(_0x9508('0x5'));var logger=require(_0x9508('0x6'))(_0x9508('0x7'));var config=require(_0x9508('0x8'));var jayson=require(_0x9508('0x9'));var client=jayson[_0x9508('0xa')][_0x9508('0xb')]({'port':0x232a});config[_0x9508('0xc')]=_[_0x9508('0xd')](config[_0x9508('0xc')],{'host':_0x9508('0xe'),'port':0x18eb});var socket=require(_0x9508('0xf'))(new Redis(config[_0x9508('0xc')]));require(_0x9508('0x10'))['register'](socket);function respondWithRpcPromise(_0x29952f,_0x440116,_0x1fae39){return new BPromise(function(_0x12b30e,_0x546fcf){return client[_0x9508('0x11')](_0x29952f,_0x1fae39)[_0x9508('0x12')](function(_0xe180c3){logger['info'](_0x9508('0x13'),_0x440116,_0x9508('0x14'));logger[_0x9508('0x15')](_0x9508('0x16'),_0x440116,_0x9508('0x14'),JSON[_0x9508('0x17')](_0xe180c3));if(_0xe180c3[_0x9508('0x18')]){if(_0xe180c3[_0x9508('0x18')][_0x9508('0x19')]===0x1f4){logger[_0x9508('0x18')]('VoiceQueue,\x20%s,\x20%s',_0x440116,_0xe180c3[_0x9508('0x18')][_0x9508('0x1a')]);return _0x546fcf(_0xe180c3[_0x9508('0x18')][_0x9508('0x1a')]);}logger['error']('VoiceQueue,\x20%s,\x20%s',_0x440116,_0xe180c3[_0x9508('0x18')][_0x9508('0x1a')]);return _0x12b30e(_0xe180c3[_0x9508('0x18')][_0x9508('0x1a')]);}else{logger[_0x9508('0x1b')](_0x9508('0x13'),_0x440116,_0x9508('0x14'));_0x12b30e(_0xe180c3[_0x9508('0x1c')]['message']);}})['catch'](function(_0x537cb2){logger[_0x9508('0x18')](_0x9508('0x13'),_0x440116,_0x537cb2);_0x546fcf(_0x537cb2);});});}exports[_0x9508('0x1d')]=function(_0x3f9ae4){var _0x398d8b=this;return new Promise(function(_0x434454,_0x242693){return db[_0x9508('0x1e')][_0x9508('0x1f')]({'raw':_0x3f9ae4['options']?_0x3f9ae4[_0x9508('0x20')]['raw']===undefined?!![]:![]:!![],'where':_0x3f9ae4[_0x9508('0x20')]?_0x3f9ae4['options'][_0x9508('0x21')]||null:null,'attributes':_0x3f9ae4[_0x9508('0x20')]?_0x3f9ae4[_0x9508('0x20')][_0x9508('0x22')]||null:null,'limit':_0x3f9ae4[_0x9508('0x20')]?_0x3f9ae4['options'][_0x9508('0x23')]||null:null,'include':_0x3f9ae4['options']?_0x3f9ae4[_0x9508('0x20')][_0x9508('0x24')]?_[_0x9508('0x25')](_0x3f9ae4[_0x9508('0x20')]['include'],function(_0x506c05){return{'model':db[_0x506c05[_0x9508('0x26')]],'as':_0x506c05['as'],'attributes':_0x506c05[_0x9508('0x22')],'include':_0x506c05[_0x9508('0x24')]?_[_0x9508('0x25')](_0x506c05[_0x9508('0x24')],function(_0x2f0aa2){return{'model':db[_0x2f0aa2[_0x9508('0x26')]],'as':_0x2f0aa2['as'],'attributes':_0x2f0aa2[_0x9508('0x22')],'include':_0x2f0aa2[_0x9508('0x24')]?_['map'](_0x2f0aa2['include'],function(_0x1c2776){return{'model':db[_0x1c2776[_0x9508('0x26')]],'as':_0x1c2776['as'],'attributes':_0x1c2776['attributes']};}):[]};}):[]};}):[]:[]})[_0x9508('0x12')](function(_0x4fbb83){logger[_0x9508('0x1b')](_0x9508('0x1d'),_0x3f9ae4);logger[_0x9508('0x15')](_0x9508('0x1d'),_0x3f9ae4,JSON['stringify'](_0x4fbb83));_0x434454(_0x4fbb83);})[_0x9508('0x27')](function(_0x2b43d9){logger[_0x9508('0x18')](_0x9508('0x1d'),_0x2b43d9['message'],_0x3f9ae4);_0x242693(_0x398d8b['error'](0x1f4,_0x2b43d9[_0x9508('0x1a')]));});});};exports[_0x9508('0x28')]=function(_0x4411e3){var _0x5b3738=this;return new Promise(function(_0x546127,_0xc1d13){return db['VoiceQueue'][_0x9508('0x29')]({'raw':_0x4411e3[_0x9508('0x20')]?_0x4411e3[_0x9508('0x20')][_0x9508('0x2a')]===undefined?!![]:![]:!![],'where':_0x4411e3['options']?_0x4411e3[_0x9508('0x20')][_0x9508('0x21')]||null:null,'attributes':_0x4411e3[_0x9508('0x20')]?_0x4411e3[_0x9508('0x20')][_0x9508('0x22')]||null:null,'include':_0x4411e3[_0x9508('0x20')]?_0x4411e3[_0x9508('0x20')][_0x9508('0x24')]?_[_0x9508('0x25')](_0x4411e3['options'][_0x9508('0x24')],function(_0x3decc5){return{'model':db[_0x3decc5['model']],'as':_0x3decc5['as'],'attributes':_0x3decc5['attributes'],'include':_0x3decc5[_0x9508('0x24')]?_[_0x9508('0x25')](_0x3decc5[_0x9508('0x24')],function(_0x191db7){return{'model':db[_0x191db7[_0x9508('0x26')]],'as':_0x191db7['as'],'attributes':_0x191db7['attributes'],'include':_0x191db7[_0x9508('0x24')]?_[_0x9508('0x25')](_0x191db7[_0x9508('0x24')],function(_0x58ea52){return{'model':db[_0x58ea52[_0x9508('0x26')]],'as':_0x58ea52['as'],'attributes':_0x58ea52[_0x9508('0x22')]};}):[]};}):[]};}):[]:[]})[_0x9508('0x12')](function(_0x24f047){logger[_0x9508('0x1b')](_0x9508('0x28'),_0x4411e3);logger[_0x9508('0x15')](_0x9508('0x28'),_0x4411e3,JSON['stringify'](_0x24f047));_0x546127(_0x24f047);})[_0x9508('0x27')](function(_0x52b30c){logger[_0x9508('0x18')]('ShowVoiceQueue',_0x52b30c[_0x9508('0x1a')],_0x4411e3);_0xc1d13(_0x5b3738[_0x9508('0x18')](0x1f4,_0x52b30c[_0x9508('0x1a')]));});});};