Built motion from commit (unavailable).|2.4.3
[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 _0x2523=['request\x20sent','debug','error','ChatQueue,\x20%s,\x20%s','message','info','GetChatQueue','ChatQueue','findAll','options','raw','where','limit','include','map','model','attributes','then','catch','ShowChatQueue','find','stringify','util','moment','bluebird','randomstring','ioredis','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./chatQueue.socket','register'];(function(_0x4f17d3,_0x1f6700){var _0x4a4c9b=function(_0x111098){while(--_0x111098){_0x4f17d3['push'](_0x4f17d3['shift']());}};_0x4a4c9b(++_0x1f6700);}(_0x2523,0x127));var _0x3252=function(_0x4949ba,_0x5a9616){_0x4949ba=_0x4949ba-0x0;var _0x543b99=_0x2523[_0x4949ba];return _0x543b99;};'use strict';var _=require('lodash');var util=require(_0x3252('0x0'));var moment=require(_0x3252('0x1'));var BPromise=require(_0x3252('0x2'));var rs=require(_0x3252('0x3'));var fs=require('fs');var Redis=require(_0x3252('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x3252('0x5'))(_0x3252('0x6'));var config=require(_0x3252('0x7'));var jayson=require(_0x3252('0x8'));var client=jayson[_0x3252('0x9')][_0x3252('0xa')]({'port':0x232a});config[_0x3252('0xb')]=_[_0x3252('0xc')](config[_0x3252('0xb')],{'host':_0x3252('0xd'),'port':0x18eb});var socket=require(_0x3252('0xe'))(new Redis(config[_0x3252('0xb')]));require(_0x3252('0xf'))[_0x3252('0x10')](socket);function respondWithRpcPromise(_0x5a5e71,_0x25966b,_0x1f5036){return new BPromise(function(_0x4002d7,_0x30c623){return client['request'](_0x5a5e71,_0x1f5036)['then'](function(_0x58adc2){logger['info']('ChatQueue,\x20%s,\x20%s',_0x25966b,_0x3252('0x11'));logger[_0x3252('0x12')]('ChatQueue,\x20%s,\x20%s,\x20%s',_0x25966b,_0x3252('0x11'),JSON['stringify'](_0x58adc2));if(_0x58adc2[_0x3252('0x13')]){if(_0x58adc2[_0x3252('0x13')]['code']===0x1f4){logger[_0x3252('0x13')](_0x3252('0x14'),_0x25966b,_0x58adc2[_0x3252('0x13')][_0x3252('0x15')]);return _0x30c623(_0x58adc2[_0x3252('0x13')][_0x3252('0x15')]);}logger[_0x3252('0x13')](_0x3252('0x14'),_0x25966b,_0x58adc2[_0x3252('0x13')][_0x3252('0x15')]);return _0x4002d7(_0x58adc2[_0x3252('0x13')][_0x3252('0x15')]);}else{logger[_0x3252('0x16')]('ChatQueue,\x20%s,\x20%s',_0x25966b,_0x3252('0x11'));_0x4002d7(_0x58adc2['result'][_0x3252('0x15')]);}})['catch'](function(_0x318a69){logger['error'](_0x3252('0x14'),_0x25966b,_0x318a69);_0x30c623(_0x318a69);});});}exports[_0x3252('0x17')]=function(_0x4b8453){var _0x331472=this;return new Promise(function(_0x546496,_0x45c382){return db[_0x3252('0x18')][_0x3252('0x19')]({'raw':_0x4b8453[_0x3252('0x1a')]?_0x4b8453[_0x3252('0x1a')][_0x3252('0x1b')]===undefined?!![]:![]:!![],'where':_0x4b8453['options']?_0x4b8453[_0x3252('0x1a')][_0x3252('0x1c')]||null:null,'attributes':_0x4b8453['options']?_0x4b8453[_0x3252('0x1a')]['attributes']||null:null,'limit':_0x4b8453[_0x3252('0x1a')]?_0x4b8453[_0x3252('0x1a')][_0x3252('0x1d')]||null:null,'include':_0x4b8453['options']?_0x4b8453[_0x3252('0x1a')][_0x3252('0x1e')]?_[_0x3252('0x1f')](_0x4b8453['options'][_0x3252('0x1e')],function(_0x3e409b){return{'model':db[_0x3e409b[_0x3252('0x20')]],'as':_0x3e409b['as'],'attributes':_0x3e409b[_0x3252('0x21')],'include':_0x3e409b[_0x3252('0x1e')]?_['map'](_0x3e409b[_0x3252('0x1e')],function(_0x48e7c6){return{'model':db[_0x48e7c6[_0x3252('0x20')]],'as':_0x48e7c6['as'],'attributes':_0x48e7c6[_0x3252('0x21')],'include':_0x48e7c6['include']?_[_0x3252('0x1f')](_0x48e7c6[_0x3252('0x1e')],function(_0x28aa3b){return{'model':db[_0x28aa3b[_0x3252('0x20')]],'as':_0x28aa3b['as'],'attributes':_0x28aa3b['attributes']};}):[]};}):[]};}):[]:[]})[_0x3252('0x22')](function(_0xe0a774){logger[_0x3252('0x16')](_0x3252('0x17'),_0x4b8453);logger[_0x3252('0x12')]('GetChatQueue',_0x4b8453,JSON['stringify'](_0xe0a774));_0x546496(_0xe0a774);})[_0x3252('0x23')](function(_0x3ced8e){logger[_0x3252('0x13')](_0x3252('0x17'),_0x3ced8e[_0x3252('0x15')],_0x4b8453);_0x45c382(_0x331472[_0x3252('0x13')](0x1f4,_0x3ced8e[_0x3252('0x15')]));});});};exports[_0x3252('0x24')]=function(_0x32b630){var _0x2e106e=this;return new Promise(function(_0x871c61,_0x24edee){return db[_0x3252('0x18')][_0x3252('0x25')]({'raw':_0x32b630[_0x3252('0x1a')]?_0x32b630['options']['raw']===undefined?!![]:![]:!![],'where':_0x32b630[_0x3252('0x1a')]?_0x32b630['options'][_0x3252('0x1c')]||null:null,'attributes':_0x32b630[_0x3252('0x1a')]?_0x32b630[_0x3252('0x1a')]['attributes']||null:null,'include':_0x32b630[_0x3252('0x1a')]?_0x32b630['options']['include']?_[_0x3252('0x1f')](_0x32b630[_0x3252('0x1a')][_0x3252('0x1e')],function(_0x370434){return{'model':db[_0x370434['model']],'as':_0x370434['as'],'attributes':_0x370434[_0x3252('0x21')],'include':_0x370434[_0x3252('0x1e')]?_['map'](_0x370434[_0x3252('0x1e')],function(_0x13c3fb){return{'model':db[_0x13c3fb['model']],'as':_0x13c3fb['as'],'attributes':_0x13c3fb[_0x3252('0x21')],'include':_0x13c3fb['include']?_['map'](_0x13c3fb['include'],function(_0x545a1d){return{'model':db[_0x545a1d['model']],'as':_0x545a1d['as'],'attributes':_0x545a1d[_0x3252('0x21')]};}):[]};}):[]};}):[]:[]})[_0x3252('0x22')](function(_0x4f33f2){logger[_0x3252('0x16')]('ShowChatQueue',_0x32b630);logger[_0x3252('0x12')](_0x3252('0x24'),_0x32b630,JSON[_0x3252('0x26')](_0x4f33f2));_0x871c61(_0x4f33f2);})[_0x3252('0x23')](function(_0x76124d){logger[_0x3252('0x13')](_0x3252('0x24'),_0x76124d[_0x3252('0x15')],_0x32b630);_0x24edee(_0x2e106e[_0x3252('0x13')](0x1f4,_0x76124d[_0x3252('0x15')]));});});};