b272dfda15c387cae2f5f9f62d063a22c2292331
[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 _0xbea5=['info','MailApplication,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','MailApplication','update','body','options','raw','where','limit','UpdateMailApplication','lodash','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','http','then'];(function(_0x426829,_0x5ccd00){var _0x35e0f8=function(_0x555ecc){while(--_0x555ecc){_0x426829['push'](_0x426829['shift']());}};_0x35e0f8(++_0x5ccd00);}(_0xbea5,0x7d));var _0x5bea=function(_0x109371,_0x441c8e){_0x109371=_0x109371-0x0;var _0x4fd858=_0xbea5[_0x109371];return _0x4fd858;};'use strict';var _=require(_0x5bea('0x0'));var util=require('util');var moment=require(_0x5bea('0x1'));var BPromise=require(_0x5bea('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5bea('0x3'));var db=require(_0x5bea('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x5bea('0x5'))(_0x5bea('0x6'));var config=require('../../config/environment');var jayson=require(_0x5bea('0x7'));var client=jayson['client'][_0x5bea('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x170d30,_0x3411a0,_0x48b392){return new BPromise(function(_0x10d5c9,_0x10d7f0){return client['request'](_0x170d30,_0x48b392)[_0x5bea('0x9')](function(_0x21e7ea){logger[_0x5bea('0xa')](_0x5bea('0xb'),_0x3411a0,_0x5bea('0xc'));logger['debug']('MailApplication,\x20%s,\x20%s,\x20%s',_0x3411a0,_0x5bea('0xc'),JSON[_0x5bea('0xd')](_0x21e7ea));if(_0x21e7ea['error']){if(_0x21e7ea[_0x5bea('0xe')][_0x5bea('0xf')]===0x1f4){logger[_0x5bea('0xe')](_0x5bea('0xb'),_0x3411a0,_0x21e7ea[_0x5bea('0xe')][_0x5bea('0x10')]);return _0x10d7f0(_0x21e7ea[_0x5bea('0xe')]['message']);}logger[_0x5bea('0xe')](_0x5bea('0xb'),_0x3411a0,_0x21e7ea[_0x5bea('0xe')]['message']);return _0x10d5c9(_0x21e7ea[_0x5bea('0xe')]['message']);}else{logger[_0x5bea('0xa')](_0x5bea('0xb'),_0x3411a0,_0x5bea('0xc'));_0x10d5c9(_0x21e7ea[_0x5bea('0x11')]['message']);}})[_0x5bea('0x12')](function(_0x532948){logger[_0x5bea('0xe')]('MailApplication,\x20%s,\x20%s',_0x3411a0,_0x532948);_0x10d7f0(_0x532948);});});}exports['UpdateMailApplication']=function(_0x48f038){var _0x15e213=this;return new Promise(function(_0x54476b,_0x118502){return db[_0x5bea('0x13')][_0x5bea('0x14')](_0x48f038[_0x5bea('0x15')],{'raw':_0x48f038[_0x5bea('0x16')]?_0x48f038[_0x5bea('0x16')][_0x5bea('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x48f038[_0x5bea('0x16')]?_0x48f038[_0x5bea('0x16')][_0x5bea('0x18')]||null:null,'attributes':_0x48f038[_0x5bea('0x16')]?_0x48f038[_0x5bea('0x16')]['attributes']||null:null,'limit':_0x48f038['options']?_0x48f038[_0x5bea('0x16')][_0x5bea('0x19')]||null:null})[_0x5bea('0x9')](function(_0x5614cf){logger[_0x5bea('0xa')](_0x5bea('0x1a'),_0x48f038);logger['debug'](_0x5bea('0x1a'),_0x48f038,JSON[_0x5bea('0xd')](_0x5614cf));_0x54476b(_0x5614cf);})['catch'](function(_0x22b71d){logger[_0x5bea('0xe')](_0x5bea('0x1a'),_0x22b71d[_0x5bea('0x10')],_0x48f038);_0x118502(_0x15e213[_0x5bea('0xe')](0x1f4,_0x22b71d[_0x5bea('0x10')]));});});};