Built motion from commit ae138b72.|2.6.28
[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 _0xa883=['client','http','request','then','info','MailApplication,\x20%s,\x20%s','request\x20sent','error','message','result','catch','UpdateMailApplication','update','body','options','where','lodash','util','moment','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xa883,0xe8));var _0x3a88=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xa883[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0x3a88('0x0'));var util=require(_0x3a88('0x1'));var moment=require(_0x3a88('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x3a88('0x3'));var db=require(_0x3a88('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x3a88('0x5'));var config=require(_0x3a88('0x6'));var jayson=require(_0x3a88('0x7'));var client=jayson[_0x3a88('0x8')][_0x3a88('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x641655,_0x33b827,_0x489d5e){return new BPromise(function(_0x31a2dc,_0x329b04){return client[_0x3a88('0xa')](_0x641655,_0x489d5e)[_0x3a88('0xb')](function(_0x3ad430){logger[_0x3a88('0xc')](_0x3a88('0xd'),_0x33b827,'request\x20sent');logger['debug']('MailApplication,\x20%s,\x20%s,\x20%s',_0x33b827,_0x3a88('0xe'),JSON['stringify'](_0x3ad430));if(_0x3ad430['error']){if(_0x3ad430[_0x3a88('0xf')]['code']===0x1f4){logger[_0x3a88('0xf')](_0x3a88('0xd'),_0x33b827,_0x3ad430['error'][_0x3a88('0x10')]);return _0x329b04(_0x3ad430[_0x3a88('0xf')][_0x3a88('0x10')]);}logger[_0x3a88('0xf')](_0x3a88('0xd'),_0x33b827,_0x3ad430[_0x3a88('0xf')][_0x3a88('0x10')]);return _0x31a2dc(_0x3ad430[_0x3a88('0xf')][_0x3a88('0x10')]);}else{logger['info']('MailApplication,\x20%s,\x20%s',_0x33b827,'request\x20sent');_0x31a2dc(_0x3ad430[_0x3a88('0x11')][_0x3a88('0x10')]);}})[_0x3a88('0x12')](function(_0x3fa4a9){logger['error'](_0x3a88('0xd'),_0x33b827,_0x3fa4a9);_0x329b04(_0x3fa4a9);});});}exports[_0x3a88('0x13')]=function(_0x1c2421){var _0x195f5b=this;return new Promise(function(_0x25a5a6,_0x30ac04){return db['MailApplication'][_0x3a88('0x14')](_0x1c2421[_0x3a88('0x15')],{'raw':_0x1c2421[_0x3a88('0x16')]?_0x1c2421[_0x3a88('0x16')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1c2421['options']?_0x1c2421[_0x3a88('0x16')][_0x3a88('0x17')]||null:null,'attributes':_0x1c2421[_0x3a88('0x16')]?_0x1c2421[_0x3a88('0x16')]['attributes']||null:null,'limit':_0x1c2421[_0x3a88('0x16')]?_0x1c2421['options']['limit']||null:null})[_0x3a88('0xb')](function(_0x35bf1c){logger[_0x3a88('0xc')](_0x3a88('0x13'),_0x1c2421);logger['debug'](_0x3a88('0x13'),_0x1c2421,JSON['stringify'](_0x35bf1c));_0x25a5a6(_0x35bf1c);})[_0x3a88('0x12')](function(_0x48c0ea){logger['error'](_0x3a88('0x13'),_0x48c0ea[_0x3a88('0x10')],_0x1c2421);_0x30ac04(_0x195f5b[_0x3a88('0xf')](0x1f4,_0x48c0ea[_0x3a88('0x10')]));});});};