62e8de3292e56d4c32b7fc2b423d5e622a474d46
[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 _0x95ce=['client','request','then','MailServerIn,\x20%s,\x20%s','MailServerIn,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','GetMailServerIn','MailServerIn','findAll','options','raw','where','attributes','limit','include','map','model','info','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise'];(function(_0x227267,_0x548e57){var _0x47e978=function(_0x4ddc41){while(--_0x4ddc41){_0x227267['push'](_0x227267['shift']());}};_0x47e978(++_0x548e57);}(_0x95ce,0x1e6));var _0xe95c=function(_0x3ea7a5,_0x59e8e8){_0x3ea7a5=_0x3ea7a5-0x0;var _0x165fe5=_0x95ce[_0x3ea7a5];return _0x165fe5;};'use strict';var _=require('lodash');var util=require(_0xe95c('0x0'));var moment=require(_0xe95c('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xe95c('0x2'));var db=require(_0xe95c('0x3'))['db'];var utils=require(_0xe95c('0x4'));var logger=require(_0xe95c('0x5'))(_0xe95c('0x6'));var config=require(_0xe95c('0x7'));var jayson=require(_0xe95c('0x8'));var client=jayson[_0xe95c('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2be11f,_0x467d6f,_0x445413){return new BPromise(function(_0x4f923c,_0x54a1e9){return client[_0xe95c('0xa')](_0x2be11f,_0x445413)[_0xe95c('0xb')](function(_0x16e3ff){logger['info'](_0xe95c('0xc'),_0x467d6f,'request\x20sent');logger['debug'](_0xe95c('0xd'),_0x467d6f,_0xe95c('0xe'),JSON[_0xe95c('0xf')](_0x16e3ff));if(_0x16e3ff['error']){if(_0x16e3ff[_0xe95c('0x10')][_0xe95c('0x11')]===0x1f4){logger['error'](_0xe95c('0xc'),_0x467d6f,_0x16e3ff[_0xe95c('0x10')][_0xe95c('0x12')]);return _0x54a1e9(_0x16e3ff[_0xe95c('0x10')][_0xe95c('0x12')]);}logger[_0xe95c('0x10')]('MailServerIn,\x20%s,\x20%s',_0x467d6f,_0x16e3ff[_0xe95c('0x10')][_0xe95c('0x12')]);return _0x4f923c(_0x16e3ff[_0xe95c('0x10')]['message']);}else{logger['info'](_0xe95c('0xc'),_0x467d6f,_0xe95c('0xe'));_0x4f923c(_0x16e3ff[_0xe95c('0x13')][_0xe95c('0x12')]);}})[_0xe95c('0x14')](function(_0x30662c){logger[_0xe95c('0x10')](_0xe95c('0xc'),_0x467d6f,_0x30662c);_0x54a1e9(_0x30662c);});});}exports[_0xe95c('0x15')]=function(_0x17b96d){var _0x2562aa=this;return new Promise(function(_0x2a5fd8,_0x4dc52c){return db[_0xe95c('0x16')][_0xe95c('0x17')]({'raw':_0x17b96d[_0xe95c('0x18')]?_0x17b96d['options'][_0xe95c('0x19')]===undefined?!![]:![]:!![],'where':_0x17b96d['options']?_0x17b96d[_0xe95c('0x18')][_0xe95c('0x1a')]||null:null,'attributes':_0x17b96d[_0xe95c('0x18')]?_0x17b96d[_0xe95c('0x18')][_0xe95c('0x1b')]||null:null,'limit':_0x17b96d[_0xe95c('0x18')]?_0x17b96d[_0xe95c('0x18')][_0xe95c('0x1c')]||null:null,'include':_0x17b96d[_0xe95c('0x18')]?_0x17b96d[_0xe95c('0x18')][_0xe95c('0x1d')]?_[_0xe95c('0x1e')](_0x17b96d['options'][_0xe95c('0x1d')],function(_0x1f9c5a){return{'model':db[_0x1f9c5a[_0xe95c('0x1f')]],'as':_0x1f9c5a['as'],'attributes':_0x1f9c5a[_0xe95c('0x1b')],'include':_0x1f9c5a[_0xe95c('0x1d')]?_[_0xe95c('0x1e')](_0x1f9c5a['include'],function(_0x2dc218){return{'model':db[_0x2dc218[_0xe95c('0x1f')]],'as':_0x2dc218['as'],'attributes':_0x2dc218['attributes'],'include':_0x2dc218[_0xe95c('0x1d')]?_['map'](_0x2dc218[_0xe95c('0x1d')],function(_0x5d4c50){return{'model':db[_0x5d4c50['model']],'as':_0x5d4c50['as'],'attributes':_0x5d4c50[_0xe95c('0x1b')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xa1e841){logger[_0xe95c('0x20')](_0xe95c('0x15'),_0x17b96d);logger['debug'](_0xe95c('0x15'),_0x17b96d,JSON[_0xe95c('0xf')](_0xa1e841));_0x2a5fd8(_0xa1e841);})[_0xe95c('0x14')](function(_0x298ff7){logger[_0xe95c('0x10')](_0xe95c('0x15'),_0x298ff7[_0xe95c('0x12')],_0x17b96d);_0x4dc52c(_0x2562aa['error'](0x1f4,_0x298ff7[_0xe95c('0x12')]));});});};