c27e30790c64f890c0a315c170c73c3b90a4bf2c
[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 _0x9c53=['map','model','include','stringify','moment','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','then','MailServerIn,\x20%s,\x20%s','debug','MailServerIn,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','info','result','catch','GetMailServerIn','MailServerIn','findAll','options','attributes','limit'];(function(_0x495387,_0x42ee5c){var _0x35e169=function(_0x22156c){while(--_0x22156c){_0x495387['push'](_0x495387['shift']());}};_0x35e169(++_0x42ee5c);}(_0x9c53,0x1f4));var _0x39c5=function(_0x53d700,_0x6f7291){_0x53d700=_0x53d700-0x0;var _0x95d0b0=_0x9c53[_0x53d700];return _0x95d0b0;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x39c5('0x0'));var BPromise=require('bluebird');var rs=require(_0x39c5('0x1'));var fs=require('fs');var Redis=require(_0x39c5('0x2'));var db=require(_0x39c5('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x39c5('0x4'))(_0x39c5('0x5'));var config=require(_0x39c5('0x6'));var jayson=require(_0x39c5('0x7'));var client=jayson[_0x39c5('0x8')][_0x39c5('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x45a23f,_0x95728e,_0x24205b){return new BPromise(function(_0x51b1fa,_0x474158){return client['request'](_0x45a23f,_0x24205b)[_0x39c5('0xa')](function(_0x126323){logger['info'](_0x39c5('0xb'),_0x95728e,'request\x20sent');logger[_0x39c5('0xc')](_0x39c5('0xd'),_0x95728e,_0x39c5('0xe'),JSON['stringify'](_0x126323));if(_0x126323[_0x39c5('0xf')]){if(_0x126323[_0x39c5('0xf')][_0x39c5('0x10')]===0x1f4){logger[_0x39c5('0xf')]('MailServerIn,\x20%s,\x20%s',_0x95728e,_0x126323[_0x39c5('0xf')][_0x39c5('0x11')]);return _0x474158(_0x126323[_0x39c5('0xf')][_0x39c5('0x11')]);}logger[_0x39c5('0xf')](_0x39c5('0xb'),_0x95728e,_0x126323[_0x39c5('0xf')]['message']);return _0x51b1fa(_0x126323[_0x39c5('0xf')][_0x39c5('0x11')]);}else{logger[_0x39c5('0x12')](_0x39c5('0xb'),_0x95728e,_0x39c5('0xe'));_0x51b1fa(_0x126323[_0x39c5('0x13')][_0x39c5('0x11')]);}})[_0x39c5('0x14')](function(_0x5b73e5){logger['error']('MailServerIn,\x20%s,\x20%s',_0x95728e,_0x5b73e5);_0x474158(_0x5b73e5);});});}exports[_0x39c5('0x15')]=function(_0xc360c4){var _0x5c8950=this;return new Promise(function(_0x533a54,_0x336972){return db[_0x39c5('0x16')][_0x39c5('0x17')]({'raw':_0xc360c4['options']?_0xc360c4[_0x39c5('0x18')]['raw']===undefined?!![]:![]:!![],'where':_0xc360c4[_0x39c5('0x18')]?_0xc360c4['options']['where']||null:null,'attributes':_0xc360c4[_0x39c5('0x18')]?_0xc360c4[_0x39c5('0x18')][_0x39c5('0x19')]||null:null,'limit':_0xc360c4[_0x39c5('0x18')]?_0xc360c4[_0x39c5('0x18')][_0x39c5('0x1a')]||null:null,'include':_0xc360c4[_0x39c5('0x18')]?_0xc360c4[_0x39c5('0x18')]['include']?_[_0x39c5('0x1b')](_0xc360c4[_0x39c5('0x18')]['include'],function(_0x276b56){return{'model':db[_0x276b56[_0x39c5('0x1c')]],'as':_0x276b56['as'],'attributes':_0x276b56[_0x39c5('0x19')],'include':_0x276b56[_0x39c5('0x1d')]?_[_0x39c5('0x1b')](_0x276b56[_0x39c5('0x1d')],function(_0x5d25c9){return{'model':db[_0x5d25c9[_0x39c5('0x1c')]],'as':_0x5d25c9['as'],'attributes':_0x5d25c9['attributes'],'include':_0x5d25c9[_0x39c5('0x1d')]?_['map'](_0x5d25c9['include'],function(_0x493100){return{'model':db[_0x493100[_0x39c5('0x1c')]],'as':_0x493100['as'],'attributes':_0x493100[_0x39c5('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2156f1){logger[_0x39c5('0x12')](_0x39c5('0x15'),_0xc360c4);logger[_0x39c5('0xc')](_0x39c5('0x15'),_0xc360c4,JSON[_0x39c5('0x1e')](_0x2156f1));_0x533a54(_0x2156f1);})[_0x39c5('0x14')](function(_0x4b0b38){logger['error'](_0x39c5('0x15'),_0x4b0b38['message'],_0xc360c4);_0x336972(_0x5c8950[_0x39c5('0xf')](0x1f4,_0x4b0b38[_0x39c5('0x11')]));});});};