532f8fc581465886a127132f79ecaa9a130ddd77
[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 _0x5707=['attributes','include','map','model','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','debug','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetMailServerIn','MailServerIn','options','raw','where'];(function(_0x23c02b,_0x411b4d){var _0x25efc5=function(_0x50e9e4){while(--_0x50e9e4){_0x23c02b['push'](_0x23c02b['shift']());}};_0x25efc5(++_0x411b4d);}(_0x5707,0x12d));var _0x7570=function(_0x1bf8cc,_0x118778){_0x1bf8cc=_0x1bf8cc-0x0;var _0x322d20=_0x5707[_0x1bf8cc];return _0x322d20;};'use strict';var _=require(_0x7570('0x0'));var util=require(_0x7570('0x1'));var moment=require('moment');var BPromise=require(_0x7570('0x2'));var rs=require(_0x7570('0x3'));var fs=require('fs');var Redis=require(_0x7570('0x4'));var db=require(_0x7570('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x7570('0x6'))(_0x7570('0x7'));var config=require('../../config/environment');var jayson=require(_0x7570('0x8'));var client=jayson[_0x7570('0x9')][_0x7570('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x4a7de3,_0x5cd76c,_0x5a3440){return new BPromise(function(_0x81027b,_0x2c9855){return client[_0x7570('0xb')](_0x4a7de3,_0x5a3440)[_0x7570('0xc')](function(_0x1f81d5){logger[_0x7570('0xd')](_0x7570('0xe'),_0x5cd76c,_0x7570('0xf'));logger[_0x7570('0x10')](_0x7570('0x11'),_0x5cd76c,'request\x20sent',JSON[_0x7570('0x12')](_0x1f81d5));if(_0x1f81d5[_0x7570('0x13')]){if(_0x1f81d5[_0x7570('0x13')][_0x7570('0x14')]===0x1f4){logger[_0x7570('0x13')]('MailServerIn,\x20%s,\x20%s',_0x5cd76c,_0x1f81d5[_0x7570('0x13')][_0x7570('0x15')]);return _0x2c9855(_0x1f81d5[_0x7570('0x13')][_0x7570('0x15')]);}logger['error'](_0x7570('0xe'),_0x5cd76c,_0x1f81d5[_0x7570('0x13')][_0x7570('0x15')]);return _0x81027b(_0x1f81d5[_0x7570('0x13')]['message']);}else{logger[_0x7570('0xd')](_0x7570('0xe'),_0x5cd76c,'request\x20sent');_0x81027b(_0x1f81d5[_0x7570('0x16')][_0x7570('0x15')]);}})[_0x7570('0x17')](function(_0x1c87da){logger[_0x7570('0x13')](_0x7570('0xe'),_0x5cd76c,_0x1c87da);_0x2c9855(_0x1c87da);});});}exports[_0x7570('0x18')]=function(_0x549379){var _0x277356=this;return new Promise(function(_0x465b7a,_0x1490a0){return db[_0x7570('0x19')]['findAll']({'raw':_0x549379[_0x7570('0x1a')]?_0x549379[_0x7570('0x1a')][_0x7570('0x1b')]===undefined?!![]:![]:!![],'where':_0x549379[_0x7570('0x1a')]?_0x549379['options'][_0x7570('0x1c')]||null:null,'attributes':_0x549379['options']?_0x549379[_0x7570('0x1a')][_0x7570('0x1d')]||null:null,'limit':_0x549379[_0x7570('0x1a')]?_0x549379[_0x7570('0x1a')]['limit']||null:null,'include':_0x549379[_0x7570('0x1a')]?_0x549379[_0x7570('0x1a')][_0x7570('0x1e')]?_[_0x7570('0x1f')](_0x549379[_0x7570('0x1a')]['include'],function(_0x292711){return{'model':db[_0x292711[_0x7570('0x20')]],'as':_0x292711['as'],'attributes':_0x292711[_0x7570('0x1d')],'include':_0x292711[_0x7570('0x1e')]?_[_0x7570('0x1f')](_0x292711[_0x7570('0x1e')],function(_0x190ef8){return{'model':db[_0x190ef8[_0x7570('0x20')]],'as':_0x190ef8['as'],'attributes':_0x190ef8['attributes'],'include':_0x190ef8[_0x7570('0x1e')]?_['map'](_0x190ef8[_0x7570('0x1e')],function(_0x8d59fb){return{'model':db[_0x8d59fb['model']],'as':_0x8d59fb['as'],'attributes':_0x8d59fb[_0x7570('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1a6ea0){logger['info']('GetMailServerIn',_0x549379);logger[_0x7570('0x10')](_0x7570('0x18'),_0x549379,JSON['stringify'](_0x1a6ea0));_0x465b7a(_0x1a6ea0);})[_0x7570('0x17')](function(_0x58a14b){logger['error']('GetMailServerIn',_0x58a14b[_0x7570('0x15')],_0x549379);_0x1490a0(_0x277356[_0x7570('0x13')](0x1f4,_0x58a14b[_0x7570('0x15')]));});});};