1d1e86015c881c882c29ee707c9a63703837e54d
[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 _0x28ac=['code','message','MailApplication,\x20%s,\x20%s','catch','update','body','options','raw','limit','UpdateMailApplication','debug','stringify','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','request\x20sent','MailApplication,\x20%s,\x20%s,\x20%s','error'];(function(_0x3f0b30,_0x159bc8){var _0x2748a5=function(_0x3b42cc){while(--_0x3b42cc){_0x3f0b30['push'](_0x3f0b30['shift']());}};_0x2748a5(++_0x159bc8);}(_0x28ac,0x1e8));var _0xc28a=function(_0x148fbc,_0x506529){_0x148fbc=_0x148fbc-0x0;var _0x584012=_0x28ac[_0x148fbc];return _0x584012;};'use strict';var _=require('lodash');var util=require(_0xc28a('0x0'));var moment=require('moment');var BPromise=require(_0xc28a('0x1'));var rs=require(_0xc28a('0x2'));var fs=require('fs');var Redis=require(_0xc28a('0x3'));var db=require(_0xc28a('0x4'))['db'];var utils=require(_0xc28a('0x5'));var logger=require(_0xc28a('0x6'))(_0xc28a('0x7'));var config=require(_0xc28a('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xc28a('0x9')][_0xc28a('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x3e5433,_0x22ff41,_0x10bcfd){return new BPromise(function(_0x209c6d,_0x4ebb74){return client[_0xc28a('0xb')](_0x3e5433,_0x10bcfd)[_0xc28a('0xc')](function(_0x3a4426){logger['info']('MailApplication,\x20%s,\x20%s',_0x22ff41,_0xc28a('0xd'));logger['debug'](_0xc28a('0xe'),_0x22ff41,_0xc28a('0xd'),JSON['stringify'](_0x3a4426));if(_0x3a4426[_0xc28a('0xf')]){if(_0x3a4426[_0xc28a('0xf')][_0xc28a('0x10')]===0x1f4){logger[_0xc28a('0xf')]('MailApplication,\x20%s,\x20%s',_0x22ff41,_0x3a4426[_0xc28a('0xf')][_0xc28a('0x11')]);return _0x4ebb74(_0x3a4426[_0xc28a('0xf')][_0xc28a('0x11')]);}logger[_0xc28a('0xf')](_0xc28a('0x12'),_0x22ff41,_0x3a4426[_0xc28a('0xf')]['message']);return _0x209c6d(_0x3a4426[_0xc28a('0xf')][_0xc28a('0x11')]);}else{logger['info'](_0xc28a('0x12'),_0x22ff41,'request\x20sent');_0x209c6d(_0x3a4426['result'][_0xc28a('0x11')]);}})[_0xc28a('0x13')](function(_0x48d157){logger[_0xc28a('0xf')](_0xc28a('0x12'),_0x22ff41,_0x48d157);_0x4ebb74(_0x48d157);});});}exports['UpdateMailApplication']=function(_0x5e93bb){var _0x51af81=this;return new Promise(function(_0x553621,_0x30a784){return db['MailApplication'][_0xc28a('0x14')](_0x5e93bb[_0xc28a('0x15')],{'raw':_0x5e93bb['options']?_0x5e93bb[_0xc28a('0x16')][_0xc28a('0x17')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5e93bb[_0xc28a('0x16')]?_0x5e93bb['options']['where']||null:null,'attributes':_0x5e93bb[_0xc28a('0x16')]?_0x5e93bb[_0xc28a('0x16')]['attributes']||null:null,'limit':_0x5e93bb[_0xc28a('0x16')]?_0x5e93bb[_0xc28a('0x16')][_0xc28a('0x18')]||null:null})[_0xc28a('0xc')](function(_0x517af7){logger['info'](_0xc28a('0x19'),_0x5e93bb);logger[_0xc28a('0x1a')](_0xc28a('0x19'),_0x5e93bb,JSON[_0xc28a('0x1b')](_0x517af7));_0x553621(_0x517af7);})['catch'](function(_0x1d821b){logger[_0xc28a('0xf')](_0xc28a('0x19'),_0x1d821b[_0xc28a('0x11')],_0x5e93bb);_0x30a784(_0x51af81[_0xc28a('0xf')](0x1f4,_0x1d821b[_0xc28a('0x11')]));});});};