Built motion from commit (unavailable).|2.0.82
[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 _0x6281=['raw','where','attributes','limit','include','model','map','debug','stringify','ShowMailQueue','find','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','socket.io-emitter','localhost','./mailQueue.socket','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','MailQueue,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetMailQueue','MailQueue','findAll','options'];(function(_0xec707d,_0x4396bb){var _0x445025=function(_0x3a5843){while(--_0x3a5843){_0xec707d['push'](_0xec707d['shift']());}};_0x445025(++_0x4396bb);}(_0x6281,0x101));var _0x1628=function(_0xc1136d,_0x3d339f){_0xc1136d=_0xc1136d-0x0;var _0x3ba510=_0x6281[_0xc1136d];return _0x3ba510;};'use strict';var _=require(_0x1628('0x0'));var util=require(_0x1628('0x1'));var moment=require(_0x1628('0x2'));var BPromise=require(_0x1628('0x3'));var rs=require('randomstring');var fs=require('fs');var db=require(_0x1628('0x4'))['db'];var utils=require(_0x1628('0x5'));var logger=require(_0x1628('0x6'))('rpc');var config=require(_0x1628('0x7'));var jayson=require(_0x1628('0x8'));var client=jayson[_0x1628('0x9')][_0x1628('0xa')]({'port':0x232a});var socket=require(_0x1628('0xb'))({'host':_0x1628('0xc'),'port':0x18eb});require(_0x1628('0xd'))[_0x1628('0xe')](socket);function respondWithRpcPromise(_0x302d2d,_0x18ab0b,_0x8a01be){return new BPromise(function(_0x5492ae,_0x43602e){return client[_0x1628('0xf')](_0x302d2d,_0x8a01be)[_0x1628('0x10')](function(_0x3a58a8){logger[_0x1628('0x11')](_0x1628('0x12'),_0x18ab0b,_0x1628('0x13'));logger['debug'](_0x1628('0x14'),_0x18ab0b,_0x1628('0x13'),JSON['stringify'](_0x3a58a8));if(_0x3a58a8[_0x1628('0x15')]){if(_0x3a58a8['error'][_0x1628('0x16')]===0x1f4){logger[_0x1628('0x15')]('MailQueue,\x20%s,\x20%s',_0x18ab0b,_0x3a58a8[_0x1628('0x15')][_0x1628('0x17')]);return _0x43602e(_0x3a58a8[_0x1628('0x15')][_0x1628('0x17')]);}logger[_0x1628('0x15')](_0x1628('0x12'),_0x18ab0b,_0x3a58a8[_0x1628('0x15')][_0x1628('0x17')]);return _0x5492ae(_0x3a58a8[_0x1628('0x15')][_0x1628('0x17')]);}else{logger[_0x1628('0x11')](_0x1628('0x12'),_0x18ab0b,'request\x20sent');_0x5492ae(_0x3a58a8[_0x1628('0x18')][_0x1628('0x17')]);}})[_0x1628('0x19')](function(_0x59cac){logger[_0x1628('0x15')](_0x1628('0x12'),_0x18ab0b,_0x59cac);_0x43602e(_0x59cac);});});}exports[_0x1628('0x1a')]=function(_0x4f5c4d){var _0x4a8edc=this;return new Promise(function(_0x6b34d3,_0x1ad1be){return db[_0x1628('0x1b')][_0x1628('0x1c')]({'raw':_0x4f5c4d[_0x1628('0x1d')]?_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x1e')]===undefined?!![]:![]:!![],'where':_0x4f5c4d['options']?_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x1f')]||null:null,'attributes':_0x4f5c4d[_0x1628('0x1d')]?_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x20')]||null:null,'limit':_0x4f5c4d['options']?_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x21')]||null:null,'include':_0x4f5c4d[_0x1628('0x1d')]?_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x22')]?_['map'](_0x4f5c4d[_0x1628('0x1d')][_0x1628('0x22')],function(_0xe47088){return{'model':db[_0xe47088[_0x1628('0x23')]],'as':_0xe47088['as'],'attributes':_0xe47088[_0x1628('0x20')],'include':_0xe47088['include']?_['map'](_0xe47088[_0x1628('0x22')],function(_0x1f3e13){return{'model':db[_0x1f3e13[_0x1628('0x23')]],'as':_0x1f3e13['as'],'attributes':_0x1f3e13['attributes'],'include':_0x1f3e13['include']?_[_0x1628('0x24')](_0x1f3e13[_0x1628('0x22')],function(_0x2c2156){return{'model':db[_0x2c2156[_0x1628('0x23')]],'as':_0x2c2156['as'],'attributes':_0x2c2156[_0x1628('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x36160d){logger[_0x1628('0x11')](_0x1628('0x1a'),_0x4f5c4d);logger[_0x1628('0x25')](_0x1628('0x1a'),_0x4f5c4d,JSON[_0x1628('0x26')](_0x36160d));_0x6b34d3(_0x36160d);})[_0x1628('0x19')](function(_0x168fd5){logger[_0x1628('0x15')](_0x1628('0x1a'),_0x168fd5[_0x1628('0x17')],_0x4f5c4d);_0x1ad1be(_0x4a8edc[_0x1628('0x15')](0x1f4,_0x168fd5[_0x1628('0x17')]));});});};exports[_0x1628('0x27')]=function(_0x1f7d11){var _0x50a768=this;return new Promise(function(_0x7cac4,_0x1fd623){return db['MailQueue'][_0x1628('0x28')]({'raw':_0x1f7d11[_0x1628('0x1d')]?_0x1f7d11[_0x1628('0x1d')][_0x1628('0x1e')]===undefined?!![]:![]:!![],'where':_0x1f7d11['options']?_0x1f7d11[_0x1628('0x1d')][_0x1628('0x1f')]||null:null,'attributes':_0x1f7d11['options']?_0x1f7d11[_0x1628('0x1d')][_0x1628('0x20')]||null:null,'include':_0x1f7d11[_0x1628('0x1d')]?_0x1f7d11[_0x1628('0x1d')][_0x1628('0x22')]?_['map'](_0x1f7d11[_0x1628('0x1d')][_0x1628('0x22')],function(_0x2aa1e8){return{'model':db[_0x2aa1e8[_0x1628('0x23')]],'as':_0x2aa1e8['as'],'attributes':_0x2aa1e8[_0x1628('0x20')],'include':_0x2aa1e8[_0x1628('0x22')]?_[_0x1628('0x24')](_0x2aa1e8[_0x1628('0x22')],function(_0x2689d9){return{'model':db[_0x2689d9[_0x1628('0x23')]],'as':_0x2689d9['as'],'attributes':_0x2689d9[_0x1628('0x20')],'include':_0x2689d9[_0x1628('0x22')]?_[_0x1628('0x24')](_0x2689d9[_0x1628('0x22')],function(_0x27dedd){return{'model':db[_0x27dedd[_0x1628('0x23')]],'as':_0x27dedd['as'],'attributes':_0x27dedd['attributes']};}):[]};}):[]};}):[]:[]})[_0x1628('0x10')](function(_0x420ef4){logger['info'](_0x1628('0x27'),_0x1f7d11);logger['debug'](_0x1628('0x27'),_0x1f7d11,JSON[_0x1628('0x26')](_0x420ef4));_0x7cac4(_0x420ef4);})[_0x1628('0x19')](function(_0x250535){logger[_0x1628('0x15')](_0x1628('0x27'),_0x250535['message'],_0x1f7d11);_0x1fd623(_0x50a768['error'](0x1f4,_0x250535[_0x1628('0x17')]));});});};