Built motion from commit f0b1811d.|2.6.6
[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 _0x689b=['attributes','limit','include','model','map','GetChatQueue','ShowChatQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','client','http','redis','localhost','./chatQueue.socket','register','then','info','ChatQueue,\x20%s,\x20%s','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','ChatQueue','raw','options','where'];(function(_0x4ce392,_0x571cb5){var _0x20bd85=function(_0x593921){while(--_0x593921){_0x4ce392['push'](_0x4ce392['shift']());}};_0x20bd85(++_0x571cb5);}(_0x689b,0xeb));var _0xb689=function(_0x384160,_0x6e117d){_0x384160=_0x384160-0x0;var _0x5e8b8d=_0x689b[_0x384160];return _0x5e8b8d;};'use strict';var _=require(_0xb689('0x0'));var util=require(_0xb689('0x1'));var moment=require(_0xb689('0x2'));var BPromise=require(_0xb689('0x3'));var rs=require(_0xb689('0x4'));var fs=require('fs');var Redis=require(_0xb689('0x5'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xb689('0x6'))(_0xb689('0x7'));var config=require(_0xb689('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xb689('0x9')][_0xb689('0xa')]({'port':0x232a});config['redis']=_['defaults'](config[_0xb689('0xb')],{'host':_0xb689('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb689('0xb')]));require(_0xb689('0xd'))[_0xb689('0xe')](socket);function respondWithRpcPromise(_0x3e2f74,_0x2394b9,_0xe35a91){return new BPromise(function(_0x5d3ad6,_0x201e5){return client['request'](_0x3e2f74,_0xe35a91)[_0xb689('0xf')](function(_0x29ddfa){logger[_0xb689('0x10')](_0xb689('0x11'),_0x2394b9,'request\x20sent');logger[_0xb689('0x12')](_0xb689('0x13'),_0x2394b9,'request\x20sent',JSON[_0xb689('0x14')](_0x29ddfa));if(_0x29ddfa[_0xb689('0x15')]){if(_0x29ddfa[_0xb689('0x15')][_0xb689('0x16')]===0x1f4){logger[_0xb689('0x15')](_0xb689('0x11'),_0x2394b9,_0x29ddfa['error'][_0xb689('0x17')]);return _0x201e5(_0x29ddfa[_0xb689('0x15')][_0xb689('0x17')]);}logger['error']('ChatQueue,\x20%s,\x20%s',_0x2394b9,_0x29ddfa['error']['message']);return _0x5d3ad6(_0x29ddfa['error'][_0xb689('0x17')]);}else{logger[_0xb689('0x10')]('ChatQueue,\x20%s,\x20%s',_0x2394b9,_0xb689('0x18'));_0x5d3ad6(_0x29ddfa[_0xb689('0x19')]['message']);}})[_0xb689('0x1a')](function(_0x4ea72c){logger[_0xb689('0x15')](_0xb689('0x11'),_0x2394b9,_0x4ea72c);_0x201e5(_0x4ea72c);});});}exports['GetChatQueue']=function(_0x49e094){var _0x2ab40e=this;return new Promise(function(_0x550f5f,_0x54f0db){return db[_0xb689('0x1b')]['findAll']({'raw':_0x49e094['options']?_0x49e094['options'][_0xb689('0x1c')]===undefined?!![]:![]:!![],'where':_0x49e094['options']?_0x49e094[_0xb689('0x1d')][_0xb689('0x1e')]||null:null,'attributes':_0x49e094[_0xb689('0x1d')]?_0x49e094[_0xb689('0x1d')][_0xb689('0x1f')]||null:null,'limit':_0x49e094[_0xb689('0x1d')]?_0x49e094[_0xb689('0x1d')][_0xb689('0x20')]||null:null,'include':_0x49e094[_0xb689('0x1d')]?_0x49e094[_0xb689('0x1d')][_0xb689('0x21')]?_['map'](_0x49e094[_0xb689('0x1d')][_0xb689('0x21')],function(_0x32d8ee){return{'model':db[_0x32d8ee[_0xb689('0x22')]],'as':_0x32d8ee['as'],'attributes':_0x32d8ee[_0xb689('0x1f')],'include':_0x32d8ee[_0xb689('0x21')]?_[_0xb689('0x23')](_0x32d8ee['include'],function(_0x413c56){return{'model':db[_0x413c56[_0xb689('0x22')]],'as':_0x413c56['as'],'attributes':_0x413c56[_0xb689('0x1f')],'include':_0x413c56[_0xb689('0x21')]?_[_0xb689('0x23')](_0x413c56[_0xb689('0x21')],function(_0x189fd4){return{'model':db[_0x189fd4[_0xb689('0x22')]],'as':_0x189fd4['as'],'attributes':_0x189fd4[_0xb689('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb689('0xf')](function(_0x456b01){logger['info'](_0xb689('0x24'),_0x49e094);logger[_0xb689('0x12')](_0xb689('0x24'),_0x49e094,JSON['stringify'](_0x456b01));_0x550f5f(_0x456b01);})[_0xb689('0x1a')](function(_0x305809){logger[_0xb689('0x15')](_0xb689('0x24'),_0x305809[_0xb689('0x17')],_0x49e094);_0x54f0db(_0x2ab40e[_0xb689('0x15')](0x1f4,_0x305809[_0xb689('0x17')]));});});};exports[_0xb689('0x25')]=function(_0x39e36f){var _0xf07dd1=this;return new Promise(function(_0x100bfe,_0x6a2c39){return db[_0xb689('0x1b')]['find']({'raw':_0x39e36f[_0xb689('0x1d')]?_0x39e36f[_0xb689('0x1d')][_0xb689('0x1c')]===undefined?!![]:![]:!![],'where':_0x39e36f[_0xb689('0x1d')]?_0x39e36f[_0xb689('0x1d')]['where']||null:null,'attributes':_0x39e36f[_0xb689('0x1d')]?_0x39e36f[_0xb689('0x1d')]['attributes']||null:null,'include':_0x39e36f['options']?_0x39e36f[_0xb689('0x1d')][_0xb689('0x21')]?_[_0xb689('0x23')](_0x39e36f[_0xb689('0x1d')]['include'],function(_0x329e30){return{'model':db[_0x329e30[_0xb689('0x22')]],'as':_0x329e30['as'],'attributes':_0x329e30['attributes'],'include':_0x329e30[_0xb689('0x21')]?_[_0xb689('0x23')](_0x329e30[_0xb689('0x21')],function(_0xa23009){return{'model':db[_0xa23009[_0xb689('0x22')]],'as':_0xa23009['as'],'attributes':_0xa23009[_0xb689('0x1f')],'include':_0xa23009[_0xb689('0x21')]?_[_0xb689('0x23')](_0xa23009[_0xb689('0x21')],function(_0x578a90){return{'model':db[_0x578a90[_0xb689('0x22')]],'as':_0x578a90['as'],'attributes':_0x578a90['attributes']};}):[]};}):[]};}):[]:[]})[_0xb689('0xf')](function(_0x442384){logger[_0xb689('0x10')]('ShowChatQueue',_0x39e36f);logger[_0xb689('0x12')]('ShowChatQueue',_0x39e36f,JSON[_0xb689('0x14')](_0x442384));_0x100bfe(_0x442384);})[_0xb689('0x1a')](function(_0x5f2956){logger[_0xb689('0x15')]('ShowChatQueue',_0x5f2956['message'],_0x39e36f);_0x6a2c39(_0xf07dd1['error'](0x1f4,_0x5f2956[_0xb689('0x17')]));});});};