ed52070af7c7b71e4fc448efc124380c8bcf3cc6
[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 _0x29a5=['attributes','include','model','map','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','info','debug','MailServerIn,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','MailServerIn,\x20%s,\x20%s','message','result','catch','GetMailServerIn','MailServerIn','findAll','options','raw','where'];(function(_0x10ee3b,_0x58d9d0){var _0x1d0b32=function(_0x3f55bc){while(--_0x3f55bc){_0x10ee3b['push'](_0x10ee3b['shift']());}};_0x1d0b32(++_0x58d9d0);}(_0x29a5,0x1e0));var _0x529a=function(_0x8c43de,_0x90ff31){_0x8c43de=_0x8c43de-0x0;var _0xa6591b=_0x29a5[_0x8c43de];return _0xa6591b;};'use strict';var _=require(_0x529a('0x0'));var util=require(_0x529a('0x1'));var moment=require(_0x529a('0x2'));var BPromise=require('bluebird');var rs=require(_0x529a('0x3'));var fs=require('fs');var Redis=require(_0x529a('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x529a('0x5'));var logger=require(_0x529a('0x6'))('rpc');var config=require(_0x529a('0x7'));var jayson=require(_0x529a('0x8'));var client=jayson[_0x529a('0x9')][_0x529a('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3da223,_0x6861f0,_0x1c9b41){return new BPromise(function(_0x4b8ad9,_0x465d78){return client[_0x529a('0xb')](_0x3da223,_0x1c9b41)[_0x529a('0xc')](function(_0x5558a3){logger[_0x529a('0xd')]('MailServerIn,\x20%s,\x20%s',_0x6861f0,'request\x20sent');logger[_0x529a('0xe')](_0x529a('0xf'),_0x6861f0,_0x529a('0x10'),JSON[_0x529a('0x11')](_0x5558a3));if(_0x5558a3[_0x529a('0x12')]){if(_0x5558a3[_0x529a('0x12')][_0x529a('0x13')]===0x1f4){logger[_0x529a('0x12')](_0x529a('0x14'),_0x6861f0,_0x5558a3[_0x529a('0x12')][_0x529a('0x15')]);return _0x465d78(_0x5558a3[_0x529a('0x12')][_0x529a('0x15')]);}logger[_0x529a('0x12')](_0x529a('0x14'),_0x6861f0,_0x5558a3[_0x529a('0x12')]['message']);return _0x4b8ad9(_0x5558a3[_0x529a('0x12')][_0x529a('0x15')]);}else{logger[_0x529a('0xd')]('MailServerIn,\x20%s,\x20%s',_0x6861f0,_0x529a('0x10'));_0x4b8ad9(_0x5558a3[_0x529a('0x16')][_0x529a('0x15')]);}})[_0x529a('0x17')](function(_0x36e235){logger[_0x529a('0x12')]('MailServerIn,\x20%s,\x20%s',_0x6861f0,_0x36e235);_0x465d78(_0x36e235);});});}exports[_0x529a('0x18')]=function(_0x34fa5c){var _0x2b89c2=this;return new Promise(function(_0x543b56,_0x2168d5){return db[_0x529a('0x19')][_0x529a('0x1a')]({'raw':_0x34fa5c[_0x529a('0x1b')]?_0x34fa5c['options'][_0x529a('0x1c')]===undefined?!![]:![]:!![],'where':_0x34fa5c[_0x529a('0x1b')]?_0x34fa5c[_0x529a('0x1b')][_0x529a('0x1d')]||null:null,'attributes':_0x34fa5c[_0x529a('0x1b')]?_0x34fa5c[_0x529a('0x1b')][_0x529a('0x1e')]||null:null,'limit':_0x34fa5c[_0x529a('0x1b')]?_0x34fa5c[_0x529a('0x1b')]['limit']||null:null,'include':_0x34fa5c[_0x529a('0x1b')]?_0x34fa5c[_0x529a('0x1b')][_0x529a('0x1f')]?_['map'](_0x34fa5c['options'][_0x529a('0x1f')],function(_0x18f9b4){return{'model':db[_0x18f9b4[_0x529a('0x20')]],'as':_0x18f9b4['as'],'attributes':_0x18f9b4[_0x529a('0x1e')],'include':_0x18f9b4[_0x529a('0x1f')]?_[_0x529a('0x21')](_0x18f9b4[_0x529a('0x1f')],function(_0x40eac6){return{'model':db[_0x40eac6['model']],'as':_0x40eac6['as'],'attributes':_0x40eac6[_0x529a('0x1e')],'include':_0x40eac6[_0x529a('0x1f')]?_[_0x529a('0x21')](_0x40eac6[_0x529a('0x1f')],function(_0x3d91f5){return{'model':db[_0x3d91f5['model']],'as':_0x3d91f5['as'],'attributes':_0x3d91f5[_0x529a('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x529a('0xc')](function(_0x527ad6){logger[_0x529a('0xd')](_0x529a('0x18'),_0x34fa5c);logger[_0x529a('0xe')]('GetMailServerIn',_0x34fa5c,JSON['stringify'](_0x527ad6));_0x543b56(_0x527ad6);})[_0x529a('0x17')](function(_0x1e1727){logger[_0x529a('0x12')](_0x529a('0x18'),_0x1e1727[_0x529a('0x15')],_0x34fa5c);_0x2168d5(_0x2b89c2[_0x529a('0x12')](0x1f4,_0x1e1727[_0x529a('0x15')]));});});};