Built motion from commit f25620e4.|2.6.30
[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 _0x1306=['code','MailQueue,\x20%s,\x20%s','message','result','catch','GetMailQueue','MailQueue','findAll','raw','options','where','limit','include','attributes','map','model','find','ShowMailQueue','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','register','request','then','info','request\x20sent','debug','stringify','error'];(function(_0x1a0f3a,_0x3f82c3){var _0x152ebf=function(_0x2d33ea){while(--_0x2d33ea){_0x1a0f3a['push'](_0x1a0f3a['shift']());}};_0x152ebf(++_0x3f82c3);}(_0x1306,0x17a));var _0x6130=function(_0xa16512,_0x537b0f){_0xa16512=_0xa16512-0x0;var _0x141776=_0x1306[_0xa16512];return _0x141776;};'use strict';var _=require(_0x6130('0x0'));var util=require(_0x6130('0x1'));var moment=require(_0x6130('0x2'));var BPromise=require(_0x6130('0x3'));var rs=require(_0x6130('0x4'));var fs=require('fs');var Redis=require(_0x6130('0x5'));var db=require(_0x6130('0x6'))['db'];var utils=require(_0x6130('0x7'));var logger=require(_0x6130('0x8'))(_0x6130('0x9'));var config=require(_0x6130('0xa'));var jayson=require(_0x6130('0xb'));var client=jayson[_0x6130('0xc')][_0x6130('0xd')]({'port':0x232a});config[_0x6130('0xe')]=_[_0x6130('0xf')](config[_0x6130('0xe')],{'host':_0x6130('0x10'),'port':0x18eb});var socket=require(_0x6130('0x11'))(new Redis(config[_0x6130('0xe')]));require(_0x6130('0x12'))[_0x6130('0x13')](socket);function respondWithRpcPromise(_0xb9c7e6,_0x34d1a6,_0x2d06a5){return new BPromise(function(_0x107d80,_0xcaf732){return client[_0x6130('0x14')](_0xb9c7e6,_0x2d06a5)[_0x6130('0x15')](function(_0x583072){logger[_0x6130('0x16')]('MailQueue,\x20%s,\x20%s',_0x34d1a6,_0x6130('0x17'));logger[_0x6130('0x18')]('MailQueue,\x20%s,\x20%s,\x20%s',_0x34d1a6,_0x6130('0x17'),JSON[_0x6130('0x19')](_0x583072));if(_0x583072[_0x6130('0x1a')]){if(_0x583072[_0x6130('0x1a')][_0x6130('0x1b')]===0x1f4){logger[_0x6130('0x1a')](_0x6130('0x1c'),_0x34d1a6,_0x583072[_0x6130('0x1a')][_0x6130('0x1d')]);return _0xcaf732(_0x583072[_0x6130('0x1a')][_0x6130('0x1d')]);}logger[_0x6130('0x1a')](_0x6130('0x1c'),_0x34d1a6,_0x583072[_0x6130('0x1a')][_0x6130('0x1d')]);return _0x107d80(_0x583072[_0x6130('0x1a')]['message']);}else{logger['info'](_0x6130('0x1c'),_0x34d1a6,'request\x20sent');_0x107d80(_0x583072[_0x6130('0x1e')][_0x6130('0x1d')]);}})[_0x6130('0x1f')](function(_0x2c83b0){logger[_0x6130('0x1a')]('MailQueue,\x20%s,\x20%s',_0x34d1a6,_0x2c83b0);_0xcaf732(_0x2c83b0);});});}exports[_0x6130('0x20')]=function(_0x4d4b4b){var _0x41fa14=this;return new Promise(function(_0x41f56a,_0x18bb78){return db[_0x6130('0x21')][_0x6130('0x22')]({'raw':_0x4d4b4b['options']?_0x4d4b4b['options'][_0x6130('0x23')]===undefined?!![]:![]:!![],'where':_0x4d4b4b['options']?_0x4d4b4b[_0x6130('0x24')][_0x6130('0x25')]||null:null,'attributes':_0x4d4b4b['options']?_0x4d4b4b['options']['attributes']||null:null,'limit':_0x4d4b4b[_0x6130('0x24')]?_0x4d4b4b['options'][_0x6130('0x26')]||null:null,'include':_0x4d4b4b['options']?_0x4d4b4b['options']['include']?_['map'](_0x4d4b4b['options'][_0x6130('0x27')],function(_0x1ba07d){return{'model':db[_0x1ba07d['model']],'as':_0x1ba07d['as'],'attributes':_0x1ba07d[_0x6130('0x28')],'include':_0x1ba07d['include']?_[_0x6130('0x29')](_0x1ba07d['include'],function(_0x5787a6){return{'model':db[_0x5787a6[_0x6130('0x2a')]],'as':_0x5787a6['as'],'attributes':_0x5787a6[_0x6130('0x28')],'include':_0x5787a6[_0x6130('0x27')]?_[_0x6130('0x29')](_0x5787a6[_0x6130('0x27')],function(_0x392386){return{'model':db[_0x392386[_0x6130('0x2a')]],'as':_0x392386['as'],'attributes':_0x392386[_0x6130('0x28')]};}):[]};}):[]};}):[]:[]})[_0x6130('0x15')](function(_0x5809e4){logger['info'](_0x6130('0x20'),_0x4d4b4b);logger[_0x6130('0x18')](_0x6130('0x20'),_0x4d4b4b,JSON[_0x6130('0x19')](_0x5809e4));_0x41f56a(_0x5809e4);})[_0x6130('0x1f')](function(_0x4e068c){logger[_0x6130('0x1a')](_0x6130('0x20'),_0x4e068c[_0x6130('0x1d')],_0x4d4b4b);_0x18bb78(_0x41fa14[_0x6130('0x1a')](0x1f4,_0x4e068c[_0x6130('0x1d')]));});});};exports['ShowMailQueue']=function(_0x248324){var _0x600c28=this;return new Promise(function(_0x165407,_0x4b0c9c){return db[_0x6130('0x21')][_0x6130('0x2b')]({'raw':_0x248324[_0x6130('0x24')]?_0x248324[_0x6130('0x24')][_0x6130('0x23')]===undefined?!![]:![]:!![],'where':_0x248324[_0x6130('0x24')]?_0x248324[_0x6130('0x24')][_0x6130('0x25')]||null:null,'attributes':_0x248324[_0x6130('0x24')]?_0x248324['options'][_0x6130('0x28')]||null:null,'include':_0x248324['options']?_0x248324['options']['include']?_[_0x6130('0x29')](_0x248324[_0x6130('0x24')][_0x6130('0x27')],function(_0x3b5270){return{'model':db[_0x3b5270[_0x6130('0x2a')]],'as':_0x3b5270['as'],'attributes':_0x3b5270[_0x6130('0x28')],'include':_0x3b5270[_0x6130('0x27')]?_[_0x6130('0x29')](_0x3b5270['include'],function(_0x36a91e){return{'model':db[_0x36a91e[_0x6130('0x2a')]],'as':_0x36a91e['as'],'attributes':_0x36a91e['attributes'],'include':_0x36a91e[_0x6130('0x27')]?_[_0x6130('0x29')](_0x36a91e[_0x6130('0x27')],function(_0x5874cd){return{'model':db[_0x5874cd[_0x6130('0x2a')]],'as':_0x5874cd['as'],'attributes':_0x5874cd[_0x6130('0x28')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5f3798){logger[_0x6130('0x16')](_0x6130('0x2c'),_0x248324);logger[_0x6130('0x18')]('ShowMailQueue',_0x248324,JSON['stringify'](_0x5f3798));_0x165407(_0x5f3798);})[_0x6130('0x1f')](function(_0x94a76){logger[_0x6130('0x1a')](_0x6130('0x2c'),_0x94a76[_0x6130('0x1d')],_0x248324);_0x4b0c9c(_0x600c28[_0x6130('0x1a')](0x1f4,_0x94a76[_0x6130('0x1d')]));});});};