53045746f9cdf461bb0a822bd7e27dab5df73801
[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 _0x4f6f=['result','catch','GetMailServerIn','MailServerIn','findAll','options','raw','where','attributes','limit','include','map','model','lodash','util','moment','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','client','http','request','then','info','MailServerIn,\x20%s,\x20%s','request\x20sent','MailServerIn,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x43a710,_0x482f5b){var _0x47e675=function(_0x5b49d0){while(--_0x5b49d0){_0x43a710['push'](_0x43a710['shift']());}};_0x47e675(++_0x482f5b);}(_0x4f6f,0x157));var _0xf4f6=function(_0x17406e,_0x1049fd){_0x17406e=_0x17406e-0x0;var _0x2bfc5a=_0x4f6f[_0x17406e];return _0x2bfc5a;};'use strict';var _=require(_0xf4f6('0x0'));var util=require(_0xf4f6('0x1'));var moment=require(_0xf4f6('0x2'));var BPromise=require('bluebird');var rs=require(_0xf4f6('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf4f6('0x4'))['db'];var utils=require(_0xf4f6('0x5'));var logger=require('../../config/logger')(_0xf4f6('0x6'));var config=require(_0xf4f6('0x7'));var jayson=require('jayson/promise');var client=jayson[_0xf4f6('0x8')][_0xf4f6('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2dc7b9,_0x4fa106,_0x106455){return new BPromise(function(_0x592fa6,_0x483c82){return client[_0xf4f6('0xa')](_0x2dc7b9,_0x106455)[_0xf4f6('0xb')](function(_0x34bc5d){logger[_0xf4f6('0xc')](_0xf4f6('0xd'),_0x4fa106,_0xf4f6('0xe'));logger['debug'](_0xf4f6('0xf'),_0x4fa106,_0xf4f6('0xe'),JSON[_0xf4f6('0x10')](_0x34bc5d));if(_0x34bc5d[_0xf4f6('0x11')]){if(_0x34bc5d[_0xf4f6('0x11')][_0xf4f6('0x12')]===0x1f4){logger['error'](_0xf4f6('0xd'),_0x4fa106,_0x34bc5d[_0xf4f6('0x11')]['message']);return _0x483c82(_0x34bc5d['error'][_0xf4f6('0x13')]);}logger[_0xf4f6('0x11')](_0xf4f6('0xd'),_0x4fa106,_0x34bc5d['error'][_0xf4f6('0x13')]);return _0x592fa6(_0x34bc5d[_0xf4f6('0x11')][_0xf4f6('0x13')]);}else{logger['info'](_0xf4f6('0xd'),_0x4fa106,'request\x20sent');_0x592fa6(_0x34bc5d[_0xf4f6('0x14')][_0xf4f6('0x13')]);}})[_0xf4f6('0x15')](function(_0x522af3){logger[_0xf4f6('0x11')](_0xf4f6('0xd'),_0x4fa106,_0x522af3);_0x483c82(_0x522af3);});});}exports[_0xf4f6('0x16')]=function(_0x4e1d2a){var _0x3d5019=this;return new Promise(function(_0x4cb047,_0x109095){return db[_0xf4f6('0x17')][_0xf4f6('0x18')]({'raw':_0x4e1d2a['options']?_0x4e1d2a[_0xf4f6('0x19')][_0xf4f6('0x1a')]===undefined?!![]:![]:!![],'where':_0x4e1d2a[_0xf4f6('0x19')]?_0x4e1d2a[_0xf4f6('0x19')][_0xf4f6('0x1b')]||null:null,'attributes':_0x4e1d2a[_0xf4f6('0x19')]?_0x4e1d2a[_0xf4f6('0x19')][_0xf4f6('0x1c')]||null:null,'limit':_0x4e1d2a[_0xf4f6('0x19')]?_0x4e1d2a[_0xf4f6('0x19')][_0xf4f6('0x1d')]||null:null,'include':_0x4e1d2a['options']?_0x4e1d2a[_0xf4f6('0x19')][_0xf4f6('0x1e')]?_[_0xf4f6('0x1f')](_0x4e1d2a['options'][_0xf4f6('0x1e')],function(_0x45b5fb){return{'model':db[_0x45b5fb['model']],'as':_0x45b5fb['as'],'attributes':_0x45b5fb[_0xf4f6('0x1c')],'include':_0x45b5fb[_0xf4f6('0x1e')]?_[_0xf4f6('0x1f')](_0x45b5fb['include'],function(_0x32af7b){return{'model':db[_0x32af7b[_0xf4f6('0x20')]],'as':_0x32af7b['as'],'attributes':_0x32af7b[_0xf4f6('0x1c')],'include':_0x32af7b[_0xf4f6('0x1e')]?_['map'](_0x32af7b[_0xf4f6('0x1e')],function(_0x330ec1){return{'model':db[_0x330ec1[_0xf4f6('0x20')]],'as':_0x330ec1['as'],'attributes':_0x330ec1[_0xf4f6('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xf4f6('0xb')](function(_0x2edc23){logger[_0xf4f6('0xc')](_0xf4f6('0x16'),_0x4e1d2a);logger['debug'](_0xf4f6('0x16'),_0x4e1d2a,JSON[_0xf4f6('0x10')](_0x2edc23));_0x4cb047(_0x2edc23);})[_0xf4f6('0x15')](function(_0x59490b){logger[_0xf4f6('0x11')](_0xf4f6('0x16'),_0x59490b[_0xf4f6('0x13')],_0x4e1d2a);_0x109095(_0x3d5019[_0xf4f6('0x11')](0x1f4,_0x59490b[_0xf4f6('0x13')]));});});};