Built motion from commit 87cd5f02.|2.5.48
[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 _0xffda=['../../mysqldb','../../config/utils','rpc','jayson/promise','client','defaults','redis','localhost','./mailQueue.socket','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','MailQueue,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','GetMailQueue','MailQueue','findAll','options','raw','where','attributes','limit','map','include','model','ShowMailQueue','find','lodash','util','moment','bluebird','ioredis'];(function(_0x57dd9c,_0x36ecca){var _0x1d70a4=function(_0x53fedb){while(--_0x53fedb){_0x57dd9c['push'](_0x57dd9c['shift']());}};_0x1d70a4(++_0x36ecca);}(_0xffda,0x73));var _0xaffd=function(_0x388fb0,_0x5f3ff5){_0x388fb0=_0x388fb0-0x0;var _0x309bc1=_0xffda[_0x388fb0];return _0x309bc1;};'use strict';var _=require(_0xaffd('0x0'));var util=require(_0xaffd('0x1'));var moment=require(_0xaffd('0x2'));var BPromise=require(_0xaffd('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xaffd('0x4'));var db=require(_0xaffd('0x5'))['db'];var utils=require(_0xaffd('0x6'));var logger=require('../../config/logger')(_0xaffd('0x7'));var config=require('../../config/environment');var jayson=require(_0xaffd('0x8'));var client=jayson[_0xaffd('0x9')]['http']({'port':0x232a});config['redis']=_[_0xaffd('0xa')](config[_0xaffd('0xb')],{'host':_0xaffd('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xaffd('0xb')]));require(_0xaffd('0xd'))['register'](socket);function respondWithRpcPromise(_0x585a00,_0x31d35f,_0x42159b){return new BPromise(function(_0x39c15b,_0x5ebd4c){return client[_0xaffd('0xe')](_0x585a00,_0x42159b)[_0xaffd('0xf')](function(_0x550c0f){logger[_0xaffd('0x10')](_0xaffd('0x11'),_0x31d35f,_0xaffd('0x12'));logger[_0xaffd('0x13')](_0xaffd('0x14'),_0x31d35f,'request\x20sent',JSON[_0xaffd('0x15')](_0x550c0f));if(_0x550c0f['error']){if(_0x550c0f['error'][_0xaffd('0x16')]===0x1f4){logger[_0xaffd('0x17')](_0xaffd('0x11'),_0x31d35f,_0x550c0f['error'][_0xaffd('0x18')]);return _0x5ebd4c(_0x550c0f[_0xaffd('0x17')][_0xaffd('0x18')]);}logger[_0xaffd('0x17')](_0xaffd('0x11'),_0x31d35f,_0x550c0f[_0xaffd('0x17')][_0xaffd('0x18')]);return _0x39c15b(_0x550c0f[_0xaffd('0x17')]['message']);}else{logger[_0xaffd('0x10')](_0xaffd('0x11'),_0x31d35f,_0xaffd('0x12'));_0x39c15b(_0x550c0f[_0xaffd('0x19')][_0xaffd('0x18')]);}})[_0xaffd('0x1a')](function(_0x59e33b){logger['error']('MailQueue,\x20%s,\x20%s',_0x31d35f,_0x59e33b);_0x5ebd4c(_0x59e33b);});});}exports[_0xaffd('0x1b')]=function(_0x4af35c){var _0x4d40ae=this;return new Promise(function(_0x3f72d8,_0x1055df){return db[_0xaffd('0x1c')][_0xaffd('0x1d')]({'raw':_0x4af35c[_0xaffd('0x1e')]?_0x4af35c[_0xaffd('0x1e')][_0xaffd('0x1f')]===undefined?!![]:![]:!![],'where':_0x4af35c[_0xaffd('0x1e')]?_0x4af35c[_0xaffd('0x1e')][_0xaffd('0x20')]||null:null,'attributes':_0x4af35c[_0xaffd('0x1e')]?_0x4af35c[_0xaffd('0x1e')][_0xaffd('0x21')]||null:null,'limit':_0x4af35c[_0xaffd('0x1e')]?_0x4af35c[_0xaffd('0x1e')][_0xaffd('0x22')]||null:null,'include':_0x4af35c[_0xaffd('0x1e')]?_0x4af35c[_0xaffd('0x1e')]['include']?_[_0xaffd('0x23')](_0x4af35c[_0xaffd('0x1e')][_0xaffd('0x24')],function(_0x30602e){return{'model':db[_0x30602e[_0xaffd('0x25')]],'as':_0x30602e['as'],'attributes':_0x30602e[_0xaffd('0x21')],'include':_0x30602e[_0xaffd('0x24')]?_[_0xaffd('0x23')](_0x30602e[_0xaffd('0x24')],function(_0x59ac3f){return{'model':db[_0x59ac3f[_0xaffd('0x25')]],'as':_0x59ac3f['as'],'attributes':_0x59ac3f['attributes'],'include':_0x59ac3f['include']?_[_0xaffd('0x23')](_0x59ac3f['include'],function(_0x1d1f1e){return{'model':db[_0x1d1f1e[_0xaffd('0x25')]],'as':_0x1d1f1e['as'],'attributes':_0x1d1f1e[_0xaffd('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x78a316){logger[_0xaffd('0x10')](_0xaffd('0x1b'),_0x4af35c);logger[_0xaffd('0x13')](_0xaffd('0x1b'),_0x4af35c,JSON['stringify'](_0x78a316));_0x3f72d8(_0x78a316);})['catch'](function(_0x1efc3b){logger['error'](_0xaffd('0x1b'),_0x1efc3b[_0xaffd('0x18')],_0x4af35c);_0x1055df(_0x4d40ae[_0xaffd('0x17')](0x1f4,_0x1efc3b['message']));});});};exports[_0xaffd('0x26')]=function(_0x453388){var _0x6b245c=this;return new Promise(function(_0x136745,_0x13453e){return db[_0xaffd('0x1c')][_0xaffd('0x27')]({'raw':_0x453388[_0xaffd('0x1e')]?_0x453388['options'][_0xaffd('0x1f')]===undefined?!![]:![]:!![],'where':_0x453388['options']?_0x453388['options'][_0xaffd('0x20')]||null:null,'attributes':_0x453388[_0xaffd('0x1e')]?_0x453388['options'][_0xaffd('0x21')]||null:null,'include':_0x453388['options']?_0x453388[_0xaffd('0x1e')][_0xaffd('0x24')]?_[_0xaffd('0x23')](_0x453388[_0xaffd('0x1e')][_0xaffd('0x24')],function(_0x26befb){return{'model':db[_0x26befb[_0xaffd('0x25')]],'as':_0x26befb['as'],'attributes':_0x26befb[_0xaffd('0x21')],'include':_0x26befb['include']?_[_0xaffd('0x23')](_0x26befb[_0xaffd('0x24')],function(_0x461454){return{'model':db[_0x461454[_0xaffd('0x25')]],'as':_0x461454['as'],'attributes':_0x461454[_0xaffd('0x21')],'include':_0x461454['include']?_[_0xaffd('0x23')](_0x461454[_0xaffd('0x24')],function(_0x2f12a4){return{'model':db[_0x2f12a4[_0xaffd('0x25')]],'as':_0x2f12a4['as'],'attributes':_0x2f12a4[_0xaffd('0x21')]};}):[]};}):[]};}):[]:[]})[_0xaffd('0xf')](function(_0x8735c5){logger['info'](_0xaffd('0x26'),_0x453388);logger[_0xaffd('0x13')](_0xaffd('0x26'),_0x453388,JSON[_0xaffd('0x15')](_0x8735c5));_0x136745(_0x8735c5);})[_0xaffd('0x1a')](function(_0x537256){logger[_0xaffd('0x17')](_0xaffd('0x26'),_0x537256['message'],_0x453388);_0x13453e(_0x6b245c[_0xaffd('0x17')](0x1f4,_0x537256[_0xaffd('0x18')]));});});};