513f74cd47672ee59c9f2256ab8161304d11b639
[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 _0xbcd0=['then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetMailQueue','MailQueue','findAll','options','raw','where','attributes','limit','include','map','model','ShowMailQueue','find','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./mailQueue.socket'];(function(_0x22babc,_0x434b80){var _0x3641ef=function(_0x45f351){while(--_0x45f351){_0x22babc['push'](_0x22babc['shift']());}};_0x3641ef(++_0x434b80);}(_0xbcd0,0xb8));var _0x0bcd=function(_0x37e2b0,_0x5ba5dd){_0x37e2b0=_0x37e2b0-0x0;var _0xe03021=_0xbcd0[_0x37e2b0];return _0xe03021;};'use strict';var _=require(_0x0bcd('0x0'));var util=require(_0x0bcd('0x1'));var moment=require(_0x0bcd('0x2'));var BPromise=require(_0x0bcd('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x0bcd('0x4'));var db=require(_0x0bcd('0x5'))['db'];var utils=require(_0x0bcd('0x6'));var logger=require(_0x0bcd('0x7'))(_0x0bcd('0x8'));var config=require(_0x0bcd('0x9'));var jayson=require(_0x0bcd('0xa'));var client=jayson['client'][_0x0bcd('0xb')]({'port':0x232a});config[_0x0bcd('0xc')]=_['defaults'](config[_0x0bcd('0xc')],{'host':_0x0bcd('0xd'),'port':0x18eb});var socket=require(_0x0bcd('0xe'))(new Redis(config['redis']));require(_0x0bcd('0xf'))['register'](socket);function respondWithRpcPromise(_0x571fce,_0x4fd427,_0x14090f){return new BPromise(function(_0x2fb1f2,_0x1222e1){return client['request'](_0x571fce,_0x14090f)[_0x0bcd('0x10')](function(_0x32f4e8){logger[_0x0bcd('0x11')](_0x0bcd('0x12'),_0x4fd427,_0x0bcd('0x13'));logger[_0x0bcd('0x14')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x4fd427,_0x0bcd('0x13'),JSON[_0x0bcd('0x15')](_0x32f4e8));if(_0x32f4e8[_0x0bcd('0x16')]){if(_0x32f4e8[_0x0bcd('0x16')][_0x0bcd('0x17')]===0x1f4){logger[_0x0bcd('0x16')](_0x0bcd('0x12'),_0x4fd427,_0x32f4e8[_0x0bcd('0x16')][_0x0bcd('0x18')]);return _0x1222e1(_0x32f4e8[_0x0bcd('0x16')][_0x0bcd('0x18')]);}logger[_0x0bcd('0x16')](_0x0bcd('0x12'),_0x4fd427,_0x32f4e8[_0x0bcd('0x16')]['message']);return _0x2fb1f2(_0x32f4e8['error']['message']);}else{logger[_0x0bcd('0x11')](_0x0bcd('0x12'),_0x4fd427,_0x0bcd('0x13'));_0x2fb1f2(_0x32f4e8[_0x0bcd('0x19')][_0x0bcd('0x18')]);}})[_0x0bcd('0x1a')](function(_0x52785e){logger[_0x0bcd('0x16')](_0x0bcd('0x12'),_0x4fd427,_0x52785e);_0x1222e1(_0x52785e);});});}exports[_0x0bcd('0x1b')]=function(_0x562a35){var _0xf8b76f=this;return new Promise(function(_0x1f886d,_0x2b18bb){return db[_0x0bcd('0x1c')][_0x0bcd('0x1d')]({'raw':_0x562a35[_0x0bcd('0x1e')]?_0x562a35[_0x0bcd('0x1e')][_0x0bcd('0x1f')]===undefined?!![]:![]:!![],'where':_0x562a35[_0x0bcd('0x1e')]?_0x562a35[_0x0bcd('0x1e')][_0x0bcd('0x20')]||null:null,'attributes':_0x562a35['options']?_0x562a35[_0x0bcd('0x1e')][_0x0bcd('0x21')]||null:null,'limit':_0x562a35[_0x0bcd('0x1e')]?_0x562a35['options'][_0x0bcd('0x22')]||null:null,'include':_0x562a35['options']?_0x562a35[_0x0bcd('0x1e')][_0x0bcd('0x23')]?_[_0x0bcd('0x24')](_0x562a35[_0x0bcd('0x1e')][_0x0bcd('0x23')],function(_0x16065b){return{'model':db[_0x16065b['model']],'as':_0x16065b['as'],'attributes':_0x16065b['attributes'],'include':_0x16065b[_0x0bcd('0x23')]?_[_0x0bcd('0x24')](_0x16065b[_0x0bcd('0x23')],function(_0x1d994f){return{'model':db[_0x1d994f['model']],'as':_0x1d994f['as'],'attributes':_0x1d994f[_0x0bcd('0x21')],'include':_0x1d994f[_0x0bcd('0x23')]?_[_0x0bcd('0x24')](_0x1d994f[_0x0bcd('0x23')],function(_0x67c8c2){return{'model':db[_0x67c8c2[_0x0bcd('0x25')]],'as':_0x67c8c2['as'],'attributes':_0x67c8c2['attributes']};}):[]};}):[]};}):[]:[]})[_0x0bcd('0x10')](function(_0x15e33c){logger['info'](_0x0bcd('0x1b'),_0x562a35);logger[_0x0bcd('0x14')](_0x0bcd('0x1b'),_0x562a35,JSON[_0x0bcd('0x15')](_0x15e33c));_0x1f886d(_0x15e33c);})[_0x0bcd('0x1a')](function(_0x4f7a96){logger['error']('GetMailQueue',_0x4f7a96['message'],_0x562a35);_0x2b18bb(_0xf8b76f[_0x0bcd('0x16')](0x1f4,_0x4f7a96[_0x0bcd('0x18')]));});});};exports[_0x0bcd('0x26')]=function(_0x136463){var _0x206607=this;return new Promise(function(_0x3e5697,_0x4aacec){return db[_0x0bcd('0x1c')][_0x0bcd('0x27')]({'raw':_0x136463[_0x0bcd('0x1e')]?_0x136463['options']['raw']===undefined?!![]:![]:!![],'where':_0x136463['options']?_0x136463['options'][_0x0bcd('0x20')]||null:null,'attributes':_0x136463[_0x0bcd('0x1e')]?_0x136463[_0x0bcd('0x1e')][_0x0bcd('0x21')]||null:null,'include':_0x136463[_0x0bcd('0x1e')]?_0x136463[_0x0bcd('0x1e')][_0x0bcd('0x23')]?_['map'](_0x136463[_0x0bcd('0x1e')][_0x0bcd('0x23')],function(_0x551b37){return{'model':db[_0x551b37[_0x0bcd('0x25')]],'as':_0x551b37['as'],'attributes':_0x551b37[_0x0bcd('0x21')],'include':_0x551b37[_0x0bcd('0x23')]?_[_0x0bcd('0x24')](_0x551b37['include'],function(_0x22e505){return{'model':db[_0x22e505[_0x0bcd('0x25')]],'as':_0x22e505['as'],'attributes':_0x22e505[_0x0bcd('0x21')],'include':_0x22e505[_0x0bcd('0x23')]?_[_0x0bcd('0x24')](_0x22e505[_0x0bcd('0x23')],function(_0x36e240){return{'model':db[_0x36e240['model']],'as':_0x36e240['as'],'attributes':_0x36e240[_0x0bcd('0x21')]};}):[]};}):[]};}):[]:[]})[_0x0bcd('0x10')](function(_0x377a74){logger[_0x0bcd('0x11')](_0x0bcd('0x26'),_0x136463);logger[_0x0bcd('0x14')](_0x0bcd('0x26'),_0x136463,JSON[_0x0bcd('0x15')](_0x377a74));_0x3e5697(_0x377a74);})[_0x0bcd('0x1a')](function(_0x49e826){logger[_0x0bcd('0x16')](_0x0bcd('0x26'),_0x49e826[_0x0bcd('0x18')],_0x136463);_0x4aacec(_0x206607[_0x0bcd('0x16')](0x1f4,_0x49e826[_0x0bcd('0x18')]));});});};