Built motion from commit (unavailable).|2.5.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 _0xae59=['then','ChatQueue,\x20%s,\x20%s','ChatQueue,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','GetChatQueue','ChatQueue','findAll','options','raw','map','include','model','attributes','info','debug','stringify','catch','ShowChatQueue','find','where','lodash','moment','bluebird','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','register','request'];(function(_0xf26c2e,_0x56c3ea){var _0x46ecb4=function(_0x1be516){while(--_0x1be516){_0xf26c2e['push'](_0xf26c2e['shift']());}};_0x46ecb4(++_0x56c3ea);}(_0xae59,0x8d));var _0x9ae5=function(_0x1dfbd8,_0x54e99a){_0x1dfbd8=_0x1dfbd8-0x0;var _0x285e63=_0xae59[_0x1dfbd8];return _0x285e63;};'use strict';var _=require(_0x9ae5('0x0'));var util=require('util');var moment=require(_0x9ae5('0x1'));var BPromise=require(_0x9ae5('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x9ae5('0x3'));var db=require('../../mysqldb')['db'];var utils=require(_0x9ae5('0x4'));var logger=require('../../config/logger')(_0x9ae5('0x5'));var config=require(_0x9ae5('0x6'));var jayson=require(_0x9ae5('0x7'));var client=jayson[_0x9ae5('0x8')][_0x9ae5('0x9')]({'port':0x232a});config[_0x9ae5('0xa')]=_[_0x9ae5('0xb')](config[_0x9ae5('0xa')],{'host':_0x9ae5('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./chatQueue.socket')[_0x9ae5('0xd')](socket);function respondWithRpcPromise(_0x302d4c,_0x669c38,_0x44626a){return new BPromise(function(_0x2e0557,_0x27684b){return client[_0x9ae5('0xe')](_0x302d4c,_0x44626a)[_0x9ae5('0xf')](function(_0x30a7ca){logger['info'](_0x9ae5('0x10'),_0x669c38,'request\x20sent');logger['debug'](_0x9ae5('0x11'),_0x669c38,_0x9ae5('0x12'),JSON['stringify'](_0x30a7ca));if(_0x30a7ca[_0x9ae5('0x13')]){if(_0x30a7ca[_0x9ae5('0x13')][_0x9ae5('0x14')]===0x1f4){logger[_0x9ae5('0x13')](_0x9ae5('0x10'),_0x669c38,_0x30a7ca[_0x9ae5('0x13')][_0x9ae5('0x15')]);return _0x27684b(_0x30a7ca[_0x9ae5('0x13')][_0x9ae5('0x15')]);}logger[_0x9ae5('0x13')](_0x9ae5('0x10'),_0x669c38,_0x30a7ca[_0x9ae5('0x13')][_0x9ae5('0x15')]);return _0x2e0557(_0x30a7ca[_0x9ae5('0x13')][_0x9ae5('0x15')]);}else{logger['info'](_0x9ae5('0x10'),_0x669c38,_0x9ae5('0x12'));_0x2e0557(_0x30a7ca[_0x9ae5('0x16')][_0x9ae5('0x15')]);}})['catch'](function(_0x569931){logger[_0x9ae5('0x13')](_0x9ae5('0x10'),_0x669c38,_0x569931);_0x27684b(_0x569931);});});}exports[_0x9ae5('0x17')]=function(_0x483a27){var _0x1c42f2=this;return new Promise(function(_0xc086de,_0x69855d){return db[_0x9ae5('0x18')][_0x9ae5('0x19')]({'raw':_0x483a27['options']?_0x483a27[_0x9ae5('0x1a')][_0x9ae5('0x1b')]===undefined?!![]:![]:!![],'where':_0x483a27[_0x9ae5('0x1a')]?_0x483a27['options']['where']||null:null,'attributes':_0x483a27[_0x9ae5('0x1a')]?_0x483a27[_0x9ae5('0x1a')]['attributes']||null:null,'limit':_0x483a27[_0x9ae5('0x1a')]?_0x483a27['options']['limit']||null:null,'include':_0x483a27['options']?_0x483a27[_0x9ae5('0x1a')]['include']?_[_0x9ae5('0x1c')](_0x483a27[_0x9ae5('0x1a')][_0x9ae5('0x1d')],function(_0x29d330){return{'model':db[_0x29d330[_0x9ae5('0x1e')]],'as':_0x29d330['as'],'attributes':_0x29d330[_0x9ae5('0x1f')],'include':_0x29d330['include']?_['map'](_0x29d330[_0x9ae5('0x1d')],function(_0x276f2b){return{'model':db[_0x276f2b[_0x9ae5('0x1e')]],'as':_0x276f2b['as'],'attributes':_0x276f2b[_0x9ae5('0x1f')],'include':_0x276f2b[_0x9ae5('0x1d')]?_[_0x9ae5('0x1c')](_0x276f2b[_0x9ae5('0x1d')],function(_0x38919f){return{'model':db[_0x38919f[_0x9ae5('0x1e')]],'as':_0x38919f['as'],'attributes':_0x38919f['attributes']};}):[]};}):[]};}):[]:[]})[_0x9ae5('0xf')](function(_0x8fbae0){logger[_0x9ae5('0x20')]('GetChatQueue',_0x483a27);logger[_0x9ae5('0x21')](_0x9ae5('0x17'),_0x483a27,JSON[_0x9ae5('0x22')](_0x8fbae0));_0xc086de(_0x8fbae0);})[_0x9ae5('0x23')](function(_0x3cb0c7){logger[_0x9ae5('0x13')]('GetChatQueue',_0x3cb0c7[_0x9ae5('0x15')],_0x483a27);_0x69855d(_0x1c42f2[_0x9ae5('0x13')](0x1f4,_0x3cb0c7[_0x9ae5('0x15')]));});});};exports[_0x9ae5('0x24')]=function(_0x15f31c){var _0x48389d=this;return new Promise(function(_0x5edb8d,_0x54bd77){return db['ChatQueue'][_0x9ae5('0x25')]({'raw':_0x15f31c['options']?_0x15f31c[_0x9ae5('0x1a')][_0x9ae5('0x1b')]===undefined?!![]:![]:!![],'where':_0x15f31c[_0x9ae5('0x1a')]?_0x15f31c[_0x9ae5('0x1a')][_0x9ae5('0x26')]||null:null,'attributes':_0x15f31c[_0x9ae5('0x1a')]?_0x15f31c[_0x9ae5('0x1a')][_0x9ae5('0x1f')]||null:null,'include':_0x15f31c[_0x9ae5('0x1a')]?_0x15f31c[_0x9ae5('0x1a')][_0x9ae5('0x1d')]?_['map'](_0x15f31c[_0x9ae5('0x1a')][_0x9ae5('0x1d')],function(_0xd2ee66){return{'model':db[_0xd2ee66['model']],'as':_0xd2ee66['as'],'attributes':_0xd2ee66['attributes'],'include':_0xd2ee66[_0x9ae5('0x1d')]?_[_0x9ae5('0x1c')](_0xd2ee66['include'],function(_0x4983e5){return{'model':db[_0x4983e5['model']],'as':_0x4983e5['as'],'attributes':_0x4983e5[_0x9ae5('0x1f')],'include':_0x4983e5[_0x9ae5('0x1d')]?_[_0x9ae5('0x1c')](_0x4983e5[_0x9ae5('0x1d')],function(_0x3b0725){return{'model':db[_0x3b0725[_0x9ae5('0x1e')]],'as':_0x3b0725['as'],'attributes':_0x3b0725['attributes']};}):[]};}):[]};}):[]:[]})[_0x9ae5('0xf')](function(_0x591889){logger['info'](_0x9ae5('0x24'),_0x15f31c);logger['debug']('ShowChatQueue',_0x15f31c,JSON['stringify'](_0x591889));_0x5edb8d(_0x591889);})[_0x9ae5('0x23')](function(_0x462221){logger['error'](_0x9ae5('0x24'),_0x462221[_0x9ae5('0x15')],_0x15f31c);_0x54bd77(_0x48389d['error'](0x1f4,_0x462221[_0x9ae5('0x15')]));});});};