35f84a7387b553c58dfbfeaedc14d8aaf3c9eaa2
[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 _0x3c0d=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','MailServerIn,\x20%s,\x20%s,\x20%s','error','code','message','result','GetMailServerIn','findAll','options','raw','attributes','map','model','include','debug','stringify','catch','bluebird','randomstring'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x3c0d,0xf6));var _0xd3c0=function(_0xd03824,_0x227f4c){_0xd03824=_0xd03824-0x0;var _0x2ccb5c=_0x3c0d[_0xd03824];return _0x2ccb5c;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xd3c0('0x0'));var rs=require(_0xd3c0('0x1'));var fs=require('fs');var Redis=require(_0xd3c0('0x2'));var db=require(_0xd3c0('0x3'))['db'];var utils=require(_0xd3c0('0x4'));var logger=require(_0xd3c0('0x5'))(_0xd3c0('0x6'));var config=require(_0xd3c0('0x7'));var jayson=require(_0xd3c0('0x8'));var client=jayson['client'][_0xd3c0('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x47fa5f,_0x6308e2,_0x10f804){return new BPromise(function(_0x2c37b8,_0x2d11d5){return client[_0xd3c0('0xa')](_0x47fa5f,_0x10f804)[_0xd3c0('0xb')](function(_0x2be3c0){logger[_0xd3c0('0xc')](_0xd3c0('0xd'),_0x6308e2,_0xd3c0('0xe'));logger['debug'](_0xd3c0('0xf'),_0x6308e2,_0xd3c0('0xe'),JSON['stringify'](_0x2be3c0));if(_0x2be3c0['error']){if(_0x2be3c0[_0xd3c0('0x10')][_0xd3c0('0x11')]===0x1f4){logger[_0xd3c0('0x10')](_0xd3c0('0xd'),_0x6308e2,_0x2be3c0['error'][_0xd3c0('0x12')]);return _0x2d11d5(_0x2be3c0[_0xd3c0('0x10')][_0xd3c0('0x12')]);}logger['error'](_0xd3c0('0xd'),_0x6308e2,_0x2be3c0[_0xd3c0('0x10')][_0xd3c0('0x12')]);return _0x2c37b8(_0x2be3c0[_0xd3c0('0x10')][_0xd3c0('0x12')]);}else{logger[_0xd3c0('0xc')]('MailServerIn,\x20%s,\x20%s',_0x6308e2,'request\x20sent');_0x2c37b8(_0x2be3c0[_0xd3c0('0x13')][_0xd3c0('0x12')]);}})['catch'](function(_0x3e9b6b){logger[_0xd3c0('0x10')](_0xd3c0('0xd'),_0x6308e2,_0x3e9b6b);_0x2d11d5(_0x3e9b6b);});});}exports[_0xd3c0('0x14')]=function(_0x1a204c){var _0x2adf93=this;return new Promise(function(_0x24e048,_0x53584a){return db['MailServerIn'][_0xd3c0('0x15')]({'raw':_0x1a204c['options']?_0x1a204c[_0xd3c0('0x16')][_0xd3c0('0x17')]===undefined?!![]:![]:!![],'where':_0x1a204c[_0xd3c0('0x16')]?_0x1a204c[_0xd3c0('0x16')]['where']||null:null,'attributes':_0x1a204c['options']?_0x1a204c[_0xd3c0('0x16')][_0xd3c0('0x18')]||null:null,'limit':_0x1a204c[_0xd3c0('0x16')]?_0x1a204c[_0xd3c0('0x16')]['limit']||null:null,'include':_0x1a204c[_0xd3c0('0x16')]?_0x1a204c['options']['include']?_[_0xd3c0('0x19')](_0x1a204c[_0xd3c0('0x16')]['include'],function(_0x3ac1b3){return{'model':db[_0x3ac1b3[_0xd3c0('0x1a')]],'as':_0x3ac1b3['as'],'attributes':_0x3ac1b3['attributes'],'include':_0x3ac1b3[_0xd3c0('0x1b')]?_['map'](_0x3ac1b3['include'],function(_0x23e772){return{'model':db[_0x23e772[_0xd3c0('0x1a')]],'as':_0x23e772['as'],'attributes':_0x23e772['attributes'],'include':_0x23e772['include']?_[_0xd3c0('0x19')](_0x23e772[_0xd3c0('0x1b')],function(_0x58d3cc){return{'model':db[_0x58d3cc['model']],'as':_0x58d3cc['as'],'attributes':_0x58d3cc[_0xd3c0('0x18')]};}):[]};}):[]};}):[]:[]})[_0xd3c0('0xb')](function(_0xa7a5c2){logger['info'](_0xd3c0('0x14'),_0x1a204c);logger[_0xd3c0('0x1c')]('GetMailServerIn',_0x1a204c,JSON[_0xd3c0('0x1d')](_0xa7a5c2));_0x24e048(_0xa7a5c2);})[_0xd3c0('0x1e')](function(_0xeeaecc){logger[_0xd3c0('0x10')](_0xd3c0('0x14'),_0xeeaecc['message'],_0x1a204c);_0x53584a(_0x2adf93[_0xd3c0('0x10')](0x1f4,_0xeeaecc[_0xd3c0('0x12')]));});});};