72d2823062754a3abfdbe37d0a429bbfabe697ca
[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 _0x280f=['../../config/environment','jayson/promise','client','http','redis','localhost','socket.io-emitter','./mailQueue.socket','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','catch','GetMailQueue','MailQueue','findAll','options','where','attributes','include','map','model','ShowMailQueue','raw','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x94b853,_0x28399b){var _0x17a9c0=function(_0x5ba347){while(--_0x5ba347){_0x94b853['push'](_0x94b853['shift']());}};_0x17a9c0(++_0x28399b);}(_0x280f,0xe2));var _0xf280=function(_0x20589d,_0x55d5bf){_0x20589d=_0x20589d-0x0;var _0x422de9=_0x280f[_0x20589d];return _0x422de9;};'use strict';var _=require(_0xf280('0x0'));var util=require('util');var moment=require(_0xf280('0x1'));var BPromise=require(_0xf280('0x2'));var rs=require(_0xf280('0x3'));var fs=require('fs');var Redis=require(_0xf280('0x4'));var db=require(_0xf280('0x5'))['db'];var utils=require(_0xf280('0x6'));var logger=require(_0xf280('0x7'))('rpc');var config=require(_0xf280('0x8'));var jayson=require(_0xf280('0x9'));var client=jayson[_0xf280('0xa')][_0xf280('0xb')]({'port':0x232a});config[_0xf280('0xc')]=_['defaults'](config[_0xf280('0xc')],{'host':_0xf280('0xd'),'port':0x18eb});var socket=require(_0xf280('0xe'))(new Redis(config[_0xf280('0xc')]));require(_0xf280('0xf'))[_0xf280('0x10')](socket);function respondWithRpcPromise(_0x5360c3,_0x2447c6,_0x3d13c5){return new BPromise(function(_0x1f580a,_0x3e58af){return client[_0xf280('0x11')](_0x5360c3,_0x3d13c5)[_0xf280('0x12')](function(_0x10ccbe){logger[_0xf280('0x13')](_0xf280('0x14'),_0x2447c6,_0xf280('0x15'));logger[_0xf280('0x16')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x2447c6,_0xf280('0x15'),JSON[_0xf280('0x17')](_0x10ccbe));if(_0x10ccbe[_0xf280('0x18')]){if(_0x10ccbe[_0xf280('0x18')][_0xf280('0x19')]===0x1f4){logger[_0xf280('0x18')]('MailQueue,\x20%s,\x20%s',_0x2447c6,_0x10ccbe[_0xf280('0x18')][_0xf280('0x1a')]);return _0x3e58af(_0x10ccbe[_0xf280('0x18')][_0xf280('0x1a')]);}logger[_0xf280('0x18')](_0xf280('0x14'),_0x2447c6,_0x10ccbe[_0xf280('0x18')]['message']);return _0x1f580a(_0x10ccbe['error']['message']);}else{logger[_0xf280('0x13')]('MailQueue,\x20%s,\x20%s',_0x2447c6,_0xf280('0x15'));_0x1f580a(_0x10ccbe['result'][_0xf280('0x1a')]);}})[_0xf280('0x1b')](function(_0x5328ae){logger[_0xf280('0x18')]('MailQueue,\x20%s,\x20%s',_0x2447c6,_0x5328ae);_0x3e58af(_0x5328ae);});});}exports[_0xf280('0x1c')]=function(_0x26c705){var _0x114364=this;return new Promise(function(_0x21e99b,_0x11db7d){return db[_0xf280('0x1d')][_0xf280('0x1e')]({'raw':_0x26c705[_0xf280('0x1f')]?_0x26c705[_0xf280('0x1f')]['raw']===undefined?!![]:![]:!![],'where':_0x26c705[_0xf280('0x1f')]?_0x26c705[_0xf280('0x1f')][_0xf280('0x20')]||null:null,'attributes':_0x26c705[_0xf280('0x1f')]?_0x26c705[_0xf280('0x1f')][_0xf280('0x21')]||null:null,'limit':_0x26c705[_0xf280('0x1f')]?_0x26c705[_0xf280('0x1f')]['limit']||null:null,'include':_0x26c705[_0xf280('0x1f')]?_0x26c705[_0xf280('0x1f')][_0xf280('0x22')]?_[_0xf280('0x23')](_0x26c705[_0xf280('0x1f')][_0xf280('0x22')],function(_0x4509c1){return{'model':db[_0x4509c1[_0xf280('0x24')]],'as':_0x4509c1['as'],'attributes':_0x4509c1['attributes'],'include':_0x4509c1[_0xf280('0x22')]?_[_0xf280('0x23')](_0x4509c1[_0xf280('0x22')],function(_0xf9ac1c){return{'model':db[_0xf9ac1c['model']],'as':_0xf9ac1c['as'],'attributes':_0xf9ac1c['attributes'],'include':_0xf9ac1c['include']?_['map'](_0xf9ac1c['include'],function(_0x3da40e){return{'model':db[_0x3da40e[_0xf280('0x24')]],'as':_0x3da40e['as'],'attributes':_0x3da40e[_0xf280('0x21')]};}):[]};}):[]};}):[]:[]})[_0xf280('0x12')](function(_0x545ccf){logger[_0xf280('0x13')]('GetMailQueue',_0x26c705);logger[_0xf280('0x16')](_0xf280('0x1c'),_0x26c705,JSON['stringify'](_0x545ccf));_0x21e99b(_0x545ccf);})[_0xf280('0x1b')](function(_0x7bbbd){logger[_0xf280('0x18')](_0xf280('0x1c'),_0x7bbbd['message'],_0x26c705);_0x11db7d(_0x114364[_0xf280('0x18')](0x1f4,_0x7bbbd[_0xf280('0x1a')]));});});};exports[_0xf280('0x25')]=function(_0x20aee4){var _0x9e9dc2=this;return new Promise(function(_0xa6e2ca,_0x45a2cf){return db[_0xf280('0x1d')]['find']({'raw':_0x20aee4[_0xf280('0x1f')]?_0x20aee4[_0xf280('0x1f')][_0xf280('0x26')]===undefined?!![]:![]:!![],'where':_0x20aee4[_0xf280('0x1f')]?_0x20aee4['options']['where']||null:null,'attributes':_0x20aee4[_0xf280('0x1f')]?_0x20aee4['options'][_0xf280('0x21')]||null:null,'include':_0x20aee4[_0xf280('0x1f')]?_0x20aee4[_0xf280('0x1f')][_0xf280('0x22')]?_[_0xf280('0x23')](_0x20aee4['options']['include'],function(_0x5c34a3){return{'model':db[_0x5c34a3[_0xf280('0x24')]],'as':_0x5c34a3['as'],'attributes':_0x5c34a3['attributes'],'include':_0x5c34a3[_0xf280('0x22')]?_[_0xf280('0x23')](_0x5c34a3['include'],function(_0x36a914){return{'model':db[_0x36a914[_0xf280('0x24')]],'as':_0x36a914['as'],'attributes':_0x36a914[_0xf280('0x21')],'include':_0x36a914[_0xf280('0x22')]?_[_0xf280('0x23')](_0x36a914[_0xf280('0x22')],function(_0x286b48){return{'model':db[_0x286b48[_0xf280('0x24')]],'as':_0x286b48['as'],'attributes':_0x286b48[_0xf280('0x21')]};}):[]};}):[]};}):[]:[]})[_0xf280('0x12')](function(_0x4ddd4a){logger[_0xf280('0x13')](_0xf280('0x25'),_0x20aee4);logger[_0xf280('0x16')](_0xf280('0x25'),_0x20aee4,JSON[_0xf280('0x17')](_0x4ddd4a));_0xa6e2ca(_0x4ddd4a);})['catch'](function(_0x1c85b4){logger[_0xf280('0x18')]('ShowMailQueue',_0x1c85b4[_0xf280('0x1a')],_0x20aee4);_0x45a2cf(_0x9e9dc2[_0xf280('0x18')](0x1f4,_0x1c85b4[_0xf280('0x1a')]));});});};