Built motion from commit (unavailable).|2.4.3
[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 _0xa2f5=['bluebird','randomstring','../../mysqldb','../../config/utils','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','MailQueue','raw','options','where','attributes','include','map','model','GetMailQueue','stringify','catch','ShowMailQueue','find','moment'];(function(_0x507299,_0x28aecd){var _0x5f410c=function(_0x288f0d){while(--_0x288f0d){_0x507299['push'](_0x507299['shift']());}};_0x5f410c(++_0x28aecd);}(_0xa2f5,0x14c));var _0x5a2f=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0xa2f5[_0x6c993a];return _0x27f547;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x5a2f('0x0'));var BPromise=require(_0x5a2f('0x1'));var rs=require(_0x5a2f('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x5a2f('0x3'))['db'];var utils=require(_0x5a2f('0x4'));var logger=require('../../config/logger')('rpc');var config=require(_0x5a2f('0x5'));var jayson=require('jayson/promise');var client=jayson[_0x5a2f('0x6')][_0x5a2f('0x7')]({'port':0x232a});config[_0x5a2f('0x8')]=_[_0x5a2f('0x9')](config[_0x5a2f('0x8')],{'host':_0x5a2f('0xa'),'port':0x18eb});var socket=require(_0x5a2f('0xb'))(new Redis(config['redis']));require(_0x5a2f('0xc'))[_0x5a2f('0xd')](socket);function respondWithRpcPromise(_0x5d7beb,_0x2a5d01,_0x2abe1b){return new BPromise(function(_0x46594f,_0x5918ce){return client[_0x5a2f('0xe')](_0x5d7beb,_0x2abe1b)[_0x5a2f('0xf')](function(_0x4eab8f){logger[_0x5a2f('0x10')](_0x5a2f('0x11'),_0x2a5d01,_0x5a2f('0x12'));logger[_0x5a2f('0x13')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x2a5d01,_0x5a2f('0x12'),JSON['stringify'](_0x4eab8f));if(_0x4eab8f[_0x5a2f('0x14')]){if(_0x4eab8f[_0x5a2f('0x14')][_0x5a2f('0x15')]===0x1f4){logger[_0x5a2f('0x14')](_0x5a2f('0x11'),_0x2a5d01,_0x4eab8f[_0x5a2f('0x14')][_0x5a2f('0x16')]);return _0x5918ce(_0x4eab8f['error'][_0x5a2f('0x16')]);}logger[_0x5a2f('0x14')](_0x5a2f('0x11'),_0x2a5d01,_0x4eab8f[_0x5a2f('0x14')][_0x5a2f('0x16')]);return _0x46594f(_0x4eab8f[_0x5a2f('0x14')][_0x5a2f('0x16')]);}else{logger[_0x5a2f('0x10')](_0x5a2f('0x11'),_0x2a5d01,_0x5a2f('0x12'));_0x46594f(_0x4eab8f[_0x5a2f('0x17')]['message']);}})['catch'](function(_0x342a38){logger[_0x5a2f('0x14')]('MailQueue,\x20%s,\x20%s',_0x2a5d01,_0x342a38);_0x5918ce(_0x342a38);});});}exports['GetMailQueue']=function(_0x3e5e5a){var _0x4228a8=this;return new Promise(function(_0x437518,_0x16a8f3){return db[_0x5a2f('0x18')]['findAll']({'raw':_0x3e5e5a['options']?_0x3e5e5a['options'][_0x5a2f('0x19')]===undefined?!![]:![]:!![],'where':_0x3e5e5a[_0x5a2f('0x1a')]?_0x3e5e5a[_0x5a2f('0x1a')][_0x5a2f('0x1b')]||null:null,'attributes':_0x3e5e5a['options']?_0x3e5e5a[_0x5a2f('0x1a')][_0x5a2f('0x1c')]||null:null,'limit':_0x3e5e5a['options']?_0x3e5e5a[_0x5a2f('0x1a')]['limit']||null:null,'include':_0x3e5e5a[_0x5a2f('0x1a')]?_0x3e5e5a[_0x5a2f('0x1a')][_0x5a2f('0x1d')]?_[_0x5a2f('0x1e')](_0x3e5e5a[_0x5a2f('0x1a')][_0x5a2f('0x1d')],function(_0x657458){return{'model':db[_0x657458[_0x5a2f('0x1f')]],'as':_0x657458['as'],'attributes':_0x657458[_0x5a2f('0x1c')],'include':_0x657458[_0x5a2f('0x1d')]?_[_0x5a2f('0x1e')](_0x657458[_0x5a2f('0x1d')],function(_0x3bcb6f){return{'model':db[_0x3bcb6f[_0x5a2f('0x1f')]],'as':_0x3bcb6f['as'],'attributes':_0x3bcb6f['attributes'],'include':_0x3bcb6f['include']?_[_0x5a2f('0x1e')](_0x3bcb6f[_0x5a2f('0x1d')],function(_0x2143f7){return{'model':db[_0x2143f7['model']],'as':_0x2143f7['as'],'attributes':_0x2143f7[_0x5a2f('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x5a2f('0xf')](function(_0x4cdb7c){logger[_0x5a2f('0x10')](_0x5a2f('0x20'),_0x3e5e5a);logger['debug'](_0x5a2f('0x20'),_0x3e5e5a,JSON[_0x5a2f('0x21')](_0x4cdb7c));_0x437518(_0x4cdb7c);})[_0x5a2f('0x22')](function(_0x725837){logger[_0x5a2f('0x14')](_0x5a2f('0x20'),_0x725837[_0x5a2f('0x16')],_0x3e5e5a);_0x16a8f3(_0x4228a8['error'](0x1f4,_0x725837['message']));});});};exports[_0x5a2f('0x23')]=function(_0x537dac){var _0x753f5f=this;return new Promise(function(_0x37baf2,_0x33fec7){return db[_0x5a2f('0x18')][_0x5a2f('0x24')]({'raw':_0x537dac[_0x5a2f('0x1a')]?_0x537dac['options'][_0x5a2f('0x19')]===undefined?!![]:![]:!![],'where':_0x537dac[_0x5a2f('0x1a')]?_0x537dac[_0x5a2f('0x1a')][_0x5a2f('0x1b')]||null:null,'attributes':_0x537dac[_0x5a2f('0x1a')]?_0x537dac[_0x5a2f('0x1a')][_0x5a2f('0x1c')]||null:null,'include':_0x537dac[_0x5a2f('0x1a')]?_0x537dac[_0x5a2f('0x1a')]['include']?_[_0x5a2f('0x1e')](_0x537dac[_0x5a2f('0x1a')][_0x5a2f('0x1d')],function(_0x552194){return{'model':db[_0x552194[_0x5a2f('0x1f')]],'as':_0x552194['as'],'attributes':_0x552194[_0x5a2f('0x1c')],'include':_0x552194['include']?_[_0x5a2f('0x1e')](_0x552194[_0x5a2f('0x1d')],function(_0x2a7777){return{'model':db[_0x2a7777[_0x5a2f('0x1f')]],'as':_0x2a7777['as'],'attributes':_0x2a7777[_0x5a2f('0x1c')],'include':_0x2a7777['include']?_[_0x5a2f('0x1e')](_0x2a7777['include'],function(_0x1a1434){return{'model':db[_0x1a1434[_0x5a2f('0x1f')]],'as':_0x1a1434['as'],'attributes':_0x1a1434[_0x5a2f('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x5a2f('0xf')](function(_0x58db9a){logger['info']('ShowMailQueue',_0x537dac);logger[_0x5a2f('0x13')](_0x5a2f('0x23'),_0x537dac,JSON[_0x5a2f('0x21')](_0x58db9a));_0x37baf2(_0x58db9a);})[_0x5a2f('0x22')](function(_0x50c6ce){logger['error'](_0x5a2f('0x23'),_0x50c6ce['message'],_0x537dac);_0x33fec7(_0x753f5f[_0x5a2f('0x14')](0x1f4,_0x50c6ce[_0x5a2f('0x16')]));});});};