Built motion from commit f541bb3b.|2.6.14
[motion2.git] / server / api / chatQueue / chatQueue.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 _0x8ff4=['include','map','model','attributes','ShowChatQueue','find','catch','lodash','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','register','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','GetChatQueue','ChatQueue','options','raw','where'];(function(_0x4e9628,_0x250573){var _0x27bc8c=function(_0xb3b7ae){while(--_0xb3b7ae){_0x4e9628['push'](_0x4e9628['shift']());}};_0x27bc8c(++_0x250573);}(_0x8ff4,0x11f));var _0x48ff=function(_0x2786ea,_0x16c3c3){_0x2786ea=_0x2786ea-0x0;var _0x5c38e5=_0x8ff4[_0x2786ea];return _0x5c38e5;};'use strict';var _=require(_0x48ff('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x48ff('0x1'));var rs=require(_0x48ff('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x48ff('0x3'))['db'];var utils=require(_0x48ff('0x4'));var logger=require(_0x48ff('0x5'))(_0x48ff('0x6'));var config=require(_0x48ff('0x7'));var jayson=require(_0x48ff('0x8'));var client=jayson[_0x48ff('0x9')][_0x48ff('0xa')]({'port':0x232a});config[_0x48ff('0xb')]=_[_0x48ff('0xc')](config[_0x48ff('0xb')],{'host':_0x48ff('0xd'),'port':0x18eb});var socket=require(_0x48ff('0xe'))(new Redis(config[_0x48ff('0xb')]));require('./chatQueue.socket')[_0x48ff('0xf')](socket);function respondWithRpcPromise(_0x312c3f,_0x5eb71f,_0x37027d){return new BPromise(function(_0x140a23,_0x5754e1){return client[_0x48ff('0x10')](_0x312c3f,_0x37027d)[_0x48ff('0x11')](function(_0x5a3f0a){logger[_0x48ff('0x12')](_0x48ff('0x13'),_0x5eb71f,_0x48ff('0x14'));logger[_0x48ff('0x15')](_0x48ff('0x16'),_0x5eb71f,_0x48ff('0x14'),JSON[_0x48ff('0x17')](_0x5a3f0a));if(_0x5a3f0a[_0x48ff('0x18')]){if(_0x5a3f0a[_0x48ff('0x18')][_0x48ff('0x19')]===0x1f4){logger[_0x48ff('0x18')](_0x48ff('0x13'),_0x5eb71f,_0x5a3f0a[_0x48ff('0x18')][_0x48ff('0x1a')]);return _0x5754e1(_0x5a3f0a['error'][_0x48ff('0x1a')]);}logger[_0x48ff('0x18')]('ChatQueue,\x20%s,\x20%s',_0x5eb71f,_0x5a3f0a[_0x48ff('0x18')][_0x48ff('0x1a')]);return _0x140a23(_0x5a3f0a[_0x48ff('0x18')]['message']);}else{logger[_0x48ff('0x12')](_0x48ff('0x13'),_0x5eb71f,'request\x20sent');_0x140a23(_0x5a3f0a[_0x48ff('0x1b')][_0x48ff('0x1a')]);}})['catch'](function(_0x24d4fb){logger[_0x48ff('0x18')]('ChatQueue,\x20%s,\x20%s',_0x5eb71f,_0x24d4fb);_0x5754e1(_0x24d4fb);});});}exports[_0x48ff('0x1c')]=function(_0x1a4111){var _0x2fe32f=this;return new Promise(function(_0x55bc40,_0x57c773){return db[_0x48ff('0x1d')]['findAll']({'raw':_0x1a4111[_0x48ff('0x1e')]?_0x1a4111[_0x48ff('0x1e')][_0x48ff('0x1f')]===undefined?!![]:![]:!![],'where':_0x1a4111[_0x48ff('0x1e')]?_0x1a4111[_0x48ff('0x1e')][_0x48ff('0x20')]||null:null,'attributes':_0x1a4111[_0x48ff('0x1e')]?_0x1a4111[_0x48ff('0x1e')]['attributes']||null:null,'limit':_0x1a4111[_0x48ff('0x1e')]?_0x1a4111[_0x48ff('0x1e')]['limit']||null:null,'include':_0x1a4111[_0x48ff('0x1e')]?_0x1a4111[_0x48ff('0x1e')][_0x48ff('0x21')]?_[_0x48ff('0x22')](_0x1a4111[_0x48ff('0x1e')][_0x48ff('0x21')],function(_0x4ff1b7){return{'model':db[_0x4ff1b7[_0x48ff('0x23')]],'as':_0x4ff1b7['as'],'attributes':_0x4ff1b7[_0x48ff('0x24')],'include':_0x4ff1b7['include']?_[_0x48ff('0x22')](_0x4ff1b7[_0x48ff('0x21')],function(_0x39088f){return{'model':db[_0x39088f[_0x48ff('0x23')]],'as':_0x39088f['as'],'attributes':_0x39088f[_0x48ff('0x24')],'include':_0x39088f[_0x48ff('0x21')]?_[_0x48ff('0x22')](_0x39088f[_0x48ff('0x21')],function(_0x2b92ad){return{'model':db[_0x2b92ad[_0x48ff('0x23')]],'as':_0x2b92ad['as'],'attributes':_0x2b92ad[_0x48ff('0x24')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x34def7){logger[_0x48ff('0x12')](_0x48ff('0x1c'),_0x1a4111);logger[_0x48ff('0x15')]('GetChatQueue',_0x1a4111,JSON[_0x48ff('0x17')](_0x34def7));_0x55bc40(_0x34def7);})['catch'](function(_0x2c9185){logger['error'](_0x48ff('0x1c'),_0x2c9185[_0x48ff('0x1a')],_0x1a4111);_0x57c773(_0x2fe32f[_0x48ff('0x18')](0x1f4,_0x2c9185[_0x48ff('0x1a')]));});});};exports[_0x48ff('0x25')]=function(_0x182289){var _0x536eb4=this;return new Promise(function(_0x31f896,_0x6fa03c){return db[_0x48ff('0x1d')][_0x48ff('0x26')]({'raw':_0x182289[_0x48ff('0x1e')]?_0x182289[_0x48ff('0x1e')][_0x48ff('0x1f')]===undefined?!![]:![]:!![],'where':_0x182289['options']?_0x182289[_0x48ff('0x1e')][_0x48ff('0x20')]||null:null,'attributes':_0x182289['options']?_0x182289[_0x48ff('0x1e')][_0x48ff('0x24')]||null:null,'include':_0x182289[_0x48ff('0x1e')]?_0x182289[_0x48ff('0x1e')][_0x48ff('0x21')]?_[_0x48ff('0x22')](_0x182289[_0x48ff('0x1e')][_0x48ff('0x21')],function(_0x36100d){return{'model':db[_0x36100d[_0x48ff('0x23')]],'as':_0x36100d['as'],'attributes':_0x36100d[_0x48ff('0x24')],'include':_0x36100d[_0x48ff('0x21')]?_[_0x48ff('0x22')](_0x36100d[_0x48ff('0x21')],function(_0x58955d){return{'model':db[_0x58955d[_0x48ff('0x23')]],'as':_0x58955d['as'],'attributes':_0x58955d[_0x48ff('0x24')],'include':_0x58955d[_0x48ff('0x21')]?_[_0x48ff('0x22')](_0x58955d['include'],function(_0x5c277d){return{'model':db[_0x5c277d[_0x48ff('0x23')]],'as':_0x5c277d['as'],'attributes':_0x5c277d['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x907224){logger[_0x48ff('0x12')](_0x48ff('0x25'),_0x182289);logger[_0x48ff('0x15')]('ShowChatQueue',_0x182289,JSON[_0x48ff('0x17')](_0x907224));_0x31f896(_0x907224);})[_0x48ff('0x27')](function(_0x5a66c4){logger[_0x48ff('0x18')](_0x48ff('0x25'),_0x5a66c4['message'],_0x182289);_0x6fa03c(_0x536eb4[_0x48ff('0x18')](0x1f4,_0x5a66c4['message']));});});};