cd1be83ce61c553b70c65cd5b2c79f204767e763
[motion2.git] / server / api / mailQueue / mailQueue.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 _0x983a=['where','attributes','limit','include','map','model','then','GetMailQueue','find','ShowMailQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','./mailQueue.socket','register','request','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','MailQueue','options','raw'];(function(_0x32df68,_0x58b4a8){var _0x1163df=function(_0x1a2ac4){while(--_0x1a2ac4){_0x32df68['push'](_0x32df68['shift']());}};_0x1163df(++_0x58b4a8);}(_0x983a,0x100));var _0xa983=function(_0x3696ae,_0x4c462a){_0x3696ae=_0x3696ae-0x0;var _0x3d55c7=_0x983a[_0x3696ae];return _0x3d55c7;};'use strict';var _=require(_0xa983('0x0'));var util=require(_0xa983('0x1'));var moment=require(_0xa983('0x2'));var BPromise=require(_0xa983('0x3'));var rs=require(_0xa983('0x4'));var fs=require('fs');var Redis=require(_0xa983('0x5'));var db=require(_0xa983('0x6'))['db'];var utils=require(_0xa983('0x7'));var logger=require(_0xa983('0x8'))('rpc');var config=require(_0xa983('0x9'));var jayson=require(_0xa983('0xa'));var client=jayson[_0xa983('0xb')][_0xa983('0xc')]({'port':0x232a});config[_0xa983('0xd')]=_[_0xa983('0xe')](config[_0xa983('0xd')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa983('0xd')]));require(_0xa983('0xf'))[_0xa983('0x10')](socket);function respondWithRpcPromise(_0x1ceba6,_0x305651,_0x5b8832){return new BPromise(function(_0x2c0a2f,_0x10174b){return client[_0xa983('0x11')](_0x1ceba6,_0x5b8832)['then'](function(_0x14e08d){logger[_0xa983('0x12')](_0xa983('0x13'),_0x305651,_0xa983('0x14'));logger[_0xa983('0x15')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x305651,_0xa983('0x14'),JSON[_0xa983('0x16')](_0x14e08d));if(_0x14e08d[_0xa983('0x17')]){if(_0x14e08d[_0xa983('0x17')][_0xa983('0x18')]===0x1f4){logger[_0xa983('0x17')](_0xa983('0x13'),_0x305651,_0x14e08d[_0xa983('0x17')][_0xa983('0x19')]);return _0x10174b(_0x14e08d[_0xa983('0x17')][_0xa983('0x19')]);}logger[_0xa983('0x17')](_0xa983('0x13'),_0x305651,_0x14e08d[_0xa983('0x17')]['message']);return _0x2c0a2f(_0x14e08d[_0xa983('0x17')][_0xa983('0x19')]);}else{logger[_0xa983('0x12')]('MailQueue,\x20%s,\x20%s',_0x305651,_0xa983('0x14'));_0x2c0a2f(_0x14e08d[_0xa983('0x1a')][_0xa983('0x19')]);}})[_0xa983('0x1b')](function(_0x26fab7){logger[_0xa983('0x17')](_0xa983('0x13'),_0x305651,_0x26fab7);_0x10174b(_0x26fab7);});});}exports['GetMailQueue']=function(_0x1e4da5){var _0x4e8be0=this;return new Promise(function(_0x4caf20,_0x470447){return db[_0xa983('0x1c')]['findAll']({'raw':_0x1e4da5['options']?_0x1e4da5[_0xa983('0x1d')][_0xa983('0x1e')]===undefined?!![]:![]:!![],'where':_0x1e4da5[_0xa983('0x1d')]?_0x1e4da5['options'][_0xa983('0x1f')]||null:null,'attributes':_0x1e4da5[_0xa983('0x1d')]?_0x1e4da5[_0xa983('0x1d')][_0xa983('0x20')]||null:null,'limit':_0x1e4da5['options']?_0x1e4da5['options'][_0xa983('0x21')]||null:null,'include':_0x1e4da5['options']?_0x1e4da5[_0xa983('0x1d')]['include']?_['map'](_0x1e4da5[_0xa983('0x1d')][_0xa983('0x22')],function(_0x2d80ef){return{'model':db[_0x2d80ef['model']],'as':_0x2d80ef['as'],'attributes':_0x2d80ef[_0xa983('0x20')],'include':_0x2d80ef[_0xa983('0x22')]?_[_0xa983('0x23')](_0x2d80ef[_0xa983('0x22')],function(_0x399f4b){return{'model':db[_0x399f4b['model']],'as':_0x399f4b['as'],'attributes':_0x399f4b['attributes'],'include':_0x399f4b[_0xa983('0x22')]?_[_0xa983('0x23')](_0x399f4b['include'],function(_0x55324c){return{'model':db[_0x55324c[_0xa983('0x24')]],'as':_0x55324c['as'],'attributes':_0x55324c['attributes']};}):[]};}):[]};}):[]:[]})[_0xa983('0x25')](function(_0x38e876){logger['info'](_0xa983('0x26'),_0x1e4da5);logger[_0xa983('0x15')]('GetMailQueue',_0x1e4da5,JSON[_0xa983('0x16')](_0x38e876));_0x4caf20(_0x38e876);})[_0xa983('0x1b')](function(_0x48eaa3){logger[_0xa983('0x17')](_0xa983('0x26'),_0x48eaa3[_0xa983('0x19')],_0x1e4da5);_0x470447(_0x4e8be0[_0xa983('0x17')](0x1f4,_0x48eaa3[_0xa983('0x19')]));});});};exports['ShowMailQueue']=function(_0x4982dc){var _0x2a2c5f=this;return new Promise(function(_0x9189a5,_0x177da4){return db[_0xa983('0x1c')][_0xa983('0x27')]({'raw':_0x4982dc[_0xa983('0x1d')]?_0x4982dc[_0xa983('0x1d')][_0xa983('0x1e')]===undefined?!![]:![]:!![],'where':_0x4982dc['options']?_0x4982dc['options'][_0xa983('0x1f')]||null:null,'attributes':_0x4982dc[_0xa983('0x1d')]?_0x4982dc[_0xa983('0x1d')]['attributes']||null:null,'include':_0x4982dc[_0xa983('0x1d')]?_0x4982dc[_0xa983('0x1d')]['include']?_[_0xa983('0x23')](_0x4982dc[_0xa983('0x1d')][_0xa983('0x22')],function(_0x19ac37){return{'model':db[_0x19ac37[_0xa983('0x24')]],'as':_0x19ac37['as'],'attributes':_0x19ac37[_0xa983('0x20')],'include':_0x19ac37[_0xa983('0x22')]?_['map'](_0x19ac37['include'],function(_0x2f8c4d){return{'model':db[_0x2f8c4d[_0xa983('0x24')]],'as':_0x2f8c4d['as'],'attributes':_0x2f8c4d['attributes'],'include':_0x2f8c4d[_0xa983('0x22')]?_[_0xa983('0x23')](_0x2f8c4d['include'],function(_0x559265){return{'model':db[_0x559265[_0xa983('0x24')]],'as':_0x559265['as'],'attributes':_0x559265[_0xa983('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x266eef){logger[_0xa983('0x12')]('ShowMailQueue',_0x4982dc);logger[_0xa983('0x15')]('ShowMailQueue',_0x4982dc,JSON[_0xa983('0x16')](_0x266eef));_0x9189a5(_0x266eef);})[_0xa983('0x1b')](function(_0x509e8b){logger['error'](_0xa983('0x28'),_0x509e8b[_0xa983('0x19')],_0x4982dc);_0x177da4(_0x2a2c5f[_0xa983('0x17')](0x1f4,_0x509e8b[_0xa983('0x19')]));});});};