Built motion from commit 753c950e.|2.5.42
[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 _0x6623=['model','ShowMailQueue','MailQueue','util','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./mailQueue.socket','request','then','info','MailQueue,\x20%s,\x20%s','debug','MailQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','GetMailQueue','options','raw','where','attributes','limit','map','include'];(function(_0x33032e,_0x31411a){var _0x13316b=function(_0x2fb049){while(--_0x2fb049){_0x33032e['push'](_0x33032e['shift']());}};_0x13316b(++_0x31411a);}(_0x6623,0x189));var _0x3662=function(_0x3e112d,_0x2bb132){_0x3e112d=_0x3e112d-0x0;var _0x531c31=_0x6623[_0x3e112d];return _0x531c31;};'use strict';var _=require('lodash');var util=require(_0x3662('0x0'));var moment=require(_0x3662('0x1'));var BPromise=require(_0x3662('0x2'));var rs=require(_0x3662('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x3662('0x4'));var logger=require(_0x3662('0x5'))(_0x3662('0x6'));var config=require(_0x3662('0x7'));var jayson=require(_0x3662('0x8'));var client=jayson[_0x3662('0x9')][_0x3662('0xa')]({'port':0x232a});config[_0x3662('0xb')]=_[_0x3662('0xc')](config['redis'],{'host':_0x3662('0xd'),'port':0x18eb});var socket=require(_0x3662('0xe'))(new Redis(config[_0x3662('0xb')]));require(_0x3662('0xf'))['register'](socket);function respondWithRpcPromise(_0x1cc373,_0x173701,_0x2350cc){return new BPromise(function(_0x27c807,_0x5455e3){return client[_0x3662('0x10')](_0x1cc373,_0x2350cc)[_0x3662('0x11')](function(_0x12700f){logger[_0x3662('0x12')](_0x3662('0x13'),_0x173701,'request\x20sent');logger[_0x3662('0x14')](_0x3662('0x15'),_0x173701,_0x3662('0x16'),JSON[_0x3662('0x17')](_0x12700f));if(_0x12700f[_0x3662('0x18')]){if(_0x12700f[_0x3662('0x18')][_0x3662('0x19')]===0x1f4){logger[_0x3662('0x18')](_0x3662('0x13'),_0x173701,_0x12700f[_0x3662('0x18')][_0x3662('0x1a')]);return _0x5455e3(_0x12700f['error']['message']);}logger[_0x3662('0x18')]('MailQueue,\x20%s,\x20%s',_0x173701,_0x12700f[_0x3662('0x18')][_0x3662('0x1a')]);return _0x27c807(_0x12700f[_0x3662('0x18')]['message']);}else{logger[_0x3662('0x12')]('MailQueue,\x20%s,\x20%s',_0x173701,_0x3662('0x16'));_0x27c807(_0x12700f['result'][_0x3662('0x1a')]);}})[_0x3662('0x1b')](function(_0x1cd7b6){logger[_0x3662('0x18')](_0x3662('0x13'),_0x173701,_0x1cd7b6);_0x5455e3(_0x1cd7b6);});});}exports[_0x3662('0x1c')]=function(_0x531bb7){var _0x1eac84=this;return new Promise(function(_0x25cd94,_0x43eeb6){return db['MailQueue']['findAll']({'raw':_0x531bb7[_0x3662('0x1d')]?_0x531bb7[_0x3662('0x1d')][_0x3662('0x1e')]===undefined?!![]:![]:!![],'where':_0x531bb7[_0x3662('0x1d')]?_0x531bb7['options'][_0x3662('0x1f')]||null:null,'attributes':_0x531bb7[_0x3662('0x1d')]?_0x531bb7[_0x3662('0x1d')][_0x3662('0x20')]||null:null,'limit':_0x531bb7[_0x3662('0x1d')]?_0x531bb7['options'][_0x3662('0x21')]||null:null,'include':_0x531bb7['options']?_0x531bb7[_0x3662('0x1d')]['include']?_[_0x3662('0x22')](_0x531bb7[_0x3662('0x1d')][_0x3662('0x23')],function(_0x470729){return{'model':db[_0x470729['model']],'as':_0x470729['as'],'attributes':_0x470729[_0x3662('0x20')],'include':_0x470729[_0x3662('0x23')]?_[_0x3662('0x22')](_0x470729[_0x3662('0x23')],function(_0x1e690e){return{'model':db[_0x1e690e[_0x3662('0x24')]],'as':_0x1e690e['as'],'attributes':_0x1e690e[_0x3662('0x20')],'include':_0x1e690e[_0x3662('0x23')]?_[_0x3662('0x22')](_0x1e690e[_0x3662('0x23')],function(_0x5ed766){return{'model':db[_0x5ed766[_0x3662('0x24')]],'as':_0x5ed766['as'],'attributes':_0x5ed766[_0x3662('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x15d6d6){logger['info'](_0x3662('0x1c'),_0x531bb7);logger[_0x3662('0x14')]('GetMailQueue',_0x531bb7,JSON[_0x3662('0x17')](_0x15d6d6));_0x25cd94(_0x15d6d6);})['catch'](function(_0x3c7fc7){logger[_0x3662('0x18')](_0x3662('0x1c'),_0x3c7fc7[_0x3662('0x1a')],_0x531bb7);_0x43eeb6(_0x1eac84[_0x3662('0x18')](0x1f4,_0x3c7fc7[_0x3662('0x1a')]));});});};exports[_0x3662('0x25')]=function(_0x59afb3){var _0x36d2eb=this;return new Promise(function(_0x2cb7b4,_0x3af84b){return db[_0x3662('0x26')]['find']({'raw':_0x59afb3[_0x3662('0x1d')]?_0x59afb3[_0x3662('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x59afb3['options']?_0x59afb3[_0x3662('0x1d')][_0x3662('0x1f')]||null:null,'attributes':_0x59afb3[_0x3662('0x1d')]?_0x59afb3[_0x3662('0x1d')]['attributes']||null:null,'include':_0x59afb3[_0x3662('0x1d')]?_0x59afb3[_0x3662('0x1d')][_0x3662('0x23')]?_['map'](_0x59afb3['options']['include'],function(_0x5d627d){return{'model':db[_0x5d627d['model']],'as':_0x5d627d['as'],'attributes':_0x5d627d[_0x3662('0x20')],'include':_0x5d627d['include']?_[_0x3662('0x22')](_0x5d627d['include'],function(_0x270d1a){return{'model':db[_0x270d1a[_0x3662('0x24')]],'as':_0x270d1a['as'],'attributes':_0x270d1a[_0x3662('0x20')],'include':_0x270d1a[_0x3662('0x23')]?_[_0x3662('0x22')](_0x270d1a[_0x3662('0x23')],function(_0x3f76ef){return{'model':db[_0x3f76ef[_0x3662('0x24')]],'as':_0x3f76ef['as'],'attributes':_0x3f76ef[_0x3662('0x20')]};}):[]};}):[]};}):[]:[]})[_0x3662('0x11')](function(_0x45dfd4){logger['info'](_0x3662('0x25'),_0x59afb3);logger['debug'](_0x3662('0x25'),_0x59afb3,JSON[_0x3662('0x17')](_0x45dfd4));_0x2cb7b4(_0x45dfd4);})[_0x3662('0x1b')](function(_0x1b8bcc){logger[_0x3662('0x18')](_0x3662('0x25'),_0x1b8bcc[_0x3662('0x1a')],_0x59afb3);_0x3af84b(_0x36d2eb['error'](0x1f4,_0x1b8bcc[_0x3662('0x1a')]));});});};