Built motion from commit ff426b3f.|2.6.29
[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 _0x7084=['./mailQueue.socket','register','request','then','info','MailQueue,\x20%s,\x20%s','request\x20sent','debug','MailQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','MailQueue','findAll','options','raw','attributes','limit','include','map','model','GetMailQueue','find','where','ShowMailQueue','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter'];(function(_0x69a451,_0x49fd37){var _0x3d6ef5=function(_0x27ebf4){while(--_0x27ebf4){_0x69a451['push'](_0x69a451['shift']());}};_0x3d6ef5(++_0x49fd37);}(_0x7084,0x118));var _0x4708=function(_0x539bde,_0x14b7db){_0x539bde=_0x539bde-0x0;var _0x1718d4=_0x7084[_0x539bde];return _0x1718d4;};'use strict';var _=require(_0x4708('0x0'));var util=require('util');var moment=require(_0x4708('0x1'));var BPromise=require(_0x4708('0x2'));var rs=require(_0x4708('0x3'));var fs=require('fs');var Redis=require(_0x4708('0x4'));var db=require(_0x4708('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x4708('0x6'))('rpc');var config=require(_0x4708('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x4708('0x8')][_0x4708('0x9')]({'port':0x232a});config[_0x4708('0xa')]=_[_0x4708('0xb')](config[_0x4708('0xa')],{'host':_0x4708('0xc'),'port':0x18eb});var socket=require(_0x4708('0xd'))(new Redis(config[_0x4708('0xa')]));require(_0x4708('0xe'))[_0x4708('0xf')](socket);function respondWithRpcPromise(_0x1c3f3d,_0x1029d8,_0x3a66e5){return new BPromise(function(_0x41df0b,_0x456aba){return client[_0x4708('0x10')](_0x1c3f3d,_0x3a66e5)[_0x4708('0x11')](function(_0x3bb353){logger[_0x4708('0x12')](_0x4708('0x13'),_0x1029d8,_0x4708('0x14'));logger[_0x4708('0x15')](_0x4708('0x16'),_0x1029d8,_0x4708('0x14'),JSON[_0x4708('0x17')](_0x3bb353));if(_0x3bb353[_0x4708('0x18')]){if(_0x3bb353['error'][_0x4708('0x19')]===0x1f4){logger[_0x4708('0x18')](_0x4708('0x13'),_0x1029d8,_0x3bb353[_0x4708('0x18')][_0x4708('0x1a')]);return _0x456aba(_0x3bb353[_0x4708('0x18')][_0x4708('0x1a')]);}logger[_0x4708('0x18')](_0x4708('0x13'),_0x1029d8,_0x3bb353['error'][_0x4708('0x1a')]);return _0x41df0b(_0x3bb353[_0x4708('0x18')][_0x4708('0x1a')]);}else{logger[_0x4708('0x12')](_0x4708('0x13'),_0x1029d8,'request\x20sent');_0x41df0b(_0x3bb353[_0x4708('0x1b')][_0x4708('0x1a')]);}})[_0x4708('0x1c')](function(_0x45d9c9){logger[_0x4708('0x18')](_0x4708('0x13'),_0x1029d8,_0x45d9c9);_0x456aba(_0x45d9c9);});});}exports['GetMailQueue']=function(_0x4ccd16){var _0x29dc02=this;return new Promise(function(_0x27de08,_0x40e9f4){return db[_0x4708('0x1d')][_0x4708('0x1e')]({'raw':_0x4ccd16[_0x4708('0x1f')]?_0x4ccd16[_0x4708('0x1f')][_0x4708('0x20')]===undefined?!![]:![]:!![],'where':_0x4ccd16[_0x4708('0x1f')]?_0x4ccd16['options']['where']||null:null,'attributes':_0x4ccd16[_0x4708('0x1f')]?_0x4ccd16[_0x4708('0x1f')][_0x4708('0x21')]||null:null,'limit':_0x4ccd16['options']?_0x4ccd16[_0x4708('0x1f')][_0x4708('0x22')]||null:null,'include':_0x4ccd16[_0x4708('0x1f')]?_0x4ccd16[_0x4708('0x1f')][_0x4708('0x23')]?_[_0x4708('0x24')](_0x4ccd16[_0x4708('0x1f')]['include'],function(_0x3db434){return{'model':db[_0x3db434[_0x4708('0x25')]],'as':_0x3db434['as'],'attributes':_0x3db434[_0x4708('0x21')],'include':_0x3db434['include']?_[_0x4708('0x24')](_0x3db434['include'],function(_0x4049d3){return{'model':db[_0x4049d3[_0x4708('0x25')]],'as':_0x4049d3['as'],'attributes':_0x4049d3[_0x4708('0x21')],'include':_0x4049d3[_0x4708('0x23')]?_[_0x4708('0x24')](_0x4049d3[_0x4708('0x23')],function(_0x467ea5){return{'model':db[_0x467ea5[_0x4708('0x25')]],'as':_0x467ea5['as'],'attributes':_0x467ea5[_0x4708('0x21')]};}):[]};}):[]};}):[]:[]})[_0x4708('0x11')](function(_0x48ee67){logger[_0x4708('0x12')]('GetMailQueue',_0x4ccd16);logger[_0x4708('0x15')](_0x4708('0x26'),_0x4ccd16,JSON['stringify'](_0x48ee67));_0x27de08(_0x48ee67);})[_0x4708('0x1c')](function(_0x2c601d){logger[_0x4708('0x18')](_0x4708('0x26'),_0x2c601d[_0x4708('0x1a')],_0x4ccd16);_0x40e9f4(_0x29dc02[_0x4708('0x18')](0x1f4,_0x2c601d[_0x4708('0x1a')]));});});};exports['ShowMailQueue']=function(_0x3fcfb6){var _0x158669=this;return new Promise(function(_0x302e5e,_0x2f6d2c){return db[_0x4708('0x1d')][_0x4708('0x27')]({'raw':_0x3fcfb6[_0x4708('0x1f')]?_0x3fcfb6['options']['raw']===undefined?!![]:![]:!![],'where':_0x3fcfb6[_0x4708('0x1f')]?_0x3fcfb6[_0x4708('0x1f')][_0x4708('0x28')]||null:null,'attributes':_0x3fcfb6[_0x4708('0x1f')]?_0x3fcfb6[_0x4708('0x1f')][_0x4708('0x21')]||null:null,'include':_0x3fcfb6[_0x4708('0x1f')]?_0x3fcfb6[_0x4708('0x1f')][_0x4708('0x23')]?_[_0x4708('0x24')](_0x3fcfb6[_0x4708('0x1f')][_0x4708('0x23')],function(_0x1608e5){return{'model':db[_0x1608e5[_0x4708('0x25')]],'as':_0x1608e5['as'],'attributes':_0x1608e5[_0x4708('0x21')],'include':_0x1608e5['include']?_[_0x4708('0x24')](_0x1608e5['include'],function(_0x3edc39){return{'model':db[_0x3edc39[_0x4708('0x25')]],'as':_0x3edc39['as'],'attributes':_0x3edc39[_0x4708('0x21')],'include':_0x3edc39[_0x4708('0x23')]?_[_0x4708('0x24')](_0x3edc39[_0x4708('0x23')],function(_0x1048b0){return{'model':db[_0x1048b0[_0x4708('0x25')]],'as':_0x1048b0['as'],'attributes':_0x1048b0[_0x4708('0x21')]};}):[]};}):[]};}):[]:[]})[_0x4708('0x11')](function(_0x2b78d4){logger[_0x4708('0x12')](_0x4708('0x29'),_0x3fcfb6);logger['debug'](_0x4708('0x29'),_0x3fcfb6,JSON[_0x4708('0x17')](_0x2b78d4));_0x302e5e(_0x2b78d4);})[_0x4708('0x1c')](function(_0x261195){logger[_0x4708('0x18')](_0x4708('0x29'),_0x261195['message'],_0x3fcfb6);_0x2f6d2c(_0x158669['error'](0x1f4,_0x261195[_0x4708('0x1a')]));});});};