Built motion from commit 42801a18.|2.6.28
[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 _0x8c28=['where','limit','map','include','model','attributes','ShowMailQueue','find','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','socket.io-emitter','./mailQueue.socket','register','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','MailQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetMailQueue','MailQueue','findAll','options','raw'];(function(_0x380eea,_0x2b9d83){var _0x377f16=function(_0x419470){while(--_0x419470){_0x380eea['push'](_0x380eea['shift']());}};_0x377f16(++_0x2b9d83);}(_0x8c28,0x198));var _0x88c2=function(_0x128694,_0x1c62be){_0x128694=_0x128694-0x0;var _0x4f16b1=_0x8c28[_0x128694];return _0x4f16b1;};'use strict';var _=require(_0x88c2('0x0'));var util=require(_0x88c2('0x1'));var moment=require(_0x88c2('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x88c2('0x3'));var db=require(_0x88c2('0x4'))['db'];var utils=require(_0x88c2('0x5'));var logger=require(_0x88c2('0x6'))(_0x88c2('0x7'));var config=require(_0x88c2('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x88c2('0x9')][_0x88c2('0xa')]({'port':0x232a});config[_0x88c2('0xb')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x88c2('0xc'))(new Redis(config['redis']));require(_0x88c2('0xd'))[_0x88c2('0xe')](socket);function respondWithRpcPromise(_0x39bfdc,_0x3edafc,_0x271d87){return new BPromise(function(_0x3026e7,_0x320d4d){return client['request'](_0x39bfdc,_0x271d87)[_0x88c2('0xf')](function(_0x175dcf){logger[_0x88c2('0x10')](_0x88c2('0x11'),_0x3edafc,_0x88c2('0x12'));logger[_0x88c2('0x13')](_0x88c2('0x14'),_0x3edafc,_0x88c2('0x12'),JSON[_0x88c2('0x15')](_0x175dcf));if(_0x175dcf[_0x88c2('0x16')]){if(_0x175dcf[_0x88c2('0x16')][_0x88c2('0x17')]===0x1f4){logger[_0x88c2('0x16')](_0x88c2('0x11'),_0x3edafc,_0x175dcf[_0x88c2('0x16')][_0x88c2('0x18')]);return _0x320d4d(_0x175dcf[_0x88c2('0x16')][_0x88c2('0x18')]);}logger['error'](_0x88c2('0x11'),_0x3edafc,_0x175dcf[_0x88c2('0x16')][_0x88c2('0x18')]);return _0x3026e7(_0x175dcf[_0x88c2('0x16')][_0x88c2('0x18')]);}else{logger[_0x88c2('0x10')](_0x88c2('0x11'),_0x3edafc,_0x88c2('0x12'));_0x3026e7(_0x175dcf[_0x88c2('0x19')][_0x88c2('0x18')]);}})[_0x88c2('0x1a')](function(_0x4ca70e){logger[_0x88c2('0x16')]('MailQueue,\x20%s,\x20%s',_0x3edafc,_0x4ca70e);_0x320d4d(_0x4ca70e);});});}exports[_0x88c2('0x1b')]=function(_0x586161){var _0x262002=this;return new Promise(function(_0x6169ed,_0x25e075){return db[_0x88c2('0x1c')][_0x88c2('0x1d')]({'raw':_0x586161[_0x88c2('0x1e')]?_0x586161[_0x88c2('0x1e')][_0x88c2('0x1f')]===undefined?!![]:![]:!![],'where':_0x586161[_0x88c2('0x1e')]?_0x586161[_0x88c2('0x1e')][_0x88c2('0x20')]||null:null,'attributes':_0x586161['options']?_0x586161[_0x88c2('0x1e')]['attributes']||null:null,'limit':_0x586161[_0x88c2('0x1e')]?_0x586161[_0x88c2('0x1e')][_0x88c2('0x21')]||null:null,'include':_0x586161[_0x88c2('0x1e')]?_0x586161[_0x88c2('0x1e')]['include']?_[_0x88c2('0x22')](_0x586161['options'][_0x88c2('0x23')],function(_0x2405c5){return{'model':db[_0x2405c5[_0x88c2('0x24')]],'as':_0x2405c5['as'],'attributes':_0x2405c5[_0x88c2('0x25')],'include':_0x2405c5[_0x88c2('0x23')]?_[_0x88c2('0x22')](_0x2405c5[_0x88c2('0x23')],function(_0x241a16){return{'model':db[_0x241a16['model']],'as':_0x241a16['as'],'attributes':_0x241a16['attributes'],'include':_0x241a16[_0x88c2('0x23')]?_[_0x88c2('0x22')](_0x241a16[_0x88c2('0x23')],function(_0x103e98){return{'model':db[_0x103e98['model']],'as':_0x103e98['as'],'attributes':_0x103e98[_0x88c2('0x25')]};}):[]};}):[]};}):[]:[]})[_0x88c2('0xf')](function(_0xef2b49){logger['info'](_0x88c2('0x1b'),_0x586161);logger[_0x88c2('0x13')](_0x88c2('0x1b'),_0x586161,JSON['stringify'](_0xef2b49));_0x6169ed(_0xef2b49);})[_0x88c2('0x1a')](function(_0x1c1084){logger[_0x88c2('0x16')](_0x88c2('0x1b'),_0x1c1084[_0x88c2('0x18')],_0x586161);_0x25e075(_0x262002['error'](0x1f4,_0x1c1084['message']));});});};exports[_0x88c2('0x26')]=function(_0x13609e){var _0x304be0=this;return new Promise(function(_0x4d1633,_0x456c3b){return db[_0x88c2('0x1c')][_0x88c2('0x27')]({'raw':_0x13609e[_0x88c2('0x1e')]?_0x13609e['options']['raw']===undefined?!![]:![]:!![],'where':_0x13609e['options']?_0x13609e['options'][_0x88c2('0x20')]||null:null,'attributes':_0x13609e[_0x88c2('0x1e')]?_0x13609e[_0x88c2('0x1e')][_0x88c2('0x25')]||null:null,'include':_0x13609e[_0x88c2('0x1e')]?_0x13609e['options'][_0x88c2('0x23')]?_['map'](_0x13609e[_0x88c2('0x1e')][_0x88c2('0x23')],function(_0x125e0e){return{'model':db[_0x125e0e['model']],'as':_0x125e0e['as'],'attributes':_0x125e0e[_0x88c2('0x25')],'include':_0x125e0e[_0x88c2('0x23')]?_[_0x88c2('0x22')](_0x125e0e[_0x88c2('0x23')],function(_0x333f13){return{'model':db[_0x333f13[_0x88c2('0x24')]],'as':_0x333f13['as'],'attributes':_0x333f13[_0x88c2('0x25')],'include':_0x333f13[_0x88c2('0x23')]?_['map'](_0x333f13[_0x88c2('0x23')],function(_0x1ca20b){return{'model':db[_0x1ca20b[_0x88c2('0x24')]],'as':_0x1ca20b['as'],'attributes':_0x1ca20b[_0x88c2('0x25')]};}):[]};}):[]};}):[]:[]})[_0x88c2('0xf')](function(_0x525ed1){logger[_0x88c2('0x10')](_0x88c2('0x26'),_0x13609e);logger['debug'](_0x88c2('0x26'),_0x13609e,JSON[_0x88c2('0x15')](_0x525ed1));_0x4d1633(_0x525ed1);})[_0x88c2('0x1a')](function(_0x2b681e){logger[_0x88c2('0x16')](_0x88c2('0x26'),_0x2b681e[_0x88c2('0x18')],_0x13609e);_0x456c3b(_0x304be0['error'](0x1f4,_0x2b681e[_0x88c2('0x18')]));});});};