d879f5490f846a67906f1b5fdf596d8b246c022b
[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 _0x07a2=['stringify','error','code','message','ChatQueue,\x20%s,\x20%s','result','catch','GetChatQueue','findAll','options','raw','where','attributes','limit','include','map','model','ChatQueue','find','ShowChatQueue','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','then','info','request\x20sent','debug','ChatQueue,\x20%s,\x20%s,\x20%s'];(function(_0x5c6280,_0x942b57){var _0x60cf34=function(_0x45a9b9){while(--_0x45a9b9){_0x5c6280['push'](_0x5c6280['shift']());}};_0x60cf34(++_0x942b57);}(_0x07a2,0x12c));var _0x207a=function(_0x395718,_0x20322d){_0x395718=_0x395718-0x0;var _0x3028b8=_0x07a2[_0x395718];return _0x3028b8;};'use strict';var _=require(_0x207a('0x0'));var util=require(_0x207a('0x1'));var moment=require('moment');var BPromise=require(_0x207a('0x2'));var rs=require(_0x207a('0x3'));var fs=require('fs');var Redis=require(_0x207a('0x4'));var db=require(_0x207a('0x5'))['db'];var utils=require(_0x207a('0x6'));var logger=require(_0x207a('0x7'))(_0x207a('0x8'));var config=require(_0x207a('0x9'));var jayson=require(_0x207a('0xa'));var client=jayson['client']['http']({'port':0x232a});config[_0x207a('0xb')]=_[_0x207a('0xc')](config[_0x207a('0xb')],{'host':_0x207a('0xd'),'port':0x18eb});var socket=require(_0x207a('0xe'))(new Redis(config[_0x207a('0xb')]));require('./chatQueue.socket')['register'](socket);function respondWithRpcPromise(_0x3cca2d,_0x5614e1,_0x4eab73){return new BPromise(function(_0x3dd07d,_0x5a7d85){return client['request'](_0x3cca2d,_0x4eab73)[_0x207a('0xf')](function(_0x39950f){logger[_0x207a('0x10')]('ChatQueue,\x20%s,\x20%s',_0x5614e1,_0x207a('0x11'));logger[_0x207a('0x12')](_0x207a('0x13'),_0x5614e1,'request\x20sent',JSON[_0x207a('0x14')](_0x39950f));if(_0x39950f[_0x207a('0x15')]){if(_0x39950f[_0x207a('0x15')][_0x207a('0x16')]===0x1f4){logger[_0x207a('0x15')]('ChatQueue,\x20%s,\x20%s',_0x5614e1,_0x39950f[_0x207a('0x15')]['message']);return _0x5a7d85(_0x39950f[_0x207a('0x15')][_0x207a('0x17')]);}logger[_0x207a('0x15')](_0x207a('0x18'),_0x5614e1,_0x39950f[_0x207a('0x15')][_0x207a('0x17')]);return _0x3dd07d(_0x39950f[_0x207a('0x15')][_0x207a('0x17')]);}else{logger[_0x207a('0x10')](_0x207a('0x18'),_0x5614e1,'request\x20sent');_0x3dd07d(_0x39950f[_0x207a('0x19')]['message']);}})[_0x207a('0x1a')](function(_0x28246e){logger[_0x207a('0x15')](_0x207a('0x18'),_0x5614e1,_0x28246e);_0x5a7d85(_0x28246e);});});}exports[_0x207a('0x1b')]=function(_0x1afb14){var _0x5b20bc=this;return new Promise(function(_0x104593,_0x30ff20){return db['ChatQueue'][_0x207a('0x1c')]({'raw':_0x1afb14[_0x207a('0x1d')]?_0x1afb14[_0x207a('0x1d')][_0x207a('0x1e')]===undefined?!![]:![]:!![],'where':_0x1afb14[_0x207a('0x1d')]?_0x1afb14[_0x207a('0x1d')][_0x207a('0x1f')]||null:null,'attributes':_0x1afb14[_0x207a('0x1d')]?_0x1afb14[_0x207a('0x1d')][_0x207a('0x20')]||null:null,'limit':_0x1afb14[_0x207a('0x1d')]?_0x1afb14[_0x207a('0x1d')][_0x207a('0x21')]||null:null,'include':_0x1afb14['options']?_0x1afb14[_0x207a('0x1d')][_0x207a('0x22')]?_[_0x207a('0x23')](_0x1afb14[_0x207a('0x1d')]['include'],function(_0x1bf684){return{'model':db[_0x1bf684[_0x207a('0x24')]],'as':_0x1bf684['as'],'attributes':_0x1bf684['attributes'],'include':_0x1bf684[_0x207a('0x22')]?_['map'](_0x1bf684['include'],function(_0x3c81bd){return{'model':db[_0x3c81bd['model']],'as':_0x3c81bd['as'],'attributes':_0x3c81bd[_0x207a('0x20')],'include':_0x3c81bd[_0x207a('0x22')]?_['map'](_0x3c81bd['include'],function(_0xb41124){return{'model':db[_0xb41124[_0x207a('0x24')]],'as':_0xb41124['as'],'attributes':_0xb41124['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x25d852){logger[_0x207a('0x10')](_0x207a('0x1b'),_0x1afb14);logger[_0x207a('0x12')](_0x207a('0x1b'),_0x1afb14,JSON[_0x207a('0x14')](_0x25d852));_0x104593(_0x25d852);})[_0x207a('0x1a')](function(_0x507dc9){logger[_0x207a('0x15')](_0x207a('0x1b'),_0x507dc9[_0x207a('0x17')],_0x1afb14);_0x30ff20(_0x5b20bc['error'](0x1f4,_0x507dc9['message']));});});};exports['ShowChatQueue']=function(_0x4b76cd){var _0x290385=this;return new Promise(function(_0x358231,_0x3afd69){return db[_0x207a('0x25')][_0x207a('0x26')]({'raw':_0x4b76cd[_0x207a('0x1d')]?_0x4b76cd[_0x207a('0x1d')][_0x207a('0x1e')]===undefined?!![]:![]:!![],'where':_0x4b76cd[_0x207a('0x1d')]?_0x4b76cd[_0x207a('0x1d')]['where']||null:null,'attributes':_0x4b76cd[_0x207a('0x1d')]?_0x4b76cd[_0x207a('0x1d')][_0x207a('0x20')]||null:null,'include':_0x4b76cd['options']?_0x4b76cd['options'][_0x207a('0x22')]?_[_0x207a('0x23')](_0x4b76cd['options'][_0x207a('0x22')],function(_0x1de18e){return{'model':db[_0x1de18e['model']],'as':_0x1de18e['as'],'attributes':_0x1de18e[_0x207a('0x20')],'include':_0x1de18e[_0x207a('0x22')]?_[_0x207a('0x23')](_0x1de18e['include'],function(_0x405415){return{'model':db[_0x405415['model']],'as':_0x405415['as'],'attributes':_0x405415['attributes'],'include':_0x405415[_0x207a('0x22')]?_[_0x207a('0x23')](_0x405415['include'],function(_0x2597a2){return{'model':db[_0x2597a2[_0x207a('0x24')]],'as':_0x2597a2['as'],'attributes':_0x2597a2['attributes']};}):[]};}):[]};}):[]:[]})[_0x207a('0xf')](function(_0x1bf9c0){logger[_0x207a('0x10')](_0x207a('0x27'),_0x4b76cd);logger[_0x207a('0x12')]('ShowChatQueue',_0x4b76cd,JSON[_0x207a('0x14')](_0x1bf9c0));_0x358231(_0x1bf9c0);})[_0x207a('0x1a')](function(_0xd24dc6){logger[_0x207a('0x15')](_0x207a('0x27'),_0xd24dc6[_0x207a('0x17')],_0x4b76cd);_0x3afd69(_0x290385[_0x207a('0x15')](0x1f4,_0xd24dc6['message']));});});};