Built motion from commit (unavailable).|2.0.80
[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 _0xf8fb=['bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','socket.io-emitter','localhost','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetMailQueue','MailQueue','findAll','options','raw','where','attributes','limit','include','map','model','debug','ShowMailQueue','find','lodash','moment'];(function(_0x27b9c1,_0x1196f4){var _0x415c95=function(_0x2fada3){while(--_0x2fada3){_0x27b9c1['push'](_0x27b9c1['shift']());}};_0x415c95(++_0x1196f4);}(_0xf8fb,0x184));var _0xbf8f=function(_0x19950b,_0x53d0d7){_0x19950b=_0x19950b-0x0;var _0x3c6b41=_0xf8fb[_0x19950b];return _0x3c6b41;};'use strict';var _=require(_0xbf8f('0x0'));var util=require('util');var moment=require(_0xbf8f('0x1'));var BPromise=require(_0xbf8f('0x2'));var rs=require(_0xbf8f('0x3'));var fs=require('fs');var db=require(_0xbf8f('0x4'))['db'];var utils=require(_0xbf8f('0x5'));var logger=require('../../config/logger')(_0xbf8f('0x6'));var config=require(_0xbf8f('0x7'));var jayson=require(_0xbf8f('0x8'));var client=jayson[_0xbf8f('0x9')][_0xbf8f('0xa')]({'port':0x232a});var socket=require(_0xbf8f('0xb'))({'host':_0xbf8f('0xc'),'port':0x18eb});require('./mailQueue.socket')[_0xbf8f('0xd')](socket);function respondWithRpcPromise(_0xc3bab1,_0x311171,_0x2eb83f){return new BPromise(function(_0x1b0ac1,_0x440729){return client[_0xbf8f('0xe')](_0xc3bab1,_0x2eb83f)[_0xbf8f('0xf')](function(_0x3df61f){logger[_0xbf8f('0x10')](_0xbf8f('0x11'),_0x311171,_0xbf8f('0x12'));logger['debug']('MailQueue,\x20%s,\x20%s,\x20%s',_0x311171,_0xbf8f('0x12'),JSON[_0xbf8f('0x13')](_0x3df61f));if(_0x3df61f[_0xbf8f('0x14')]){if(_0x3df61f[_0xbf8f('0x14')][_0xbf8f('0x15')]===0x1f4){logger['error'](_0xbf8f('0x11'),_0x311171,_0x3df61f['error'][_0xbf8f('0x16')]);return _0x440729(_0x3df61f[_0xbf8f('0x14')][_0xbf8f('0x16')]);}logger[_0xbf8f('0x14')](_0xbf8f('0x11'),_0x311171,_0x3df61f[_0xbf8f('0x14')][_0xbf8f('0x16')]);return _0x1b0ac1(_0x3df61f[_0xbf8f('0x14')][_0xbf8f('0x16')]);}else{logger[_0xbf8f('0x10')]('MailQueue,\x20%s,\x20%s',_0x311171,_0xbf8f('0x12'));_0x1b0ac1(_0x3df61f[_0xbf8f('0x17')][_0xbf8f('0x16')]);}})[_0xbf8f('0x18')](function(_0x4f2c62){logger[_0xbf8f('0x14')]('MailQueue,\x20%s,\x20%s',_0x311171,_0x4f2c62);_0x440729(_0x4f2c62);});});}exports[_0xbf8f('0x19')]=function(_0x14cb3b){var _0x515b32=this;return new Promise(function(_0x2b2f91,_0xa91e60){return db[_0xbf8f('0x1a')][_0xbf8f('0x1b')]({'raw':_0x14cb3b['options']?_0x14cb3b[_0xbf8f('0x1c')][_0xbf8f('0x1d')]===undefined?!![]:![]:!![],'where':_0x14cb3b[_0xbf8f('0x1c')]?_0x14cb3b[_0xbf8f('0x1c')][_0xbf8f('0x1e')]||null:null,'attributes':_0x14cb3b[_0xbf8f('0x1c')]?_0x14cb3b['options'][_0xbf8f('0x1f')]||null:null,'limit':_0x14cb3b[_0xbf8f('0x1c')]?_0x14cb3b[_0xbf8f('0x1c')][_0xbf8f('0x20')]||null:null,'include':_0x14cb3b[_0xbf8f('0x1c')]?_0x14cb3b['options'][_0xbf8f('0x21')]?_[_0xbf8f('0x22')](_0x14cb3b[_0xbf8f('0x1c')]['include'],function(_0x35e4da){return{'model':db[_0x35e4da['model']],'as':_0x35e4da['as'],'attributes':_0x35e4da[_0xbf8f('0x1f')],'include':_0x35e4da[_0xbf8f('0x21')]?_['map'](_0x35e4da[_0xbf8f('0x21')],function(_0xaf06ec){return{'model':db[_0xaf06ec[_0xbf8f('0x23')]],'as':_0xaf06ec['as'],'attributes':_0xaf06ec[_0xbf8f('0x1f')],'include':_0xaf06ec[_0xbf8f('0x21')]?_[_0xbf8f('0x22')](_0xaf06ec[_0xbf8f('0x21')],function(_0x58e89b){return{'model':db[_0x58e89b[_0xbf8f('0x23')]],'as':_0x58e89b['as'],'attributes':_0x58e89b[_0xbf8f('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xbf8f('0xf')](function(_0x1f4106){logger['info'](_0xbf8f('0x19'),_0x14cb3b);logger[_0xbf8f('0x24')](_0xbf8f('0x19'),_0x14cb3b,JSON[_0xbf8f('0x13')](_0x1f4106));_0x2b2f91(_0x1f4106);})[_0xbf8f('0x18')](function(_0x229771){logger[_0xbf8f('0x14')](_0xbf8f('0x19'),_0x229771[_0xbf8f('0x16')],_0x14cb3b);_0xa91e60(_0x515b32[_0xbf8f('0x14')](0x1f4,_0x229771[_0xbf8f('0x16')]));});});};exports[_0xbf8f('0x25')]=function(_0x236d29){var _0x564d96=this;return new Promise(function(_0xbe8c15,_0x259128){return db[_0xbf8f('0x1a')][_0xbf8f('0x26')]({'raw':_0x236d29[_0xbf8f('0x1c')]?_0x236d29[_0xbf8f('0x1c')][_0xbf8f('0x1d')]===undefined?!![]:![]:!![],'where':_0x236d29[_0xbf8f('0x1c')]?_0x236d29[_0xbf8f('0x1c')][_0xbf8f('0x1e')]||null:null,'attributes':_0x236d29[_0xbf8f('0x1c')]?_0x236d29[_0xbf8f('0x1c')][_0xbf8f('0x1f')]||null:null,'include':_0x236d29[_0xbf8f('0x1c')]?_0x236d29['options'][_0xbf8f('0x21')]?_[_0xbf8f('0x22')](_0x236d29[_0xbf8f('0x1c')][_0xbf8f('0x21')],function(_0x25277c){return{'model':db[_0x25277c['model']],'as':_0x25277c['as'],'attributes':_0x25277c['attributes'],'include':_0x25277c[_0xbf8f('0x21')]?_[_0xbf8f('0x22')](_0x25277c['include'],function(_0x360b1a){return{'model':db[_0x360b1a[_0xbf8f('0x23')]],'as':_0x360b1a['as'],'attributes':_0x360b1a[_0xbf8f('0x1f')],'include':_0x360b1a[_0xbf8f('0x21')]?_['map'](_0x360b1a['include'],function(_0x4916ad){return{'model':db[_0x4916ad['model']],'as':_0x4916ad['as'],'attributes':_0x4916ad[_0xbf8f('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xbf8f('0xf')](function(_0x3514e2){logger[_0xbf8f('0x10')](_0xbf8f('0x25'),_0x236d29);logger[_0xbf8f('0x24')](_0xbf8f('0x25'),_0x236d29,JSON[_0xbf8f('0x13')](_0x3514e2));_0xbe8c15(_0x3514e2);})[_0xbf8f('0x18')](function(_0x548234){logger[_0xbf8f('0x14')](_0xbf8f('0x25'),_0x548234[_0xbf8f('0x16')],_0x236d29);_0x259128(_0x564d96[_0xbf8f('0x14')](0x1f4,_0x548234['message']));});});};