Built motion from commit (unavailable).|2.4.17
[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 _0x67eb=['defaults','./mailQueue.socket','request','info','MailQueue,\x20%s,\x20%s','debug','MailQueue,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','GetMailQueue','MailQueue','findAll','options','where','attributes','limit','include','model','ShowMailQueue','map','lodash','util','moment','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','client','redis'];(function(_0x3da35c,_0x14e2ca){var _0x3be334=function(_0xaa5824){while(--_0xaa5824){_0x3da35c['push'](_0x3da35c['shift']());}};_0x3be334(++_0x14e2ca);}(_0x67eb,0x18e));var _0xb67e=function(_0x1a2c6f,_0x341fa0){_0x1a2c6f=_0x1a2c6f-0x0;var _0x483014=_0x67eb[_0x1a2c6f];return _0x483014;};'use strict';var _=require(_0xb67e('0x0'));var util=require(_0xb67e('0x1'));var moment=require(_0xb67e('0x2'));var BPromise=require('bluebird');var rs=require(_0xb67e('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xb67e('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xb67e('0x5'))(_0xb67e('0x6'));var config=require(_0xb67e('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xb67e('0x8')]['http']({'port':0x232a});config[_0xb67e('0x9')]=_[_0xb67e('0xa')](config[_0xb67e('0x9')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xb67e('0xb'))['register'](socket);function respondWithRpcPromise(_0x2c5b0f,_0xbd4887,_0x19f3a9){return new BPromise(function(_0x44ad7a,_0x552f35){return client[_0xb67e('0xc')](_0x2c5b0f,_0x19f3a9)['then'](function(_0xd02a66){logger[_0xb67e('0xd')](_0xb67e('0xe'),_0xbd4887,'request\x20sent');logger[_0xb67e('0xf')](_0xb67e('0x10'),_0xbd4887,_0xb67e('0x11'),JSON[_0xb67e('0x12')](_0xd02a66));if(_0xd02a66[_0xb67e('0x13')]){if(_0xd02a66['error'][_0xb67e('0x14')]===0x1f4){logger[_0xb67e('0x13')](_0xb67e('0xe'),_0xbd4887,_0xd02a66[_0xb67e('0x13')]['message']);return _0x552f35(_0xd02a66[_0xb67e('0x13')][_0xb67e('0x15')]);}logger[_0xb67e('0x13')](_0xb67e('0xe'),_0xbd4887,_0xd02a66['error']['message']);return _0x44ad7a(_0xd02a66[_0xb67e('0x13')][_0xb67e('0x15')]);}else{logger[_0xb67e('0xd')](_0xb67e('0xe'),_0xbd4887,_0xb67e('0x11'));_0x44ad7a(_0xd02a66['result']['message']);}})[_0xb67e('0x16')](function(_0x4e5c6b){logger[_0xb67e('0x13')](_0xb67e('0xe'),_0xbd4887,_0x4e5c6b);_0x552f35(_0x4e5c6b);});});}exports[_0xb67e('0x17')]=function(_0x4f4486){var _0x12f947=this;return new Promise(function(_0x54b00e,_0x5851ad){return db[_0xb67e('0x18')][_0xb67e('0x19')]({'raw':_0x4f4486[_0xb67e('0x1a')]?_0x4f4486[_0xb67e('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x4f4486['options']?_0x4f4486[_0xb67e('0x1a')][_0xb67e('0x1b')]||null:null,'attributes':_0x4f4486['options']?_0x4f4486[_0xb67e('0x1a')][_0xb67e('0x1c')]||null:null,'limit':_0x4f4486[_0xb67e('0x1a')]?_0x4f4486[_0xb67e('0x1a')][_0xb67e('0x1d')]||null:null,'include':_0x4f4486[_0xb67e('0x1a')]?_0x4f4486[_0xb67e('0x1a')][_0xb67e('0x1e')]?_['map'](_0x4f4486['options'][_0xb67e('0x1e')],function(_0x130cc9){return{'model':db[_0x130cc9[_0xb67e('0x1f')]],'as':_0x130cc9['as'],'attributes':_0x130cc9[_0xb67e('0x1c')],'include':_0x130cc9['include']?_['map'](_0x130cc9[_0xb67e('0x1e')],function(_0x25e5ce){return{'model':db[_0x25e5ce['model']],'as':_0x25e5ce['as'],'attributes':_0x25e5ce[_0xb67e('0x1c')],'include':_0x25e5ce[_0xb67e('0x1e')]?_['map'](_0x25e5ce[_0xb67e('0x1e')],function(_0x521bc8){return{'model':db[_0x521bc8[_0xb67e('0x1f')]],'as':_0x521bc8['as'],'attributes':_0x521bc8[_0xb67e('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x537f2c){logger['info'](_0xb67e('0x17'),_0x4f4486);logger[_0xb67e('0xf')]('GetMailQueue',_0x4f4486,JSON[_0xb67e('0x12')](_0x537f2c));_0x54b00e(_0x537f2c);})[_0xb67e('0x16')](function(_0x5eb1ce){logger[_0xb67e('0x13')]('GetMailQueue',_0x5eb1ce['message'],_0x4f4486);_0x5851ad(_0x12f947[_0xb67e('0x13')](0x1f4,_0x5eb1ce[_0xb67e('0x15')]));});});};exports[_0xb67e('0x20')]=function(_0x459854){var _0xeaf0a6=this;return new Promise(function(_0x226ad4,_0x5a17a1){return db[_0xb67e('0x18')]['find']({'raw':_0x459854['options']?_0x459854['options']['raw']===undefined?!![]:![]:!![],'where':_0x459854[_0xb67e('0x1a')]?_0x459854['options'][_0xb67e('0x1b')]||null:null,'attributes':_0x459854[_0xb67e('0x1a')]?_0x459854[_0xb67e('0x1a')]['attributes']||null:null,'include':_0x459854['options']?_0x459854[_0xb67e('0x1a')][_0xb67e('0x1e')]?_[_0xb67e('0x21')](_0x459854['options'][_0xb67e('0x1e')],function(_0x32ecf5){return{'model':db[_0x32ecf5[_0xb67e('0x1f')]],'as':_0x32ecf5['as'],'attributes':_0x32ecf5['attributes'],'include':_0x32ecf5['include']?_[_0xb67e('0x21')](_0x32ecf5['include'],function(_0xcbcbc5){return{'model':db[_0xcbcbc5[_0xb67e('0x1f')]],'as':_0xcbcbc5['as'],'attributes':_0xcbcbc5[_0xb67e('0x1c')],'include':_0xcbcbc5[_0xb67e('0x1e')]?_['map'](_0xcbcbc5[_0xb67e('0x1e')],function(_0x562166){return{'model':db[_0x562166[_0xb67e('0x1f')]],'as':_0x562166['as'],'attributes':_0x562166[_0xb67e('0x1c')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5c50a4){logger[_0xb67e('0xd')](_0xb67e('0x20'),_0x459854);logger[_0xb67e('0xf')](_0xb67e('0x20'),_0x459854,JSON[_0xb67e('0x12')](_0x5c50a4));_0x226ad4(_0x5c50a4);})[_0xb67e('0x16')](function(_0x458a4d){logger['error']('ShowMailQueue',_0x458a4d[_0xb67e('0x15')],_0x459854);_0x5a17a1(_0xeaf0a6[_0xb67e('0x13')](0x1f4,_0x458a4d[_0xb67e('0x15')]));});});};