fb3928373dcf2ed8d564cc688e4e3722a777cd6c
[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 _0x1fbb=['ShowChatQueue','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','redis','localhost','socket.io-emitter','./chatQueue.socket','register','then','info','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','ChatQueue,\x20%s,\x20%s','message','result','catch','GetChatQueue','ChatQueue','options','raw','where','attributes','limit','include','map','model','find'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x1fbb,0x99));var _0xb1fb=function(_0x3154be,_0x251857){_0x3154be=_0x3154be-0x0;var _0x23ef17=_0x1fbb[_0x3154be];return _0x23ef17;};'use strict';var _=require(_0xb1fb('0x0'));var util=require(_0xb1fb('0x1'));var moment=require(_0xb1fb('0x2'));var BPromise=require(_0xb1fb('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb1fb('0x4'));var db=require(_0xb1fb('0x5'))['db'];var utils=require(_0xb1fb('0x6'));var logger=require(_0xb1fb('0x7'))(_0xb1fb('0x8'));var config=require('../../config/environment');var jayson=require(_0xb1fb('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xb1fb('0xa')]=_['defaults'](config['redis'],{'host':_0xb1fb('0xb'),'port':0x18eb});var socket=require(_0xb1fb('0xc'))(new Redis(config[_0xb1fb('0xa')]));require(_0xb1fb('0xd'))[_0xb1fb('0xe')](socket);function respondWithRpcPromise(_0x437c95,_0x394373,_0x27658f){return new BPromise(function(_0x52c278,_0x273297){return client['request'](_0x437c95,_0x27658f)[_0xb1fb('0xf')](function(_0x377683){logger[_0xb1fb('0x10')]('ChatQueue,\x20%s,\x20%s',_0x394373,_0xb1fb('0x11'));logger[_0xb1fb('0x12')](_0xb1fb('0x13'),_0x394373,_0xb1fb('0x11'),JSON[_0xb1fb('0x14')](_0x377683));if(_0x377683[_0xb1fb('0x15')]){if(_0x377683[_0xb1fb('0x15')]['code']===0x1f4){logger[_0xb1fb('0x15')](_0xb1fb('0x16'),_0x394373,_0x377683['error'][_0xb1fb('0x17')]);return _0x273297(_0x377683[_0xb1fb('0x15')][_0xb1fb('0x17')]);}logger[_0xb1fb('0x15')](_0xb1fb('0x16'),_0x394373,_0x377683[_0xb1fb('0x15')][_0xb1fb('0x17')]);return _0x52c278(_0x377683[_0xb1fb('0x15')][_0xb1fb('0x17')]);}else{logger[_0xb1fb('0x10')](_0xb1fb('0x16'),_0x394373,_0xb1fb('0x11'));_0x52c278(_0x377683[_0xb1fb('0x18')]['message']);}})[_0xb1fb('0x19')](function(_0x430810){logger[_0xb1fb('0x15')](_0xb1fb('0x16'),_0x394373,_0x430810);_0x273297(_0x430810);});});}exports[_0xb1fb('0x1a')]=function(_0x1f4f1b){var _0x120613=this;return new Promise(function(_0x4c8daf,_0x568523){return db[_0xb1fb('0x1b')]['findAll']({'raw':_0x1f4f1b[_0xb1fb('0x1c')]?_0x1f4f1b[_0xb1fb('0x1c')][_0xb1fb('0x1d')]===undefined?!![]:![]:!![],'where':_0x1f4f1b['options']?_0x1f4f1b[_0xb1fb('0x1c')][_0xb1fb('0x1e')]||null:null,'attributes':_0x1f4f1b['options']?_0x1f4f1b['options'][_0xb1fb('0x1f')]||null:null,'limit':_0x1f4f1b['options']?_0x1f4f1b[_0xb1fb('0x1c')][_0xb1fb('0x20')]||null:null,'include':_0x1f4f1b[_0xb1fb('0x1c')]?_0x1f4f1b['options'][_0xb1fb('0x21')]?_[_0xb1fb('0x22')](_0x1f4f1b[_0xb1fb('0x1c')]['include'],function(_0x94e1f7){return{'model':db[_0x94e1f7[_0xb1fb('0x23')]],'as':_0x94e1f7['as'],'attributes':_0x94e1f7[_0xb1fb('0x1f')],'include':_0x94e1f7[_0xb1fb('0x21')]?_['map'](_0x94e1f7[_0xb1fb('0x21')],function(_0x5e2b93){return{'model':db[_0x5e2b93['model']],'as':_0x5e2b93['as'],'attributes':_0x5e2b93[_0xb1fb('0x1f')],'include':_0x5e2b93[_0xb1fb('0x21')]?_[_0xb1fb('0x22')](_0x5e2b93[_0xb1fb('0x21')],function(_0x155154){return{'model':db[_0x155154[_0xb1fb('0x23')]],'as':_0x155154['as'],'attributes':_0x155154['attributes']};}):[]};}):[]};}):[]:[]})[_0xb1fb('0xf')](function(_0x42a668){logger[_0xb1fb('0x10')](_0xb1fb('0x1a'),_0x1f4f1b);logger['debug']('GetChatQueue',_0x1f4f1b,JSON[_0xb1fb('0x14')](_0x42a668));_0x4c8daf(_0x42a668);})['catch'](function(_0x1836b8){logger['error'](_0xb1fb('0x1a'),_0x1836b8[_0xb1fb('0x17')],_0x1f4f1b);_0x568523(_0x120613['error'](0x1f4,_0x1836b8['message']));});});};exports['ShowChatQueue']=function(_0x218f80){var _0x568ce7=this;return new Promise(function(_0x200376,_0x330009){return db[_0xb1fb('0x1b')][_0xb1fb('0x24')]({'raw':_0x218f80[_0xb1fb('0x1c')]?_0x218f80['options'][_0xb1fb('0x1d')]===undefined?!![]:![]:!![],'where':_0x218f80[_0xb1fb('0x1c')]?_0x218f80['options']['where']||null:null,'attributes':_0x218f80[_0xb1fb('0x1c')]?_0x218f80[_0xb1fb('0x1c')][_0xb1fb('0x1f')]||null:null,'include':_0x218f80[_0xb1fb('0x1c')]?_0x218f80['options']['include']?_[_0xb1fb('0x22')](_0x218f80[_0xb1fb('0x1c')][_0xb1fb('0x21')],function(_0x1b5292){return{'model':db[_0x1b5292[_0xb1fb('0x23')]],'as':_0x1b5292['as'],'attributes':_0x1b5292[_0xb1fb('0x1f')],'include':_0x1b5292[_0xb1fb('0x21')]?_[_0xb1fb('0x22')](_0x1b5292[_0xb1fb('0x21')],function(_0x4d2cef){return{'model':db[_0x4d2cef[_0xb1fb('0x23')]],'as':_0x4d2cef['as'],'attributes':_0x4d2cef['attributes'],'include':_0x4d2cef[_0xb1fb('0x21')]?_[_0xb1fb('0x22')](_0x4d2cef[_0xb1fb('0x21')],function(_0xef5ce4){return{'model':db[_0xef5ce4[_0xb1fb('0x23')]],'as':_0xef5ce4['as'],'attributes':_0xef5ce4[_0xb1fb('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xb1fb('0xf')](function(_0x23d2d3){logger[_0xb1fb('0x10')](_0xb1fb('0x25'),_0x218f80);logger[_0xb1fb('0x12')](_0xb1fb('0x25'),_0x218f80,JSON[_0xb1fb('0x14')](_0x23d2d3));_0x200376(_0x23d2d3);})[_0xb1fb('0x19')](function(_0x460b7e){logger[_0xb1fb('0x15')](_0xb1fb('0x25'),_0x460b7e[_0xb1fb('0x17')],_0x218f80);_0x330009(_0x568ce7[_0xb1fb('0x15')](0x1f4,_0x460b7e[_0xb1fb('0x17')]));});});};