515094e0bcb527187bb5b5dea46900dbd6531b24
[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 _0xf7b2=['error','code','MailServerIn,\x20%s,\x20%s','message','request\x20sent','result','GetMailServerIn','options','attributes','limit','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','info','debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x2235bf,_0x3a06a7){var _0x4c3a64=function(_0x3b3bb6){while(--_0x3b3bb6){_0x2235bf['push'](_0x2235bf['shift']());}};_0x4c3a64(++_0x3a06a7);}(_0xf7b2,0x67));var _0x2f7b=function(_0x2b56c3,_0x2efc6d){_0x2b56c3=_0x2b56c3-0x0;var _0x2b77ce=_0xf7b2[_0x2b56c3];return _0x2b77ce;};'use strict';var _=require(_0x2f7b('0x0'));var util=require(_0x2f7b('0x1'));var moment=require(_0x2f7b('0x2'));var BPromise=require(_0x2f7b('0x3'));var rs=require(_0x2f7b('0x4'));var fs=require('fs');var Redis=require(_0x2f7b('0x5'));var db=require(_0x2f7b('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0x2f7b('0x7'))('rpc');var config=require(_0x2f7b('0x8'));var jayson=require(_0x2f7b('0x9'));var client=jayson[_0x2f7b('0xa')][_0x2f7b('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x5066fb,_0x28b106,_0x82151f){return new BPromise(function(_0x428e28,_0x5ac686){return client[_0x2f7b('0xc')](_0x5066fb,_0x82151f)['then'](function(_0x54222f){logger[_0x2f7b('0xd')]('MailServerIn,\x20%s,\x20%s',_0x28b106,'request\x20sent');logger[_0x2f7b('0xe')](_0x2f7b('0xf'),_0x28b106,'request\x20sent',JSON[_0x2f7b('0x10')](_0x54222f));if(_0x54222f[_0x2f7b('0x11')]){if(_0x54222f['error'][_0x2f7b('0x12')]===0x1f4){logger['error'](_0x2f7b('0x13'),_0x28b106,_0x54222f[_0x2f7b('0x11')][_0x2f7b('0x14')]);return _0x5ac686(_0x54222f['error'][_0x2f7b('0x14')]);}logger[_0x2f7b('0x11')](_0x2f7b('0x13'),_0x28b106,_0x54222f[_0x2f7b('0x11')][_0x2f7b('0x14')]);return _0x428e28(_0x54222f[_0x2f7b('0x11')]['message']);}else{logger[_0x2f7b('0xd')](_0x2f7b('0x13'),_0x28b106,_0x2f7b('0x15'));_0x428e28(_0x54222f[_0x2f7b('0x16')][_0x2f7b('0x14')]);}})['catch'](function(_0x59d6a4){logger[_0x2f7b('0x11')](_0x2f7b('0x13'),_0x28b106,_0x59d6a4);_0x5ac686(_0x59d6a4);});});}exports[_0x2f7b('0x17')]=function(_0x2197c3){var _0x342245=this;return new Promise(function(_0x4c0167,_0x4cc3dc){return db['MailServerIn']['findAll']({'raw':_0x2197c3[_0x2f7b('0x18')]?_0x2197c3[_0x2f7b('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0x2197c3[_0x2f7b('0x18')]?_0x2197c3[_0x2f7b('0x18')]['where']||null:null,'attributes':_0x2197c3[_0x2f7b('0x18')]?_0x2197c3['options'][_0x2f7b('0x19')]||null:null,'limit':_0x2197c3[_0x2f7b('0x18')]?_0x2197c3[_0x2f7b('0x18')][_0x2f7b('0x1a')]||null:null,'include':_0x2197c3['options']?_0x2197c3[_0x2f7b('0x18')][_0x2f7b('0x1b')]?_[_0x2f7b('0x1c')](_0x2197c3[_0x2f7b('0x18')][_0x2f7b('0x1b')],function(_0x49d3ab){return{'model':db[_0x49d3ab[_0x2f7b('0x1d')]],'as':_0x49d3ab['as'],'attributes':_0x49d3ab[_0x2f7b('0x19')],'include':_0x49d3ab[_0x2f7b('0x1b')]?_[_0x2f7b('0x1c')](_0x49d3ab[_0x2f7b('0x1b')],function(_0x2e8090){return{'model':db[_0x2e8090['model']],'as':_0x2e8090['as'],'attributes':_0x2e8090[_0x2f7b('0x19')],'include':_0x2e8090[_0x2f7b('0x1b')]?_[_0x2f7b('0x1c')](_0x2e8090[_0x2f7b('0x1b')],function(_0x41735b){return{'model':db[_0x41735b['model']],'as':_0x41735b['as'],'attributes':_0x41735b[_0x2f7b('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x309cf8){logger['info'](_0x2f7b('0x17'),_0x2197c3);logger['debug'](_0x2f7b('0x17'),_0x2197c3,JSON['stringify'](_0x309cf8));_0x4c0167(_0x309cf8);})['catch'](function(_0x4d1955){logger['error'](_0x2f7b('0x17'),_0x4d1955[_0x2f7b('0x14')],_0x2197c3);_0x4cc3dc(_0x342245[_0x2f7b('0x11')](0x1f4,_0x4d1955[_0x2f7b('0x14')]));});});};