689ba0c54a0e5517619aa1025016a1189a4d2639
[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 _0x38e7=['ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','error','message','catch','GetMailServerIn','MailServerIn','findAll','options','where','attributes','limit','include','map','model','debug','stringify','lodash','util','moment','bluebird','randomstring'];(function(_0x528650,_0x55e7c2){var _0x344d73=function(_0x25e183){while(--_0x25e183){_0x528650['push'](_0x528650['shift']());}};_0x344d73(++_0x55e7c2);}(_0x38e7,0x1eb));var _0x738e=function(_0x562faf,_0x102bcc){_0x562faf=_0x562faf-0x0;var _0x22c1f6=_0x38e7[_0x562faf];return _0x22c1f6;};'use strict';var _=require(_0x738e('0x0'));var util=require(_0x738e('0x1'));var moment=require(_0x738e('0x2'));var BPromise=require(_0x738e('0x3'));var rs=require(_0x738e('0x4'));var fs=require('fs');var Redis=require(_0x738e('0x5'));var db=require(_0x738e('0x6'))['db'];var utils=require(_0x738e('0x7'));var logger=require(_0x738e('0x8'))(_0x738e('0x9'));var config=require(_0x738e('0xa'));var jayson=require('jayson/promise');var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x282b59,_0x35db07,_0x26c0a7){return new BPromise(function(_0x287d50,_0x160926){return client[_0x738e('0xb')](_0x282b59,_0x26c0a7)[_0x738e('0xc')](function(_0x36f796){logger[_0x738e('0xd')](_0x738e('0xe'),_0x35db07,_0x738e('0xf'));logger['debug']('MailServerIn,\x20%s,\x20%s,\x20%s',_0x35db07,_0x738e('0xf'),JSON['stringify'](_0x36f796));if(_0x36f796[_0x738e('0x10')]){if(_0x36f796[_0x738e('0x10')]['code']===0x1f4){logger[_0x738e('0x10')]('MailServerIn,\x20%s,\x20%s',_0x35db07,_0x36f796[_0x738e('0x10')][_0x738e('0x11')]);return _0x160926(_0x36f796[_0x738e('0x10')][_0x738e('0x11')]);}logger[_0x738e('0x10')](_0x738e('0xe'),_0x35db07,_0x36f796['error'][_0x738e('0x11')]);return _0x287d50(_0x36f796[_0x738e('0x10')][_0x738e('0x11')]);}else{logger[_0x738e('0xd')](_0x738e('0xe'),_0x35db07,_0x738e('0xf'));_0x287d50(_0x36f796['result'][_0x738e('0x11')]);}})[_0x738e('0x12')](function(_0x4d0651){logger[_0x738e('0x10')]('MailServerIn,\x20%s,\x20%s',_0x35db07,_0x4d0651);_0x160926(_0x4d0651);});});}exports[_0x738e('0x13')]=function(_0x3add89){var _0x4618a4=this;return new Promise(function(_0x130bc5,_0x2b9eab){return db[_0x738e('0x14')][_0x738e('0x15')]({'raw':_0x3add89['options']?_0x3add89[_0x738e('0x16')]['raw']===undefined?!![]:![]:!![],'where':_0x3add89[_0x738e('0x16')]?_0x3add89[_0x738e('0x16')][_0x738e('0x17')]||null:null,'attributes':_0x3add89['options']?_0x3add89[_0x738e('0x16')][_0x738e('0x18')]||null:null,'limit':_0x3add89[_0x738e('0x16')]?_0x3add89[_0x738e('0x16')][_0x738e('0x19')]||null:null,'include':_0x3add89[_0x738e('0x16')]?_0x3add89[_0x738e('0x16')][_0x738e('0x1a')]?_[_0x738e('0x1b')](_0x3add89['options'][_0x738e('0x1a')],function(_0x609ed6){return{'model':db[_0x609ed6[_0x738e('0x1c')]],'as':_0x609ed6['as'],'attributes':_0x609ed6['attributes'],'include':_0x609ed6[_0x738e('0x1a')]?_[_0x738e('0x1b')](_0x609ed6['include'],function(_0x275850){return{'model':db[_0x275850['model']],'as':_0x275850['as'],'attributes':_0x275850['attributes'],'include':_0x275850[_0x738e('0x1a')]?_[_0x738e('0x1b')](_0x275850[_0x738e('0x1a')],function(_0x54e0bf){return{'model':db[_0x54e0bf['model']],'as':_0x54e0bf['as'],'attributes':_0x54e0bf[_0x738e('0x18')]};}):[]};}):[]};}):[]:[]})[_0x738e('0xc')](function(_0x3b4a25){logger[_0x738e('0xd')](_0x738e('0x13'),_0x3add89);logger[_0x738e('0x1d')](_0x738e('0x13'),_0x3add89,JSON[_0x738e('0x1e')](_0x3b4a25));_0x130bc5(_0x3b4a25);})[_0x738e('0x12')](function(_0x129fcb){logger[_0x738e('0x10')](_0x738e('0x13'),_0x129fcb[_0x738e('0x11')],_0x3add89);_0x2b9eab(_0x4618a4[_0x738e('0x10')](0x1f4,_0x129fcb[_0x738e('0x11')]));});});};