Built motion from commit (unavailable).|2.5.31
[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 _0x9ffa=['raw','where','attributes','limit','include','map','model','then','info','GetMailQueue','debug','ShowMailQueue','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','./mailQueue.socket','register','request','MailQueue,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','MailQueue','findAll','options'];(function(_0x89d3a6,_0x3dd79c){var _0x2c3193=function(_0x2abad3){while(--_0x2abad3){_0x89d3a6['push'](_0x89d3a6['shift']());}};_0x2c3193(++_0x3dd79c);}(_0x9ffa,0x1d4));var _0xa9ff=function(_0x25be59,_0x6c2be8){_0x25be59=_0x25be59-0x0;var _0x452fe1=_0x9ffa[_0x25be59];return _0x452fe1;};'use strict';var _=require(_0xa9ff('0x0'));var util=require(_0xa9ff('0x1'));var moment=require(_0xa9ff('0x2'));var BPromise=require(_0xa9ff('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa9ff('0x4'))['db'];var utils=require(_0xa9ff('0x5'));var logger=require(_0xa9ff('0x6'))(_0xa9ff('0x7'));var config=require(_0xa9ff('0x8'));var jayson=require(_0xa9ff('0x9'));var client=jayson['client']['http']({'port':0x232a});config[_0xa9ff('0xa')]=_[_0xa9ff('0xb')](config[_0xa9ff('0xa')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa9ff('0xa')]));require(_0xa9ff('0xc'))[_0xa9ff('0xd')](socket);function respondWithRpcPromise(_0xc904fa,_0x56776f,_0x4cb3c9){return new BPromise(function(_0x52346e,_0x3c2583){return client[_0xa9ff('0xe')](_0xc904fa,_0x4cb3c9)['then'](function(_0x1e47bb){logger['info'](_0xa9ff('0xf'),_0x56776f,_0xa9ff('0x10'));logger['debug']('MailQueue,\x20%s,\x20%s,\x20%s',_0x56776f,_0xa9ff('0x10'),JSON[_0xa9ff('0x11')](_0x1e47bb));if(_0x1e47bb[_0xa9ff('0x12')]){if(_0x1e47bb['error'][_0xa9ff('0x13')]===0x1f4){logger[_0xa9ff('0x12')](_0xa9ff('0xf'),_0x56776f,_0x1e47bb[_0xa9ff('0x12')][_0xa9ff('0x14')]);return _0x3c2583(_0x1e47bb[_0xa9ff('0x12')][_0xa9ff('0x14')]);}logger[_0xa9ff('0x12')](_0xa9ff('0xf'),_0x56776f,_0x1e47bb[_0xa9ff('0x12')][_0xa9ff('0x14')]);return _0x52346e(_0x1e47bb[_0xa9ff('0x12')][_0xa9ff('0x14')]);}else{logger['info'](_0xa9ff('0xf'),_0x56776f,'request\x20sent');_0x52346e(_0x1e47bb[_0xa9ff('0x15')][_0xa9ff('0x14')]);}})[_0xa9ff('0x16')](function(_0x44d0a0){logger[_0xa9ff('0x12')](_0xa9ff('0xf'),_0x56776f,_0x44d0a0);_0x3c2583(_0x44d0a0);});});}exports['GetMailQueue']=function(_0x2f3f7e){var _0x343062=this;return new Promise(function(_0x282c53,_0x1ee0b3){return db[_0xa9ff('0x17')][_0xa9ff('0x18')]({'raw':_0x2f3f7e[_0xa9ff('0x19')]?_0x2f3f7e[_0xa9ff('0x19')][_0xa9ff('0x1a')]===undefined?!![]:![]:!![],'where':_0x2f3f7e[_0xa9ff('0x19')]?_0x2f3f7e['options'][_0xa9ff('0x1b')]||null:null,'attributes':_0x2f3f7e[_0xa9ff('0x19')]?_0x2f3f7e[_0xa9ff('0x19')][_0xa9ff('0x1c')]||null:null,'limit':_0x2f3f7e['options']?_0x2f3f7e[_0xa9ff('0x19')][_0xa9ff('0x1d')]||null:null,'include':_0x2f3f7e[_0xa9ff('0x19')]?_0x2f3f7e[_0xa9ff('0x19')][_0xa9ff('0x1e')]?_[_0xa9ff('0x1f')](_0x2f3f7e['options'][_0xa9ff('0x1e')],function(_0x4fbbe2){return{'model':db[_0x4fbbe2['model']],'as':_0x4fbbe2['as'],'attributes':_0x4fbbe2[_0xa9ff('0x1c')],'include':_0x4fbbe2[_0xa9ff('0x1e')]?_['map'](_0x4fbbe2[_0xa9ff('0x1e')],function(_0x3b0bdc){return{'model':db[_0x3b0bdc[_0xa9ff('0x20')]],'as':_0x3b0bdc['as'],'attributes':_0x3b0bdc[_0xa9ff('0x1c')],'include':_0x3b0bdc[_0xa9ff('0x1e')]?_[_0xa9ff('0x1f')](_0x3b0bdc[_0xa9ff('0x1e')],function(_0x23b4c5){return{'model':db[_0x23b4c5['model']],'as':_0x23b4c5['as'],'attributes':_0x23b4c5['attributes']};}):[]};}):[]};}):[]:[]})[_0xa9ff('0x21')](function(_0x5bcf50){logger[_0xa9ff('0x22')](_0xa9ff('0x23'),_0x2f3f7e);logger[_0xa9ff('0x24')](_0xa9ff('0x23'),_0x2f3f7e,JSON[_0xa9ff('0x11')](_0x5bcf50));_0x282c53(_0x5bcf50);})[_0xa9ff('0x16')](function(_0x3de7cc){logger[_0xa9ff('0x12')](_0xa9ff('0x23'),_0x3de7cc[_0xa9ff('0x14')],_0x2f3f7e);_0x1ee0b3(_0x343062['error'](0x1f4,_0x3de7cc[_0xa9ff('0x14')]));});});};exports[_0xa9ff('0x25')]=function(_0x2a94d5){var _0x106b50=this;return new Promise(function(_0x47b81b,_0x569422){return db[_0xa9ff('0x17')]['find']({'raw':_0x2a94d5[_0xa9ff('0x19')]?_0x2a94d5[_0xa9ff('0x19')]['raw']===undefined?!![]:![]:!![],'where':_0x2a94d5[_0xa9ff('0x19')]?_0x2a94d5[_0xa9ff('0x19')]['where']||null:null,'attributes':_0x2a94d5['options']?_0x2a94d5[_0xa9ff('0x19')][_0xa9ff('0x1c')]||null:null,'include':_0x2a94d5[_0xa9ff('0x19')]?_0x2a94d5[_0xa9ff('0x19')][_0xa9ff('0x1e')]?_['map'](_0x2a94d5['options'][_0xa9ff('0x1e')],function(_0x16cfda){return{'model':db[_0x16cfda['model']],'as':_0x16cfda['as'],'attributes':_0x16cfda['attributes'],'include':_0x16cfda[_0xa9ff('0x1e')]?_[_0xa9ff('0x1f')](_0x16cfda[_0xa9ff('0x1e')],function(_0x1a8b4f){return{'model':db[_0x1a8b4f['model']],'as':_0x1a8b4f['as'],'attributes':_0x1a8b4f[_0xa9ff('0x1c')],'include':_0x1a8b4f[_0xa9ff('0x1e')]?_[_0xa9ff('0x1f')](_0x1a8b4f[_0xa9ff('0x1e')],function(_0x37510e){return{'model':db[_0x37510e[_0xa9ff('0x20')]],'as':_0x37510e['as'],'attributes':_0x37510e[_0xa9ff('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3a2bdc){logger[_0xa9ff('0x22')](_0xa9ff('0x25'),_0x2a94d5);logger['debug']('ShowMailQueue',_0x2a94d5,JSON['stringify'](_0x3a2bdc));_0x47b81b(_0x3a2bdc);})['catch'](function(_0x3197a8){logger['error'](_0xa9ff('0x25'),_0x3197a8['message'],_0x2a94d5);_0x569422(_0x106b50['error'](0x1f4,_0x3197a8[_0xa9ff('0x14')]));});});};