This commit is contained in:
Massimiliano Assante 2022-05-09 12:19:42 +02:00
parent c07d618220
commit 5fd457f230
1 changed files with 20 additions and 11 deletions

View File

@ -185,7 +185,7 @@ public class Notifications {
return Response.status(status).entity(responseBean).build();
}
/**
* Send a Catalogue notification to a given user
* @param event
@ -225,8 +225,9 @@ public class Notifications {
if (! event.idsAsGroup()) {
for (int i = 0; i < idsToNotify.length; i++) {
String userIdToNotify = idsToNotify[i];
String username2Notify = null;
try {
um.getUserByUsername(userIdToNotify);
username2Notify = um.getUserByUsername(userIdToNotify).getUsername();
}
catch (Exception e) {
status = Status.NOT_ACCEPTABLE;
@ -235,13 +236,20 @@ public class Notifications {
responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build();
}
deliveryResult =
nm.notifyCatalogueEvent(
CatalogueEventTypeMapper.getType(event.getType()),
userIdToNotify,
event.getItemId(),
event.getNotifyText(),
event.getItemURL());
if (username2Notify != null) {
deliveryResult =
nm.notifyCatalogueEvent(
CatalogueEventTypeMapper.getType(event.getType()),
username,
event.getItemId(),
event.getNotifyText(),
event.getItemURL());
} else {
status = Status.NOT_ACCEPTABLE;
responseBean.setSuccess(false);
responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build();
}
}
} else { //the ids are contexts
for (int i = 0; i < idsToNotify.length; i++) {
@ -335,8 +343,9 @@ public class Notifications {
if (! event.idsAsGroup()) {
for (int i = 0; i < idsToNotify.length; i++) {
String userIdToNotify = idsToNotify[i];
String username2Notify = "";
try {
um.getUserByUsername(userIdToNotify);
username2Notify = um.getUserByUsername(userIdToNotify).getUsername();
}
catch (Exception e) {
status = Status.NOT_ACCEPTABLE;
@ -345,7 +354,7 @@ public class Notifications {
responseBean.setMessage("Username not found " + userIdToNotify);
return Response.status(status).entity(responseBean).build();
}
deliveryResult = notifyWorkspaceEvent(event, nm, userIdToNotify);
deliveryResult = notifyWorkspaceEvent(event, nm, username2Notify);
}
} else { //the ids are contexts
for (int i = 0; i < idsToNotify.length; i++) {