6a2e99c952208d40680b9f8699e13f642f7cf3b7
[motion2.git] / server / api / mailApplication / mailApplication.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 _0x3f82=['limit','lodash','util','moment','bluebird','randomstring','../../config/utils','rpc','../../config/environment','client','http','request','then','MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','UpdateMailApplication','MailApplication','update','body','options','raw'];(function(_0x588011,_0x5e9d11){var _0x3b3773=function(_0x4cca54){while(--_0x4cca54){_0x588011['push'](_0x588011['shift']());}};_0x3b3773(++_0x5e9d11);}(_0x3f82,0x1c3));var _0x23f8=function(_0x30b015,_0xe071e3){_0x30b015=_0x30b015-0x0;var _0x34920a=_0x3f82[_0x30b015];return _0x34920a;};'use strict';var _=require(_0x23f8('0x0'));var util=require(_0x23f8('0x1'));var moment=require(_0x23f8('0x2'));var BPromise=require(_0x23f8('0x3'));var rs=require(_0x23f8('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x23f8('0x5'));var logger=require('../../config/logger')(_0x23f8('0x6'));var config=require(_0x23f8('0x7'));var jayson=require('jayson/promise');var client=jayson[_0x23f8('0x8')][_0x23f8('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x168190,_0x3a0bfb,_0x1c2538){return new BPromise(function(_0x19754a,_0x4ae35c){return client[_0x23f8('0xa')](_0x168190,_0x1c2538)[_0x23f8('0xb')](function(_0x1a7308){logger['info'](_0x23f8('0xc'),_0x3a0bfb,_0x23f8('0xd'));logger[_0x23f8('0xe')](_0x23f8('0xf'),_0x3a0bfb,_0x23f8('0xd'),JSON[_0x23f8('0x10')](_0x1a7308));if(_0x1a7308[_0x23f8('0x11')]){if(_0x1a7308[_0x23f8('0x11')][_0x23f8('0x12')]===0x1f4){logger[_0x23f8('0x11')](_0x23f8('0xc'),_0x3a0bfb,_0x1a7308['error'][_0x23f8('0x13')]);return _0x4ae35c(_0x1a7308[_0x23f8('0x11')][_0x23f8('0x13')]);}logger['error'](_0x23f8('0xc'),_0x3a0bfb,_0x1a7308['error'][_0x23f8('0x13')]);return _0x19754a(_0x1a7308['error'][_0x23f8('0x13')]);}else{logger[_0x23f8('0x14')](_0x23f8('0xc'),_0x3a0bfb,_0x23f8('0xd'));_0x19754a(_0x1a7308[_0x23f8('0x15')][_0x23f8('0x13')]);}})[_0x23f8('0x16')](function(_0x58d216){logger[_0x23f8('0x11')]('MailApplication,\x20%s,\x20%s',_0x3a0bfb,_0x58d216);_0x4ae35c(_0x58d216);});});}exports[_0x23f8('0x17')]=function(_0x1dbcc2){var _0x5a9edf=this;return new Promise(function(_0x52b76f,_0x4713ae){return db[_0x23f8('0x18')][_0x23f8('0x19')](_0x1dbcc2[_0x23f8('0x1a')],{'raw':_0x1dbcc2[_0x23f8('0x1b')]?_0x1dbcc2[_0x23f8('0x1b')][_0x23f8('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1dbcc2[_0x23f8('0x1b')]?_0x1dbcc2['options']['where']||null:null,'attributes':_0x1dbcc2[_0x23f8('0x1b')]?_0x1dbcc2[_0x23f8('0x1b')]['attributes']||null:null,'limit':_0x1dbcc2[_0x23f8('0x1b')]?_0x1dbcc2[_0x23f8('0x1b')][_0x23f8('0x1d')]||null:null})['then'](function(_0x199689){logger['info'](_0x23f8('0x17'),_0x1dbcc2);logger[_0x23f8('0xe')](_0x23f8('0x17'),_0x1dbcc2,JSON[_0x23f8('0x10')](_0x199689));_0x52b76f(_0x199689);})[_0x23f8('0x16')](function(_0x234d5c){logger['error'](_0x23f8('0x17'),_0x234d5c['message'],_0x1dbcc2);_0x4713ae(_0x5a9edf[_0x23f8('0x11')](0x1f4,_0x234d5c[_0x23f8('0x13')]));});});};