Built motion from commit 616d3211.|2.6.4
[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 _0x1e8c=['find','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','./chatQueue.socket','register','request','then','info','ChatQueue,\x20%s,\x20%s','request\x20sent','ChatQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','ChatQueue','findAll','options','raw','where','attributes','limit','include','map','model','GetChatQueue','ShowChatQueue'];(function(_0x348cad,_0x5cf33f){var _0x38e025=function(_0x2326cc){while(--_0x2326cc){_0x348cad['push'](_0x348cad['shift']());}};_0x38e025(++_0x5cf33f);}(_0x1e8c,0xd3));var _0xc1e8=function(_0x462832,_0x3c5525){_0x462832=_0x462832-0x0;var _0x33f578=_0x1e8c[_0x462832];return _0x33f578;};'use strict';var _=require('lodash');var util=require(_0xc1e8('0x0'));var moment=require(_0xc1e8('0x1'));var BPromise=require(_0xc1e8('0x2'));var rs=require(_0xc1e8('0x3'));var fs=require('fs');var Redis=require(_0xc1e8('0x4'));var db=require(_0xc1e8('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc1e8('0x6'))(_0xc1e8('0x7'));var config=require(_0xc1e8('0x8'));var jayson=require(_0xc1e8('0x9'));var client=jayson[_0xc1e8('0xa')][_0xc1e8('0xb')]({'port':0x232a});config['redis']=_[_0xc1e8('0xc')](config[_0xc1e8('0xd')],{'host':_0xc1e8('0xe'),'port':0x18eb});var socket=require(_0xc1e8('0xf'))(new Redis(config[_0xc1e8('0xd')]));require(_0xc1e8('0x10'))[_0xc1e8('0x11')](socket);function respondWithRpcPromise(_0x2c5f56,_0x24c6b0,_0x5e4086){return new BPromise(function(_0x32728a,_0x43a338){return client[_0xc1e8('0x12')](_0x2c5f56,_0x5e4086)[_0xc1e8('0x13')](function(_0x2c4d2d){logger[_0xc1e8('0x14')](_0xc1e8('0x15'),_0x24c6b0,_0xc1e8('0x16'));logger['debug'](_0xc1e8('0x17'),_0x24c6b0,_0xc1e8('0x16'),JSON[_0xc1e8('0x18')](_0x2c4d2d));if(_0x2c4d2d[_0xc1e8('0x19')]){if(_0x2c4d2d[_0xc1e8('0x19')][_0xc1e8('0x1a')]===0x1f4){logger[_0xc1e8('0x19')]('ChatQueue,\x20%s,\x20%s',_0x24c6b0,_0x2c4d2d[_0xc1e8('0x19')][_0xc1e8('0x1b')]);return _0x43a338(_0x2c4d2d['error']['message']);}logger[_0xc1e8('0x19')](_0xc1e8('0x15'),_0x24c6b0,_0x2c4d2d[_0xc1e8('0x19')][_0xc1e8('0x1b')]);return _0x32728a(_0x2c4d2d[_0xc1e8('0x19')]['message']);}else{logger[_0xc1e8('0x14')](_0xc1e8('0x15'),_0x24c6b0,_0xc1e8('0x16'));_0x32728a(_0x2c4d2d['result'][_0xc1e8('0x1b')]);}})[_0xc1e8('0x1c')](function(_0x3ee778){logger[_0xc1e8('0x19')](_0xc1e8('0x15'),_0x24c6b0,_0x3ee778);_0x43a338(_0x3ee778);});});}exports['GetChatQueue']=function(_0x2c2402){var _0x4eb948=this;return new Promise(function(_0x489f3c,_0x3e988b){return db[_0xc1e8('0x1d')][_0xc1e8('0x1e')]({'raw':_0x2c2402[_0xc1e8('0x1f')]?_0x2c2402[_0xc1e8('0x1f')][_0xc1e8('0x20')]===undefined?!![]:![]:!![],'where':_0x2c2402[_0xc1e8('0x1f')]?_0x2c2402[_0xc1e8('0x1f')][_0xc1e8('0x21')]||null:null,'attributes':_0x2c2402[_0xc1e8('0x1f')]?_0x2c2402[_0xc1e8('0x1f')][_0xc1e8('0x22')]||null:null,'limit':_0x2c2402[_0xc1e8('0x1f')]?_0x2c2402['options'][_0xc1e8('0x23')]||null:null,'include':_0x2c2402[_0xc1e8('0x1f')]?_0x2c2402[_0xc1e8('0x1f')][_0xc1e8('0x24')]?_[_0xc1e8('0x25')](_0x2c2402[_0xc1e8('0x1f')][_0xc1e8('0x24')],function(_0x53d25e){return{'model':db[_0x53d25e[_0xc1e8('0x26')]],'as':_0x53d25e['as'],'attributes':_0x53d25e[_0xc1e8('0x22')],'include':_0x53d25e['include']?_['map'](_0x53d25e['include'],function(_0x323132){return{'model':db[_0x323132[_0xc1e8('0x26')]],'as':_0x323132['as'],'attributes':_0x323132[_0xc1e8('0x22')],'include':_0x323132['include']?_[_0xc1e8('0x25')](_0x323132[_0xc1e8('0x24')],function(_0xea3934){return{'model':db[_0xea3934['model']],'as':_0xea3934['as'],'attributes':_0xea3934['attributes']};}):[]};}):[]};}):[]:[]})[_0xc1e8('0x13')](function(_0x57a72f){logger[_0xc1e8('0x14')](_0xc1e8('0x27'),_0x2c2402);logger['debug']('GetChatQueue',_0x2c2402,JSON[_0xc1e8('0x18')](_0x57a72f));_0x489f3c(_0x57a72f);})[_0xc1e8('0x1c')](function(_0x5c5c92){logger['error'](_0xc1e8('0x27'),_0x5c5c92[_0xc1e8('0x1b')],_0x2c2402);_0x3e988b(_0x4eb948[_0xc1e8('0x19')](0x1f4,_0x5c5c92[_0xc1e8('0x1b')]));});});};exports[_0xc1e8('0x28')]=function(_0x2cc7aa){var _0x3bcff5=this;return new Promise(function(_0x212623,_0x2c5cef){return db[_0xc1e8('0x1d')][_0xc1e8('0x29')]({'raw':_0x2cc7aa[_0xc1e8('0x1f')]?_0x2cc7aa[_0xc1e8('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x2cc7aa[_0xc1e8('0x1f')]?_0x2cc7aa[_0xc1e8('0x1f')]['where']||null:null,'attributes':_0x2cc7aa['options']?_0x2cc7aa[_0xc1e8('0x1f')]['attributes']||null:null,'include':_0x2cc7aa[_0xc1e8('0x1f')]?_0x2cc7aa[_0xc1e8('0x1f')][_0xc1e8('0x24')]?_['map'](_0x2cc7aa['options'][_0xc1e8('0x24')],function(_0x4e6004){return{'model':db[_0x4e6004[_0xc1e8('0x26')]],'as':_0x4e6004['as'],'attributes':_0x4e6004['attributes'],'include':_0x4e6004['include']?_[_0xc1e8('0x25')](_0x4e6004[_0xc1e8('0x24')],function(_0x161345){return{'model':db[_0x161345[_0xc1e8('0x26')]],'as':_0x161345['as'],'attributes':_0x161345[_0xc1e8('0x22')],'include':_0x161345['include']?_['map'](_0x161345[_0xc1e8('0x24')],function(_0x50a0a5){return{'model':db[_0x50a0a5[_0xc1e8('0x26')]],'as':_0x50a0a5['as'],'attributes':_0x50a0a5[_0xc1e8('0x22')]};}):[]};}):[]};}):[]:[]})[_0xc1e8('0x13')](function(_0x46c64c){logger['info']('ShowChatQueue',_0x2cc7aa);logger['debug'](_0xc1e8('0x28'),_0x2cc7aa,JSON[_0xc1e8('0x18')](_0x46c64c));_0x212623(_0x46c64c);})[_0xc1e8('0x1c')](function(_0x256be4){logger[_0xc1e8('0x19')](_0xc1e8('0x28'),_0x256be4['message'],_0x2cc7aa);_0x2c5cef(_0x3bcff5['error'](0x1f4,_0x256be4['message']));});});};