Built motion from commit (unavailable).|2.0.81
[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 _0x6659=['raw','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','socket.io-emitter','localhost','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','MailQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','GetMailQueue','MailQueue','findAll','options','where','attributes','limit','include','map','model','debug','ShowMailQueue','find'];(function(_0x3a49c8,_0x50c18e){var _0x48925b=function(_0x5afc7d){while(--_0x5afc7d){_0x3a49c8['push'](_0x3a49c8['shift']());}};_0x48925b(++_0x50c18e);}(_0x6659,0x169));var _0x9665=function(_0x3e4276,_0x56a6b1){_0x3e4276=_0x3e4276-0x0;var _0x46617a=_0x6659[_0x3e4276];return _0x46617a;};'use strict';var _=require(_0x9665('0x0'));var util=require(_0x9665('0x1'));var moment=require(_0x9665('0x2'));var BPromise=require(_0x9665('0x3'));var rs=require(_0x9665('0x4'));var fs=require('fs');var db=require(_0x9665('0x5'))['db'];var utils=require(_0x9665('0x6'));var logger=require(_0x9665('0x7'))('rpc');var config=require(_0x9665('0x8'));var jayson=require(_0x9665('0x9'));var client=jayson[_0x9665('0xa')][_0x9665('0xb')]({'port':0x232a});var socket=require(_0x9665('0xc'))({'host':_0x9665('0xd'),'port':0x18eb});require('./mailQueue.socket')[_0x9665('0xe')](socket);function respondWithRpcPromise(_0xe9d4ff,_0x1738a5,_0x432ad9){return new BPromise(function(_0x2a3374,_0x439736){return client[_0x9665('0xf')](_0xe9d4ff,_0x432ad9)[_0x9665('0x10')](function(_0x36cac1){logger[_0x9665('0x11')](_0x9665('0x12'),_0x1738a5,_0x9665('0x13'));logger['debug'](_0x9665('0x14'),_0x1738a5,'request\x20sent',JSON[_0x9665('0x15')](_0x36cac1));if(_0x36cac1[_0x9665('0x16')]){if(_0x36cac1[_0x9665('0x16')][_0x9665('0x17')]===0x1f4){logger['error'](_0x9665('0x12'),_0x1738a5,_0x36cac1[_0x9665('0x16')][_0x9665('0x18')]);return _0x439736(_0x36cac1[_0x9665('0x16')][_0x9665('0x18')]);}logger[_0x9665('0x16')](_0x9665('0x12'),_0x1738a5,_0x36cac1['error'][_0x9665('0x18')]);return _0x2a3374(_0x36cac1['error'][_0x9665('0x18')]);}else{logger['info']('MailQueue,\x20%s,\x20%s',_0x1738a5,_0x9665('0x13'));_0x2a3374(_0x36cac1['result']['message']);}})[_0x9665('0x19')](function(_0x2f24b9){logger['error']('MailQueue,\x20%s,\x20%s',_0x1738a5,_0x2f24b9);_0x439736(_0x2f24b9);});});}exports[_0x9665('0x1a')]=function(_0x9d1b70){var _0xd97de5=this;return new Promise(function(_0x33fed9,_0x273ad3){return db[_0x9665('0x1b')][_0x9665('0x1c')]({'raw':_0x9d1b70[_0x9665('0x1d')]?_0x9d1b70[_0x9665('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x9d1b70[_0x9665('0x1d')]?_0x9d1b70[_0x9665('0x1d')][_0x9665('0x1e')]||null:null,'attributes':_0x9d1b70[_0x9665('0x1d')]?_0x9d1b70[_0x9665('0x1d')][_0x9665('0x1f')]||null:null,'limit':_0x9d1b70['options']?_0x9d1b70[_0x9665('0x1d')][_0x9665('0x20')]||null:null,'include':_0x9d1b70[_0x9665('0x1d')]?_0x9d1b70[_0x9665('0x1d')][_0x9665('0x21')]?_[_0x9665('0x22')](_0x9d1b70[_0x9665('0x1d')]['include'],function(_0x38db97){return{'model':db[_0x38db97[_0x9665('0x23')]],'as':_0x38db97['as'],'attributes':_0x38db97[_0x9665('0x1f')],'include':_0x38db97['include']?_[_0x9665('0x22')](_0x38db97[_0x9665('0x21')],function(_0x56847b){return{'model':db[_0x56847b['model']],'as':_0x56847b['as'],'attributes':_0x56847b[_0x9665('0x1f')],'include':_0x56847b[_0x9665('0x21')]?_[_0x9665('0x22')](_0x56847b[_0x9665('0x21')],function(_0x4bb048){return{'model':db[_0x4bb048[_0x9665('0x23')]],'as':_0x4bb048['as'],'attributes':_0x4bb048[_0x9665('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x467759){logger[_0x9665('0x11')](_0x9665('0x1a'),_0x9d1b70);logger[_0x9665('0x24')](_0x9665('0x1a'),_0x9d1b70,JSON[_0x9665('0x15')](_0x467759));_0x33fed9(_0x467759);})[_0x9665('0x19')](function(_0x48840e){logger[_0x9665('0x16')](_0x9665('0x1a'),_0x48840e['message'],_0x9d1b70);_0x273ad3(_0xd97de5[_0x9665('0x16')](0x1f4,_0x48840e[_0x9665('0x18')]));});});};exports[_0x9665('0x25')]=function(_0x28067a){var _0x128006=this;return new Promise(function(_0x41bad5,_0xac1df6){return db[_0x9665('0x1b')][_0x9665('0x26')]({'raw':_0x28067a[_0x9665('0x1d')]?_0x28067a[_0x9665('0x1d')][_0x9665('0x27')]===undefined?!![]:![]:!![],'where':_0x28067a[_0x9665('0x1d')]?_0x28067a[_0x9665('0x1d')][_0x9665('0x1e')]||null:null,'attributes':_0x28067a[_0x9665('0x1d')]?_0x28067a[_0x9665('0x1d')][_0x9665('0x1f')]||null:null,'include':_0x28067a['options']?_0x28067a[_0x9665('0x1d')]['include']?_[_0x9665('0x22')](_0x28067a[_0x9665('0x1d')][_0x9665('0x21')],function(_0x185c9c){return{'model':db[_0x185c9c[_0x9665('0x23')]],'as':_0x185c9c['as'],'attributes':_0x185c9c[_0x9665('0x1f')],'include':_0x185c9c['include']?_[_0x9665('0x22')](_0x185c9c[_0x9665('0x21')],function(_0x2b05a5){return{'model':db[_0x2b05a5[_0x9665('0x23')]],'as':_0x2b05a5['as'],'attributes':_0x2b05a5[_0x9665('0x1f')],'include':_0x2b05a5['include']?_[_0x9665('0x22')](_0x2b05a5['include'],function(_0x41ed34){return{'model':db[_0x41ed34[_0x9665('0x23')]],'as':_0x41ed34['as'],'attributes':_0x41ed34[_0x9665('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x9665('0x10')](function(_0x4215e6){logger[_0x9665('0x11')](_0x9665('0x25'),_0x28067a);logger[_0x9665('0x24')](_0x9665('0x25'),_0x28067a,JSON[_0x9665('0x15')](_0x4215e6));_0x41bad5(_0x4215e6);})[_0x9665('0x19')](function(_0x5afd07){logger[_0x9665('0x16')](_0x9665('0x25'),_0x5afd07[_0x9665('0x18')],_0x28067a);_0xac1df6(_0x128006[_0x9665('0x16')](0x1f4,_0x5afd07[_0x9665('0x18')]));});});};