Built motion from commit d9028345.|2.5.43
[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 _0x97b5=['bluebird','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./mailQueue.socket','request','then','info','request\x20sent','MailQueue,\x20%s,\x20%s,\x20%s','stringify','error','code','message','MailQueue,\x20%s,\x20%s','result','GetMailQueue','findAll','options','where','attributes','limit','include','map','model','debug','catch','ShowMailQueue','MailQueue','find','raw','util'];(function(_0x2c6264,_0x4830f4){var _0x44d8=function(_0x32855a){while(--_0x32855a){_0x2c6264['push'](_0x2c6264['shift']());}};_0x44d8(++_0x4830f4);}(_0x97b5,0x137));var _0x597b=function(_0x4bfe6f,_0x2a4e4c){_0x4bfe6f=_0x4bfe6f-0x0;var _0x388d9e=_0x97b5[_0x4bfe6f];return _0x388d9e;};'use strict';var _=require('lodash');var util=require(_0x597b('0x0'));var moment=require('moment');var BPromise=require(_0x597b('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x597b('0x2'));var db=require(_0x597b('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x597b('0x4'))('rpc');var config=require(_0x597b('0x5'));var jayson=require(_0x597b('0x6'));var client=jayson[_0x597b('0x7')][_0x597b('0x8')]({'port':0x232a});config[_0x597b('0x9')]=_[_0x597b('0xa')](config[_0x597b('0x9')],{'host':_0x597b('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x597b('0xc'))['register'](socket);function respondWithRpcPromise(_0xb78319,_0x2202e5,_0x3628f2){return new BPromise(function(_0x31e0bd,_0x281dc5){return client[_0x597b('0xd')](_0xb78319,_0x3628f2)[_0x597b('0xe')](function(_0x33bec0){logger[_0x597b('0xf')]('MailQueue,\x20%s,\x20%s',_0x2202e5,_0x597b('0x10'));logger['debug'](_0x597b('0x11'),_0x2202e5,_0x597b('0x10'),JSON[_0x597b('0x12')](_0x33bec0));if(_0x33bec0[_0x597b('0x13')]){if(_0x33bec0[_0x597b('0x13')][_0x597b('0x14')]===0x1f4){logger[_0x597b('0x13')]('MailQueue,\x20%s,\x20%s',_0x2202e5,_0x33bec0['error'][_0x597b('0x15')]);return _0x281dc5(_0x33bec0[_0x597b('0x13')][_0x597b('0x15')]);}logger['error']('MailQueue,\x20%s,\x20%s',_0x2202e5,_0x33bec0[_0x597b('0x13')][_0x597b('0x15')]);return _0x31e0bd(_0x33bec0['error'][_0x597b('0x15')]);}else{logger[_0x597b('0xf')](_0x597b('0x16'),_0x2202e5,'request\x20sent');_0x31e0bd(_0x33bec0[_0x597b('0x17')][_0x597b('0x15')]);}})['catch'](function(_0x2fb27e){logger['error'](_0x597b('0x16'),_0x2202e5,_0x2fb27e);_0x281dc5(_0x2fb27e);});});}exports[_0x597b('0x18')]=function(_0x30ef6d){var _0x49cd83=this;return new Promise(function(_0x1af394,_0x337478){return db['MailQueue'][_0x597b('0x19')]({'raw':_0x30ef6d[_0x597b('0x1a')]?_0x30ef6d['options']['raw']===undefined?!![]:![]:!![],'where':_0x30ef6d[_0x597b('0x1a')]?_0x30ef6d['options'][_0x597b('0x1b')]||null:null,'attributes':_0x30ef6d['options']?_0x30ef6d[_0x597b('0x1a')][_0x597b('0x1c')]||null:null,'limit':_0x30ef6d[_0x597b('0x1a')]?_0x30ef6d[_0x597b('0x1a')][_0x597b('0x1d')]||null:null,'include':_0x30ef6d['options']?_0x30ef6d[_0x597b('0x1a')][_0x597b('0x1e')]?_[_0x597b('0x1f')](_0x30ef6d[_0x597b('0x1a')][_0x597b('0x1e')],function(_0x427909){return{'model':db[_0x427909['model']],'as':_0x427909['as'],'attributes':_0x427909[_0x597b('0x1c')],'include':_0x427909['include']?_[_0x597b('0x1f')](_0x427909['include'],function(_0x3baabe){return{'model':db[_0x3baabe[_0x597b('0x20')]],'as':_0x3baabe['as'],'attributes':_0x3baabe['attributes'],'include':_0x3baabe['include']?_[_0x597b('0x1f')](_0x3baabe[_0x597b('0x1e')],function(_0x362665){return{'model':db[_0x362665[_0x597b('0x20')]],'as':_0x362665['as'],'attributes':_0x362665[_0x597b('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x597b('0xe')](function(_0x5e080e){logger[_0x597b('0xf')](_0x597b('0x18'),_0x30ef6d);logger[_0x597b('0x21')](_0x597b('0x18'),_0x30ef6d,JSON[_0x597b('0x12')](_0x5e080e));_0x1af394(_0x5e080e);})[_0x597b('0x22')](function(_0x3ce0ce){logger[_0x597b('0x13')]('GetMailQueue',_0x3ce0ce[_0x597b('0x15')],_0x30ef6d);_0x337478(_0x49cd83[_0x597b('0x13')](0x1f4,_0x3ce0ce[_0x597b('0x15')]));});});};exports[_0x597b('0x23')]=function(_0x181fa3){var _0x52435f=this;return new Promise(function(_0x1d1e0f,_0x4ad8cc){return db[_0x597b('0x24')][_0x597b('0x25')]({'raw':_0x181fa3['options']?_0x181fa3[_0x597b('0x1a')][_0x597b('0x26')]===undefined?!![]:![]:!![],'where':_0x181fa3[_0x597b('0x1a')]?_0x181fa3[_0x597b('0x1a')][_0x597b('0x1b')]||null:null,'attributes':_0x181fa3['options']?_0x181fa3[_0x597b('0x1a')]['attributes']||null:null,'include':_0x181fa3[_0x597b('0x1a')]?_0x181fa3[_0x597b('0x1a')][_0x597b('0x1e')]?_[_0x597b('0x1f')](_0x181fa3[_0x597b('0x1a')]['include'],function(_0x52b78e){return{'model':db[_0x52b78e[_0x597b('0x20')]],'as':_0x52b78e['as'],'attributes':_0x52b78e['attributes'],'include':_0x52b78e[_0x597b('0x1e')]?_[_0x597b('0x1f')](_0x52b78e[_0x597b('0x1e')],function(_0xe35030){return{'model':db[_0xe35030[_0x597b('0x20')]],'as':_0xe35030['as'],'attributes':_0xe35030[_0x597b('0x1c')],'include':_0xe35030[_0x597b('0x1e')]?_[_0x597b('0x1f')](_0xe35030[_0x597b('0x1e')],function(_0x16a9d9){return{'model':db[_0x16a9d9['model']],'as':_0x16a9d9['as'],'attributes':_0x16a9d9[_0x597b('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x597b('0xe')](function(_0xf50ee9){logger[_0x597b('0xf')]('ShowMailQueue',_0x181fa3);logger['debug'](_0x597b('0x23'),_0x181fa3,JSON[_0x597b('0x12')](_0xf50ee9));_0x1d1e0f(_0xf50ee9);})['catch'](function(_0x19c17a){logger['error'](_0x597b('0x23'),_0x19c17a['message'],_0x181fa3);_0x4ad8cc(_0x52435f[_0x597b('0x13')](0x1f4,_0x19c17a[_0x597b('0x15')]));});});};