3c56a060c114278df4633718b47814c18d8084aa
[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 _0xe5b5=['then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','debug','MailServerIn,\x20%s,\x20%s,\x20%s','error','code','message','result','GetMailServerIn','MailServerIn','options','raw','limit','map','include','attributes','stringify','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request'];(function(_0x5c8988,_0x1b2e3f){var _0x220788=function(_0x3b0414){while(--_0x3b0414){_0x5c8988['push'](_0x5c8988['shift']());}};_0x220788(++_0x1b2e3f);}(_0xe5b5,0x73));var _0x5e5b=function(_0x2e6c19,_0x131233){_0x2e6c19=_0x2e6c19-0x0;var _0x52885d=_0xe5b5[_0x2e6c19];return _0x52885d;};'use strict';var _=require('lodash');var util=require(_0x5e5b('0x0'));var moment=require(_0x5e5b('0x1'));var BPromise=require(_0x5e5b('0x2'));var rs=require(_0x5e5b('0x3'));var fs=require('fs');var Redis=require(_0x5e5b('0x4'));var db=require(_0x5e5b('0x5'))['db'];var utils=require(_0x5e5b('0x6'));var logger=require(_0x5e5b('0x7'))(_0x5e5b('0x8'));var config=require(_0x5e5b('0x9'));var jayson=require(_0x5e5b('0xa'));var client=jayson['client'][_0x5e5b('0xb')]({'port':0x232a});function respondWithRpcPromise(_0x46660b,_0x365505,_0xfeecb4){return new BPromise(function(_0x26d2fa,_0x392941){return client[_0x5e5b('0xc')](_0x46660b,_0xfeecb4)[_0x5e5b('0xd')](function(_0x5d99be){logger[_0x5e5b('0xe')](_0x5e5b('0xf'),_0x365505,_0x5e5b('0x10'));logger[_0x5e5b('0x11')](_0x5e5b('0x12'),_0x365505,_0x5e5b('0x10'),JSON['stringify'](_0x5d99be));if(_0x5d99be['error']){if(_0x5d99be[_0x5e5b('0x13')][_0x5e5b('0x14')]===0x1f4){logger[_0x5e5b('0x13')](_0x5e5b('0xf'),_0x365505,_0x5d99be[_0x5e5b('0x13')][_0x5e5b('0x15')]);return _0x392941(_0x5d99be['error'][_0x5e5b('0x15')]);}logger[_0x5e5b('0x13')](_0x5e5b('0xf'),_0x365505,_0x5d99be[_0x5e5b('0x13')][_0x5e5b('0x15')]);return _0x26d2fa(_0x5d99be[_0x5e5b('0x13')][_0x5e5b('0x15')]);}else{logger[_0x5e5b('0xe')](_0x5e5b('0xf'),_0x365505,_0x5e5b('0x10'));_0x26d2fa(_0x5d99be[_0x5e5b('0x16')][_0x5e5b('0x15')]);}})['catch'](function(_0x271be0){logger[_0x5e5b('0x13')](_0x5e5b('0xf'),_0x365505,_0x271be0);_0x392941(_0x271be0);});});}exports[_0x5e5b('0x17')]=function(_0x498d68){var _0x2dcf5e=this;return new Promise(function(_0xe24365,_0x3afbf5){return db[_0x5e5b('0x18')]['findAll']({'raw':_0x498d68['options']?_0x498d68[_0x5e5b('0x19')][_0x5e5b('0x1a')]===undefined?!![]:![]:!![],'where':_0x498d68[_0x5e5b('0x19')]?_0x498d68[_0x5e5b('0x19')]['where']||null:null,'attributes':_0x498d68[_0x5e5b('0x19')]?_0x498d68[_0x5e5b('0x19')]['attributes']||null:null,'limit':_0x498d68[_0x5e5b('0x19')]?_0x498d68['options'][_0x5e5b('0x1b')]||null:null,'include':_0x498d68[_0x5e5b('0x19')]?_0x498d68[_0x5e5b('0x19')]['include']?_[_0x5e5b('0x1c')](_0x498d68['options'][_0x5e5b('0x1d')],function(_0x18deec){return{'model':db[_0x18deec['model']],'as':_0x18deec['as'],'attributes':_0x18deec['attributes'],'include':_0x18deec['include']?_['map'](_0x18deec['include'],function(_0x32d94c){return{'model':db[_0x32d94c['model']],'as':_0x32d94c['as'],'attributes':_0x32d94c['attributes'],'include':_0x32d94c['include']?_['map'](_0x32d94c[_0x5e5b('0x1d')],function(_0x461148){return{'model':db[_0x461148['model']],'as':_0x461148['as'],'attributes':_0x461148[_0x5e5b('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x5e5b('0xd')](function(_0x5b8b6f){logger['info'](_0x5e5b('0x17'),_0x498d68);logger[_0x5e5b('0x11')]('GetMailServerIn',_0x498d68,JSON[_0x5e5b('0x1f')](_0x5b8b6f));_0xe24365(_0x5b8b6f);})['catch'](function(_0x10428f){logger[_0x5e5b('0x13')](_0x5e5b('0x17'),_0x10428f[_0x5e5b('0x15')],_0x498d68);_0x3afbf5(_0x2dcf5e[_0x5e5b('0x13')](0x1f4,_0x10428f[_0x5e5b('0x15')]));});});};