3ae9ba4857348f2b617d37f0501c509aea11168b
[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 _0x3bb3=['debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','MailServerIn','findAll','options','raw','attributes','limit','include','model','map','GetMailServerIn','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent'];(function(_0x5d869e,_0x1731bd){var _0x13a90b=function(_0x21719e){while(--_0x21719e){_0x5d869e['push'](_0x5d869e['shift']());}};_0x13a90b(++_0x1731bd);}(_0x3bb3,0x9e));var _0x33bb=function(_0x465a0c,_0x19d4d5){_0x465a0c=_0x465a0c-0x0;var _0x1e202e=_0x3bb3[_0x465a0c];return _0x1e202e;};'use strict';var _=require(_0x33bb('0x0'));var util=require(_0x33bb('0x1'));var moment=require(_0x33bb('0x2'));var BPromise=require(_0x33bb('0x3'));var rs=require(_0x33bb('0x4'));var fs=require('fs');var Redis=require(_0x33bb('0x5'));var db=require(_0x33bb('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x33bb('0x7'))(_0x33bb('0x8'));var config=require(_0x33bb('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x33bb('0xa')][_0x33bb('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x14eec5,_0x25e1ec,_0x564fc3){return new BPromise(function(_0xe05c99,_0x5f22ab){return client[_0x33bb('0xc')](_0x14eec5,_0x564fc3)[_0x33bb('0xd')](function(_0x3f4994){logger[_0x33bb('0xe')](_0x33bb('0xf'),_0x25e1ec,_0x33bb('0x10'));logger[_0x33bb('0x11')](_0x33bb('0x12'),_0x25e1ec,_0x33bb('0x10'),JSON[_0x33bb('0x13')](_0x3f4994));if(_0x3f4994[_0x33bb('0x14')]){if(_0x3f4994[_0x33bb('0x14')][_0x33bb('0x15')]===0x1f4){logger[_0x33bb('0x14')](_0x33bb('0xf'),_0x25e1ec,_0x3f4994[_0x33bb('0x14')][_0x33bb('0x16')]);return _0x5f22ab(_0x3f4994[_0x33bb('0x14')][_0x33bb('0x16')]);}logger[_0x33bb('0x14')](_0x33bb('0xf'),_0x25e1ec,_0x3f4994['error'][_0x33bb('0x16')]);return _0xe05c99(_0x3f4994['error']['message']);}else{logger[_0x33bb('0xe')](_0x33bb('0xf'),_0x25e1ec,'request\x20sent');_0xe05c99(_0x3f4994[_0x33bb('0x17')][_0x33bb('0x16')]);}})[_0x33bb('0x18')](function(_0x97ced){logger[_0x33bb('0x14')]('MailServerIn,\x20%s,\x20%s',_0x25e1ec,_0x97ced);_0x5f22ab(_0x97ced);});});}exports['GetMailServerIn']=function(_0x5163b5){var _0x317bc8=this;return new Promise(function(_0x2dd7e1,_0x5cf992){return db[_0x33bb('0x19')][_0x33bb('0x1a')]({'raw':_0x5163b5['options']?_0x5163b5[_0x33bb('0x1b')][_0x33bb('0x1c')]===undefined?!![]:![]:!![],'where':_0x5163b5[_0x33bb('0x1b')]?_0x5163b5[_0x33bb('0x1b')]['where']||null:null,'attributes':_0x5163b5[_0x33bb('0x1b')]?_0x5163b5[_0x33bb('0x1b')][_0x33bb('0x1d')]||null:null,'limit':_0x5163b5[_0x33bb('0x1b')]?_0x5163b5[_0x33bb('0x1b')][_0x33bb('0x1e')]||null:null,'include':_0x5163b5['options']?_0x5163b5[_0x33bb('0x1b')][_0x33bb('0x1f')]?_['map'](_0x5163b5[_0x33bb('0x1b')][_0x33bb('0x1f')],function(_0x564a04){return{'model':db[_0x564a04[_0x33bb('0x20')]],'as':_0x564a04['as'],'attributes':_0x564a04[_0x33bb('0x1d')],'include':_0x564a04['include']?_[_0x33bb('0x21')](_0x564a04[_0x33bb('0x1f')],function(_0x3f3645){return{'model':db[_0x3f3645[_0x33bb('0x20')]],'as':_0x3f3645['as'],'attributes':_0x3f3645[_0x33bb('0x1d')],'include':_0x3f3645[_0x33bb('0x1f')]?_[_0x33bb('0x21')](_0x3f3645[_0x33bb('0x1f')],function(_0x81af64){return{'model':db[_0x81af64['model']],'as':_0x81af64['as'],'attributes':_0x81af64[_0x33bb('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3c33a0){logger['info'](_0x33bb('0x22'),_0x5163b5);logger['debug'](_0x33bb('0x22'),_0x5163b5,JSON['stringify'](_0x3c33a0));_0x2dd7e1(_0x3c33a0);})['catch'](function(_0xa9c14){logger[_0x33bb('0x14')](_0x33bb('0x22'),_0xa9c14['message'],_0x5163b5);_0x5cf992(_0x317bc8['error'](0x1f4,_0xa9c14['message']));});});};