Built motion from commit 2b9af5da.|2.6.26
[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 _0x8b6f=['map','model','attributes','debug','find','ShowChatQueue','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','error','code','message','info','catch','GetChatQueue','ChatQueue','findAll','options','raw','where','limit','include'];(function(_0x594585,_0x933997){var _0xcd0131=function(_0x5eac7c){while(--_0x5eac7c){_0x594585['push'](_0x594585['shift']());}};_0xcd0131(++_0x933997);}(_0x8b6f,0x177));var _0xf8b6=function(_0x1ea3b1,_0x5bdb4d){_0x1ea3b1=_0x1ea3b1-0x0;var _0x584d88=_0x8b6f[_0x1ea3b1];return _0x584d88;};'use strict';var _=require(_0xf8b6('0x0'));var util=require(_0xf8b6('0x1'));var moment=require(_0xf8b6('0x2'));var BPromise=require(_0xf8b6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xf8b6('0x4'));var db=require(_0xf8b6('0x5'))['db'];var utils=require(_0xf8b6('0x6'));var logger=require('../../config/logger')('rpc');var config=require(_0xf8b6('0x7'));var jayson=require(_0xf8b6('0x8'));var client=jayson[_0xf8b6('0x9')][_0xf8b6('0xa')]({'port':0x232a});config[_0xf8b6('0xb')]=_[_0xf8b6('0xc')](config[_0xf8b6('0xb')],{'host':_0xf8b6('0xd'),'port':0x18eb});var socket=require(_0xf8b6('0xe'))(new Redis(config[_0xf8b6('0xb')]));require(_0xf8b6('0xf'))[_0xf8b6('0x10')](socket);function respondWithRpcPromise(_0x4673dc,_0x467f8e,_0x270d9f){return new BPromise(function(_0x1496ba,_0x28899d){return client[_0xf8b6('0x11')](_0x4673dc,_0x270d9f)[_0xf8b6('0x12')](function(_0x4968e5){logger['info'](_0xf8b6('0x13'),_0x467f8e,_0xf8b6('0x14'));logger['debug'](_0xf8b6('0x15'),_0x467f8e,_0xf8b6('0x14'),JSON['stringify'](_0x4968e5));if(_0x4968e5['error']){if(_0x4968e5[_0xf8b6('0x16')][_0xf8b6('0x17')]===0x1f4){logger[_0xf8b6('0x16')](_0xf8b6('0x13'),_0x467f8e,_0x4968e5[_0xf8b6('0x16')]['message']);return _0x28899d(_0x4968e5[_0xf8b6('0x16')]['message']);}logger['error'](_0xf8b6('0x13'),_0x467f8e,_0x4968e5['error'][_0xf8b6('0x18')]);return _0x1496ba(_0x4968e5['error'][_0xf8b6('0x18')]);}else{logger[_0xf8b6('0x19')](_0xf8b6('0x13'),_0x467f8e,_0xf8b6('0x14'));_0x1496ba(_0x4968e5['result']['message']);}})[_0xf8b6('0x1a')](function(_0x58492e){logger[_0xf8b6('0x16')]('ChatQueue,\x20%s,\x20%s',_0x467f8e,_0x58492e);_0x28899d(_0x58492e);});});}exports[_0xf8b6('0x1b')]=function(_0x1cc304){var _0x25e177=this;return new Promise(function(_0x152c95,_0x28c66a){return db[_0xf8b6('0x1c')][_0xf8b6('0x1d')]({'raw':_0x1cc304[_0xf8b6('0x1e')]?_0x1cc304[_0xf8b6('0x1e')][_0xf8b6('0x1f')]===undefined?!![]:![]:!![],'where':_0x1cc304[_0xf8b6('0x1e')]?_0x1cc304['options'][_0xf8b6('0x20')]||null:null,'attributes':_0x1cc304[_0xf8b6('0x1e')]?_0x1cc304[_0xf8b6('0x1e')]['attributes']||null:null,'limit':_0x1cc304[_0xf8b6('0x1e')]?_0x1cc304[_0xf8b6('0x1e')][_0xf8b6('0x21')]||null:null,'include':_0x1cc304[_0xf8b6('0x1e')]?_0x1cc304[_0xf8b6('0x1e')][_0xf8b6('0x22')]?_[_0xf8b6('0x23')](_0x1cc304[_0xf8b6('0x1e')]['include'],function(_0x410c9a){return{'model':db[_0x410c9a[_0xf8b6('0x24')]],'as':_0x410c9a['as'],'attributes':_0x410c9a[_0xf8b6('0x25')],'include':_0x410c9a[_0xf8b6('0x22')]?_[_0xf8b6('0x23')](_0x410c9a[_0xf8b6('0x22')],function(_0x364652){return{'model':db[_0x364652[_0xf8b6('0x24')]],'as':_0x364652['as'],'attributes':_0x364652['attributes'],'include':_0x364652[_0xf8b6('0x22')]?_['map'](_0x364652[_0xf8b6('0x22')],function(_0x4b5c94){return{'model':db[_0x4b5c94[_0xf8b6('0x24')]],'as':_0x4b5c94['as'],'attributes':_0x4b5c94[_0xf8b6('0x25')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x770534){logger['info'](_0xf8b6('0x1b'),_0x1cc304);logger[_0xf8b6('0x26')](_0xf8b6('0x1b'),_0x1cc304,JSON['stringify'](_0x770534));_0x152c95(_0x770534);})[_0xf8b6('0x1a')](function(_0x1e73ef){logger[_0xf8b6('0x16')](_0xf8b6('0x1b'),_0x1e73ef[_0xf8b6('0x18')],_0x1cc304);_0x28c66a(_0x25e177[_0xf8b6('0x16')](0x1f4,_0x1e73ef[_0xf8b6('0x18')]));});});};exports['ShowChatQueue']=function(_0x4cc242){var _0x171580=this;return new Promise(function(_0xb6363c,_0x11764e){return db[_0xf8b6('0x1c')][_0xf8b6('0x27')]({'raw':_0x4cc242['options']?_0x4cc242[_0xf8b6('0x1e')][_0xf8b6('0x1f')]===undefined?!![]:![]:!![],'where':_0x4cc242[_0xf8b6('0x1e')]?_0x4cc242['options']['where']||null:null,'attributes':_0x4cc242['options']?_0x4cc242['options'][_0xf8b6('0x25')]||null:null,'include':_0x4cc242[_0xf8b6('0x1e')]?_0x4cc242[_0xf8b6('0x1e')][_0xf8b6('0x22')]?_[_0xf8b6('0x23')](_0x4cc242[_0xf8b6('0x1e')]['include'],function(_0x521888){return{'model':db[_0x521888[_0xf8b6('0x24')]],'as':_0x521888['as'],'attributes':_0x521888['attributes'],'include':_0x521888[_0xf8b6('0x22')]?_[_0xf8b6('0x23')](_0x521888[_0xf8b6('0x22')],function(_0x79b3c){return{'model':db[_0x79b3c[_0xf8b6('0x24')]],'as':_0x79b3c['as'],'attributes':_0x79b3c['attributes'],'include':_0x79b3c[_0xf8b6('0x22')]?_[_0xf8b6('0x23')](_0x79b3c[_0xf8b6('0x22')],function(_0x950494){return{'model':db[_0x950494[_0xf8b6('0x24')]],'as':_0x950494['as'],'attributes':_0x950494[_0xf8b6('0x25')]};}):[]};}):[]};}):[]:[]})[_0xf8b6('0x12')](function(_0x36e86b){logger[_0xf8b6('0x19')]('ShowChatQueue',_0x4cc242);logger['debug'](_0xf8b6('0x28'),_0x4cc242,JSON['stringify'](_0x36e86b));_0xb6363c(_0x36e86b);})[_0xf8b6('0x1a')](function(_0x1b47e3){logger['error'](_0xf8b6('0x28'),_0x1b47e3[_0xf8b6('0x18')],_0x4cc242);_0x11764e(_0x171580['error'](0x1f4,_0x1b47e3['message']));});});};