Built motion from commit (unavailable).|2.5.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 _0xf7b8=['../../config/environment','jayson/promise','client','http','defaults','redis','socket.io-emitter','./mailQueue.socket','register','request','then','request\x20sent','debug','MailQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','MailQueue,\x20%s,\x20%s','message','info','result','catch','MailQueue','findAll','raw','options','where','attributes','limit','include','model','map','GetMailQueue','ShowMailQueue','lodash','util','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc'];(function(_0x3c9579,_0x35cafc){var _0xd7653d=function(_0x2bf847){while(--_0x2bf847){_0x3c9579['push'](_0x3c9579['shift']());}};_0xd7653d(++_0x35cafc);}(_0xf7b8,0xa0));var _0x8f7b=function(_0x528a18,_0xacf111){_0x528a18=_0x528a18-0x0;var _0x4544cd=_0xf7b8[_0x528a18];return _0x4544cd;};'use strict';var _=require(_0x8f7b('0x0'));var util=require(_0x8f7b('0x1'));var moment=require('moment');var BPromise=require(_0x8f7b('0x2'));var rs=require(_0x8f7b('0x3'));var fs=require('fs');var Redis=require(_0x8f7b('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x8f7b('0x5'));var logger=require(_0x8f7b('0x6'))(_0x8f7b('0x7'));var config=require(_0x8f7b('0x8'));var jayson=require(_0x8f7b('0x9'));var client=jayson[_0x8f7b('0xa')][_0x8f7b('0xb')]({'port':0x232a});config['redis']=_[_0x8f7b('0xc')](config[_0x8f7b('0xd')],{'host':'localhost','port':0x18eb});var socket=require(_0x8f7b('0xe'))(new Redis(config['redis']));require(_0x8f7b('0xf'))[_0x8f7b('0x10')](socket);function respondWithRpcPromise(_0x2ed3d5,_0xf25e54,_0x5a0cdd){return new BPromise(function(_0x2ba34b,_0x4cd07e){return client[_0x8f7b('0x11')](_0x2ed3d5,_0x5a0cdd)[_0x8f7b('0x12')](function(_0x277f83){logger['info']('MailQueue,\x20%s,\x20%s',_0xf25e54,_0x8f7b('0x13'));logger[_0x8f7b('0x14')](_0x8f7b('0x15'),_0xf25e54,_0x8f7b('0x13'),JSON[_0x8f7b('0x16')](_0x277f83));if(_0x277f83[_0x8f7b('0x17')]){if(_0x277f83[_0x8f7b('0x17')][_0x8f7b('0x18')]===0x1f4){logger[_0x8f7b('0x17')](_0x8f7b('0x19'),_0xf25e54,_0x277f83[_0x8f7b('0x17')][_0x8f7b('0x1a')]);return _0x4cd07e(_0x277f83[_0x8f7b('0x17')]['message']);}logger[_0x8f7b('0x17')](_0x8f7b('0x19'),_0xf25e54,_0x277f83[_0x8f7b('0x17')][_0x8f7b('0x1a')]);return _0x2ba34b(_0x277f83[_0x8f7b('0x17')]['message']);}else{logger[_0x8f7b('0x1b')](_0x8f7b('0x19'),_0xf25e54,_0x8f7b('0x13'));_0x2ba34b(_0x277f83[_0x8f7b('0x1c')][_0x8f7b('0x1a')]);}})[_0x8f7b('0x1d')](function(_0x2de53d){logger[_0x8f7b('0x17')](_0x8f7b('0x19'),_0xf25e54,_0x2de53d);_0x4cd07e(_0x2de53d);});});}exports['GetMailQueue']=function(_0x5ad8be){var _0x387d62=this;return new Promise(function(_0x3454fd,_0x53e286){return db[_0x8f7b('0x1e')][_0x8f7b('0x1f')]({'raw':_0x5ad8be['options']?_0x5ad8be['options'][_0x8f7b('0x20')]===undefined?!![]:![]:!![],'where':_0x5ad8be[_0x8f7b('0x21')]?_0x5ad8be[_0x8f7b('0x21')][_0x8f7b('0x22')]||null:null,'attributes':_0x5ad8be['options']?_0x5ad8be[_0x8f7b('0x21')][_0x8f7b('0x23')]||null:null,'limit':_0x5ad8be[_0x8f7b('0x21')]?_0x5ad8be[_0x8f7b('0x21')][_0x8f7b('0x24')]||null:null,'include':_0x5ad8be['options']?_0x5ad8be['options'][_0x8f7b('0x25')]?_['map'](_0x5ad8be[_0x8f7b('0x21')]['include'],function(_0x153025){return{'model':db[_0x153025[_0x8f7b('0x26')]],'as':_0x153025['as'],'attributes':_0x153025['attributes'],'include':_0x153025[_0x8f7b('0x25')]?_[_0x8f7b('0x27')](_0x153025[_0x8f7b('0x25')],function(_0x17bb1c){return{'model':db[_0x17bb1c[_0x8f7b('0x26')]],'as':_0x17bb1c['as'],'attributes':_0x17bb1c[_0x8f7b('0x23')],'include':_0x17bb1c[_0x8f7b('0x25')]?_[_0x8f7b('0x27')](_0x17bb1c['include'],function(_0x5e41f7){return{'model':db[_0x5e41f7[_0x8f7b('0x26')]],'as':_0x5e41f7['as'],'attributes':_0x5e41f7[_0x8f7b('0x23')]};}):[]};}):[]};}):[]:[]})[_0x8f7b('0x12')](function(_0x2e86de){logger[_0x8f7b('0x1b')](_0x8f7b('0x28'),_0x5ad8be);logger[_0x8f7b('0x14')](_0x8f7b('0x28'),_0x5ad8be,JSON['stringify'](_0x2e86de));_0x3454fd(_0x2e86de);})['catch'](function(_0x48ce0b){logger[_0x8f7b('0x17')](_0x8f7b('0x28'),_0x48ce0b['message'],_0x5ad8be);_0x53e286(_0x387d62[_0x8f7b('0x17')](0x1f4,_0x48ce0b[_0x8f7b('0x1a')]));});});};exports[_0x8f7b('0x29')]=function(_0x2ffe6f){var _0x10357a=this;return new Promise(function(_0x174935,_0x3240fa){return db['MailQueue']['find']({'raw':_0x2ffe6f['options']?_0x2ffe6f[_0x8f7b('0x21')][_0x8f7b('0x20')]===undefined?!![]:![]:!![],'where':_0x2ffe6f[_0x8f7b('0x21')]?_0x2ffe6f[_0x8f7b('0x21')][_0x8f7b('0x22')]||null:null,'attributes':_0x2ffe6f['options']?_0x2ffe6f[_0x8f7b('0x21')][_0x8f7b('0x23')]||null:null,'include':_0x2ffe6f[_0x8f7b('0x21')]?_0x2ffe6f[_0x8f7b('0x21')][_0x8f7b('0x25')]?_['map'](_0x2ffe6f[_0x8f7b('0x21')]['include'],function(_0x41d4e5){return{'model':db[_0x41d4e5[_0x8f7b('0x26')]],'as':_0x41d4e5['as'],'attributes':_0x41d4e5[_0x8f7b('0x23')],'include':_0x41d4e5[_0x8f7b('0x25')]?_[_0x8f7b('0x27')](_0x41d4e5['include'],function(_0x15d57c){return{'model':db[_0x15d57c[_0x8f7b('0x26')]],'as':_0x15d57c['as'],'attributes':_0x15d57c[_0x8f7b('0x23')],'include':_0x15d57c[_0x8f7b('0x25')]?_[_0x8f7b('0x27')](_0x15d57c[_0x8f7b('0x25')],function(_0xf2de5d){return{'model':db[_0xf2de5d['model']],'as':_0xf2de5d['as'],'attributes':_0xf2de5d[_0x8f7b('0x23')]};}):[]};}):[]};}):[]:[]})[_0x8f7b('0x12')](function(_0x1cd3e2){logger[_0x8f7b('0x1b')](_0x8f7b('0x29'),_0x2ffe6f);logger[_0x8f7b('0x14')](_0x8f7b('0x29'),_0x2ffe6f,JSON['stringify'](_0x1cd3e2));_0x174935(_0x1cd3e2);})[_0x8f7b('0x1d')](function(_0x928238){logger[_0x8f7b('0x17')]('ShowMailQueue',_0x928238[_0x8f7b('0x1a')],_0x2ffe6f);_0x3240fa(_0x10357a[_0x8f7b('0x17')](0x1f4,_0x928238[_0x8f7b('0x1a')]));});});};