8d854f361e121023be545c4b72dc12213f97a24b
[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 _0xd57a=['result','catch','MailServerIn','findAll','options','raw','where','attributes','limit','include','map','model','GetMailServerIn','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x3987a1,_0x447793){var _0xe2596e=function(_0x546925){while(--_0x546925){_0x3987a1['push'](_0x3987a1['shift']());}};_0xe2596e(++_0x447793);}(_0xd57a,0xdf));var _0xad57=function(_0x25690d,_0x5594ad){_0x25690d=_0x25690d-0x0;var _0x1af49f=_0xd57a[_0x25690d];return _0x1af49f;};'use strict';var _=require(_0xad57('0x0'));var util=require(_0xad57('0x1'));var moment=require(_0xad57('0x2'));var BPromise=require('bluebird');var rs=require(_0xad57('0x3'));var fs=require('fs');var Redis=require(_0xad57('0x4'));var db=require(_0xad57('0x5'))['db'];var utils=require(_0xad57('0x6'));var logger=require(_0xad57('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xad57('0x8'));var client=jayson[_0xad57('0x9')][_0xad57('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xed22cb,_0x41d0ff,_0x38354b){return new BPromise(function(_0x231c0d,_0x4f2f43){return client[_0xad57('0xb')](_0xed22cb,_0x38354b)[_0xad57('0xc')](function(_0x1a903b){logger[_0xad57('0xd')](_0xad57('0xe'),_0x41d0ff,_0xad57('0xf'));logger[_0xad57('0x10')](_0xad57('0x11'),_0x41d0ff,'request\x20sent',JSON[_0xad57('0x12')](_0x1a903b));if(_0x1a903b[_0xad57('0x13')]){if(_0x1a903b[_0xad57('0x13')][_0xad57('0x14')]===0x1f4){logger[_0xad57('0x13')](_0xad57('0xe'),_0x41d0ff,_0x1a903b[_0xad57('0x13')][_0xad57('0x15')]);return _0x4f2f43(_0x1a903b[_0xad57('0x13')][_0xad57('0x15')]);}logger[_0xad57('0x13')](_0xad57('0xe'),_0x41d0ff,_0x1a903b['error'][_0xad57('0x15')]);return _0x231c0d(_0x1a903b[_0xad57('0x13')][_0xad57('0x15')]);}else{logger['info']('MailServerIn,\x20%s,\x20%s',_0x41d0ff,_0xad57('0xf'));_0x231c0d(_0x1a903b[_0xad57('0x16')][_0xad57('0x15')]);}})[_0xad57('0x17')](function(_0x586447){logger[_0xad57('0x13')](_0xad57('0xe'),_0x41d0ff,_0x586447);_0x4f2f43(_0x586447);});});}exports['GetMailServerIn']=function(_0x91512d){var _0x1828d2=this;return new Promise(function(_0x1e456b,_0x173aaa){return db[_0xad57('0x18')][_0xad57('0x19')]({'raw':_0x91512d[_0xad57('0x1a')]?_0x91512d[_0xad57('0x1a')][_0xad57('0x1b')]===undefined?!![]:![]:!![],'where':_0x91512d[_0xad57('0x1a')]?_0x91512d[_0xad57('0x1a')][_0xad57('0x1c')]||null:null,'attributes':_0x91512d[_0xad57('0x1a')]?_0x91512d[_0xad57('0x1a')][_0xad57('0x1d')]||null:null,'limit':_0x91512d[_0xad57('0x1a')]?_0x91512d['options'][_0xad57('0x1e')]||null:null,'include':_0x91512d[_0xad57('0x1a')]?_0x91512d[_0xad57('0x1a')][_0xad57('0x1f')]?_[_0xad57('0x20')](_0x91512d[_0xad57('0x1a')][_0xad57('0x1f')],function(_0xeeb037){return{'model':db[_0xeeb037[_0xad57('0x21')]],'as':_0xeeb037['as'],'attributes':_0xeeb037['attributes'],'include':_0xeeb037[_0xad57('0x1f')]?_[_0xad57('0x20')](_0xeeb037['include'],function(_0x466646){return{'model':db[_0x466646['model']],'as':_0x466646['as'],'attributes':_0x466646['attributes'],'include':_0x466646[_0xad57('0x1f')]?_[_0xad57('0x20')](_0x466646[_0xad57('0x1f')],function(_0x203db3){return{'model':db[_0x203db3[_0xad57('0x21')]],'as':_0x203db3['as'],'attributes':_0x203db3['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x3d0a53){logger[_0xad57('0xd')](_0xad57('0x22'),_0x91512d);logger['debug'](_0xad57('0x22'),_0x91512d,JSON[_0xad57('0x12')](_0x3d0a53));_0x1e456b(_0x3d0a53);})['catch'](function(_0x2e0ec1){logger[_0xad57('0x13')](_0xad57('0x22'),_0x2e0ec1[_0xad57('0x15')],_0x91512d);_0x173aaa(_0x1828d2[_0xad57('0x13')](0x1f4,_0x2e0ec1[_0xad57('0x15')]));});});};