Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / mailServerIn / mailServerIn.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 _0x2dfb=['lodash','util','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/environment','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','MailServerIn,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','GetMailServerIn','findAll','options','raw','where','attributes','include','map','model','debug','catch'];(function(_0x51f5d0,_0xb90d1a){var _0x17b622=function(_0x472f57){while(--_0x472f57){_0x51f5d0['push'](_0x51f5d0['shift']());}};_0x17b622(++_0xb90d1a);}(_0x2dfb,0x10e));var _0xb2df=function(_0x45b1ee,_0x246218){_0x45b1ee=_0x45b1ee-0x0;var _0x2c93af=_0x2dfb[_0x45b1ee];return _0x2c93af;};'use strict';var _=require(_0xb2df('0x0'));var util=require(_0xb2df('0x1'));var moment=require('moment');var BPromise=require(_0xb2df('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb2df('0x3'));var db=require(_0xb2df('0x4'))['db'];var utils=require(_0xb2df('0x5'));var logger=require('../../config/logger')('rpc');var config=require(_0xb2df('0x6'));var jayson=require('jayson/promise');var client=jayson[_0xb2df('0x7')][_0xb2df('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x2e4ade,_0x3a8b74,_0x203af6){return new BPromise(function(_0x26bd09,_0x43a8c0){return client[_0xb2df('0x9')](_0x2e4ade,_0x203af6)[_0xb2df('0xa')](function(_0x4abd84){logger[_0xb2df('0xb')](_0xb2df('0xc'),_0x3a8b74,'request\x20sent');logger['debug'](_0xb2df('0xd'),_0x3a8b74,_0xb2df('0xe'),JSON[_0xb2df('0xf')](_0x4abd84));if(_0x4abd84[_0xb2df('0x10')]){if(_0x4abd84[_0xb2df('0x10')][_0xb2df('0x11')]===0x1f4){logger[_0xb2df('0x10')](_0xb2df('0xc'),_0x3a8b74,_0x4abd84[_0xb2df('0x10')][_0xb2df('0x12')]);return _0x43a8c0(_0x4abd84[_0xb2df('0x10')][_0xb2df('0x12')]);}logger['error']('MailServerIn,\x20%s,\x20%s',_0x3a8b74,_0x4abd84[_0xb2df('0x10')]['message']);return _0x26bd09(_0x4abd84[_0xb2df('0x10')][_0xb2df('0x12')]);}else{logger[_0xb2df('0xb')]('MailServerIn,\x20%s,\x20%s',_0x3a8b74,_0xb2df('0xe'));_0x26bd09(_0x4abd84['result']['message']);}})['catch'](function(_0x2dbaae){logger[_0xb2df('0x10')]('MailServerIn,\x20%s,\x20%s',_0x3a8b74,_0x2dbaae);_0x43a8c0(_0x2dbaae);});});}exports[_0xb2df('0x13')]=function(_0x37e733){var _0x301635=this;return new Promise(function(_0x327d4a,_0x712d8){return db['MailServerIn'][_0xb2df('0x14')]({'raw':_0x37e733[_0xb2df('0x15')]?_0x37e733[_0xb2df('0x15')][_0xb2df('0x16')]===undefined?!![]:![]:!![],'where':_0x37e733[_0xb2df('0x15')]?_0x37e733[_0xb2df('0x15')][_0xb2df('0x17')]||null:null,'attributes':_0x37e733['options']?_0x37e733[_0xb2df('0x15')][_0xb2df('0x18')]||null:null,'limit':_0x37e733[_0xb2df('0x15')]?_0x37e733[_0xb2df('0x15')]['limit']||null:null,'include':_0x37e733[_0xb2df('0x15')]?_0x37e733[_0xb2df('0x15')][_0xb2df('0x19')]?_[_0xb2df('0x1a')](_0x37e733[_0xb2df('0x15')][_0xb2df('0x19')],function(_0x38094e){return{'model':db[_0x38094e[_0xb2df('0x1b')]],'as':_0x38094e['as'],'attributes':_0x38094e[_0xb2df('0x18')],'include':_0x38094e[_0xb2df('0x19')]?_[_0xb2df('0x1a')](_0x38094e[_0xb2df('0x19')],function(_0x173acd){return{'model':db[_0x173acd[_0xb2df('0x1b')]],'as':_0x173acd['as'],'attributes':_0x173acd[_0xb2df('0x18')],'include':_0x173acd['include']?_[_0xb2df('0x1a')](_0x173acd[_0xb2df('0x19')],function(_0x14ccd3){return{'model':db[_0x14ccd3['model']],'as':_0x14ccd3['as'],'attributes':_0x14ccd3['attributes']};}):[]};}):[]};}):[]:[]})[_0xb2df('0xa')](function(_0x4efab0){logger['info'](_0xb2df('0x13'),_0x37e733);logger[_0xb2df('0x1c')]('GetMailServerIn',_0x37e733,JSON[_0xb2df('0xf')](_0x4efab0));_0x327d4a(_0x4efab0);})[_0xb2df('0x1d')](function(_0x33c9b8){logger[_0xb2df('0x10')]('GetMailServerIn',_0x33c9b8[_0xb2df('0x12')],_0x37e733);_0x712d8(_0x301635[_0xb2df('0x10')](0x1f4,_0x33c9b8[_0xb2df('0x12')]));});});};