Built motion from commit 1fa89557.|2.6.10
[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 _0xcd1a=['randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','redis','localhost','request','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','where','attributes','limit','include','map','model','ShowMailQueue','find','lodash','util','moment'];(function(_0x3cb95f,_0x401148){var _0x386469=function(_0xb305){while(--_0xb305){_0x3cb95f['push'](_0x3cb95f['shift']());}};_0x386469(++_0x401148);}(_0xcd1a,0x115));var _0xacd1=function(_0x2064e5,_0x4f6fa2){_0x2064e5=_0x2064e5-0x0;var _0x21a233=_0xcd1a[_0x2064e5];return _0x21a233;};'use strict';var _=require(_0xacd1('0x0'));var util=require(_0xacd1('0x1'));var moment=require(_0xacd1('0x2'));var BPromise=require('bluebird');var rs=require(_0xacd1('0x3'));var fs=require('fs');var Redis=require(_0xacd1('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xacd1('0x5'));var logger=require('../../config/logger')(_0xacd1('0x6'));var config=require(_0xacd1('0x7'));var jayson=require(_0xacd1('0x8'));var client=jayson[_0xacd1('0x9')][_0xacd1('0xa')]({'port':0x232a});config['redis']=_[_0xacd1('0xb')](config[_0xacd1('0xc')],{'host':_0xacd1('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./mailQueue.socket')['register'](socket);function respondWithRpcPromise(_0x562c11,_0x3426f1,_0x118302){return new BPromise(function(_0x25e2ef,_0x47cda7){return client[_0xacd1('0xe')](_0x562c11,_0x118302)[_0xacd1('0xf')](function(_0x316326){logger[_0xacd1('0x10')](_0xacd1('0x11'),_0x3426f1,_0xacd1('0x12'));logger[_0xacd1('0x13')](_0xacd1('0x14'),_0x3426f1,_0xacd1('0x12'),JSON[_0xacd1('0x15')](_0x316326));if(_0x316326[_0xacd1('0x16')]){if(_0x316326['error'][_0xacd1('0x17')]===0x1f4){logger[_0xacd1('0x16')](_0xacd1('0x11'),_0x3426f1,_0x316326[_0xacd1('0x16')]['message']);return _0x47cda7(_0x316326['error'][_0xacd1('0x18')]);}logger[_0xacd1('0x16')](_0xacd1('0x11'),_0x3426f1,_0x316326['error']['message']);return _0x25e2ef(_0x316326['error']['message']);}else{logger['info'](_0xacd1('0x11'),_0x3426f1,_0xacd1('0x12'));_0x25e2ef(_0x316326[_0xacd1('0x19')][_0xacd1('0x18')]);}})[_0xacd1('0x1a')](function(_0x50d696){logger['error']('MailQueue,\x20%s,\x20%s',_0x3426f1,_0x50d696);_0x47cda7(_0x50d696);});});}exports[_0xacd1('0x1b')]=function(_0xf50ce4){var _0x1b18cc=this;return new Promise(function(_0x3c268f,_0x373565){return db[_0xacd1('0x1c')][_0xacd1('0x1d')]({'raw':_0xf50ce4[_0xacd1('0x1e')]?_0xf50ce4[_0xacd1('0x1e')][_0xacd1('0x1f')]===undefined?!![]:![]:!![],'where':_0xf50ce4[_0xacd1('0x1e')]?_0xf50ce4[_0xacd1('0x1e')][_0xacd1('0x20')]||null:null,'attributes':_0xf50ce4['options']?_0xf50ce4[_0xacd1('0x1e')][_0xacd1('0x21')]||null:null,'limit':_0xf50ce4[_0xacd1('0x1e')]?_0xf50ce4['options'][_0xacd1('0x22')]||null:null,'include':_0xf50ce4[_0xacd1('0x1e')]?_0xf50ce4[_0xacd1('0x1e')]['include']?_['map'](_0xf50ce4[_0xacd1('0x1e')]['include'],function(_0x3d6a1f){return{'model':db[_0x3d6a1f['model']],'as':_0x3d6a1f['as'],'attributes':_0x3d6a1f[_0xacd1('0x21')],'include':_0x3d6a1f[_0xacd1('0x23')]?_[_0xacd1('0x24')](_0x3d6a1f[_0xacd1('0x23')],function(_0x3a1a01){return{'model':db[_0x3a1a01[_0xacd1('0x25')]],'as':_0x3a1a01['as'],'attributes':_0x3a1a01[_0xacd1('0x21')],'include':_0x3a1a01['include']?_[_0xacd1('0x24')](_0x3a1a01['include'],function(_0x5379ee){return{'model':db[_0x5379ee[_0xacd1('0x25')]],'as':_0x5379ee['as'],'attributes':_0x5379ee['attributes']};}):[]};}):[]};}):[]:[]})[_0xacd1('0xf')](function(_0x389082){logger[_0xacd1('0x10')](_0xacd1('0x1b'),_0xf50ce4);logger['debug']('GetMailQueue',_0xf50ce4,JSON[_0xacd1('0x15')](_0x389082));_0x3c268f(_0x389082);})[_0xacd1('0x1a')](function(_0x371cbb){logger[_0xacd1('0x16')]('GetMailQueue',_0x371cbb[_0xacd1('0x18')],_0xf50ce4);_0x373565(_0x1b18cc['error'](0x1f4,_0x371cbb[_0xacd1('0x18')]));});});};exports[_0xacd1('0x26')]=function(_0x53db5f){var _0x1003b8=this;return new Promise(function(_0xa502fe,_0x3d6a8c){return db['MailQueue'][_0xacd1('0x27')]({'raw':_0x53db5f[_0xacd1('0x1e')]?_0x53db5f[_0xacd1('0x1e')][_0xacd1('0x1f')]===undefined?!![]:![]:!![],'where':_0x53db5f[_0xacd1('0x1e')]?_0x53db5f['options'][_0xacd1('0x20')]||null:null,'attributes':_0x53db5f[_0xacd1('0x1e')]?_0x53db5f['options']['attributes']||null:null,'include':_0x53db5f['options']?_0x53db5f[_0xacd1('0x1e')][_0xacd1('0x23')]?_[_0xacd1('0x24')](_0x53db5f[_0xacd1('0x1e')][_0xacd1('0x23')],function(_0x2d2c53){return{'model':db[_0x2d2c53[_0xacd1('0x25')]],'as':_0x2d2c53['as'],'attributes':_0x2d2c53[_0xacd1('0x21')],'include':_0x2d2c53['include']?_[_0xacd1('0x24')](_0x2d2c53['include'],function(_0x56eef6){return{'model':db[_0x56eef6[_0xacd1('0x25')]],'as':_0x56eef6['as'],'attributes':_0x56eef6[_0xacd1('0x21')],'include':_0x56eef6[_0xacd1('0x23')]?_[_0xacd1('0x24')](_0x56eef6[_0xacd1('0x23')],function(_0x1f7384){return{'model':db[_0x1f7384[_0xacd1('0x25')]],'as':_0x1f7384['as'],'attributes':_0x1f7384['attributes']};}):[]};}):[]};}):[]:[]})[_0xacd1('0xf')](function(_0x367ae3){logger[_0xacd1('0x10')](_0xacd1('0x26'),_0x53db5f);logger[_0xacd1('0x13')](_0xacd1('0x26'),_0x53db5f,JSON['stringify'](_0x367ae3));_0xa502fe(_0x367ae3);})[_0xacd1('0x1a')](function(_0x42607c){logger[_0xacd1('0x16')]('ShowMailQueue',_0x42607c[_0xacd1('0x18')],_0x53db5f);_0x3d6a8c(_0x1003b8[_0xacd1('0x16')](0x1f4,_0x42607c[_0xacd1('0x18')]));});});};