should not send notification if sender and receiver are the same
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@74109 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b0d7c8f89c
commit
af449595a0
|
@ -57,6 +57,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
*/
|
*/
|
||||||
private boolean saveNotification(Notification notification2Save) {
|
private boolean saveNotification(Notification notification2Save) {
|
||||||
_log.trace("Trying to send notification to: " + notification2Save.getUserid() + " Type: " + notification2Save.getType());
|
_log.trace("Trying to send notification to: " + notification2Save.getUserid() + " Type: " + notification2Save.getType());
|
||||||
|
if (notification2Save.getSenderid().compareTo(notification2Save.getUserid()) == 0) {
|
||||||
|
_log.trace("Sender and Receiver are the same " + notification2Save.getUserid() + " Notification Stopped");
|
||||||
|
return true; //I'm not sending notifications to the person who triggered it, pretend I sent it though
|
||||||
|
}
|
||||||
List<NotificationChannelType> channels = null;
|
List<NotificationChannelType> channels = null;
|
||||||
try {
|
try {
|
||||||
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid());
|
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid());
|
||||||
|
@ -73,12 +77,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
}
|
}
|
||||||
if (channels.contains(NotificationChannelType.EMAIL))
|
if (channels.contains(NotificationChannelType.EMAIL))
|
||||||
EmailPlugin.sendNotification(notification2Save, aslSession.getGroupName());
|
EmailPlugin.sendNotification(notification2Save, aslSession.getGroupName());
|
||||||
|
|
||||||
if (channels.isEmpty()) {
|
if (channels.isEmpty()) {
|
||||||
_log.info("Notification was not needed as the user decided not to be notified");
|
_log.info("Notification was not needed as the user decided not to be notified");
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* return the url of the application if exists in the profile
|
* return the url of the application if exists in the profile
|
||||||
|
@ -171,7 +176,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
UserManager um = new LiferayUserManager();
|
UserManager um = new LiferayUserManager();
|
||||||
for (String userId : newAddedUserIds)
|
for (String userId : newAddedUserIds)
|
||||||
addedUsersFullNames.append(um.getUserByScreenName(userId).getFullname()).append(" ");
|
addedUsersFullNames.append(um.getUserByScreenName(userId).getFullname()).append(" ");
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.WP_FOLDER_ADDEDUSER,
|
NotificationType.WP_FOLDER_ADDEDUSER,
|
||||||
|
@ -187,7 +192,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -339,22 +344,22 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName) {
|
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName) {
|
||||||
String notificationText = (aslSession.getUserFullName().compareTo(feedOwnerFullName) == 0) ?
|
String notificationText = (aslSession.getUserFullName().compareTo(feedOwnerFullName) == 0) ?
|
||||||
"also commented on his post: " + escapeHtml(commentText)
|
"also commented on his post: " + escapeHtml(commentText)
|
||||||
:
|
:
|
||||||
"also commented on " + feedOwnerFullName + "'s post: " + escapeHtml(commentText);
|
"also commented on " + feedOwnerFullName + "'s post: " + escapeHtml(commentText);
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.COMMENT,
|
NotificationType.COMMENT,
|
||||||
userIdToNotify, //user no notify
|
userIdToNotify, //user no notify
|
||||||
feedid, //the post
|
feedid, //the post
|
||||||
new Date(),
|
new Date(),
|
||||||
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
||||||
notificationText,
|
notificationText,
|
||||||
false,
|
false,
|
||||||
aslSession.getUsername(),
|
aslSession.getUsername(),
|
||||||
aslSession.getUserFullName(),
|
aslSession.getUserFullName(),
|
||||||
aslSession.getUserAvatarId());
|
aslSession.getUserAvatarId());
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -465,10 +470,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean notifyDocumentWorkflowTaskRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRoleName) {
|
public boolean notifyDocumentWorkflowTaskRequest(String userIdToNotify, String documentWorkflowId, String documentName, String assignedRoleName) {
|
||||||
|
|
||||||
String notificationText = "in " + aslSession.getGroupName() + " you are requested to perform a new task in the Document Workflow titled: "
|
String notificationText = "in " + aslSession.getGroupName() + " you are requested to perform a new task in the Document Workflow titled: "
|
||||||
+ escapeHtml(documentName) + ". Your role is: " + assignedRoleName;
|
+ escapeHtml(documentName) + ". Your role is: " + assignedRoleName;
|
||||||
|
|
||||||
Notification not = new Notification(
|
Notification not = new Notification(
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,
|
NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,
|
||||||
|
@ -477,10 +482,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
new Date(),
|
new Date(),
|
||||||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||||
notificationText,
|
notificationText,
|
||||||
false,
|
false,
|
||||||
aslSession.getUsername(),
|
aslSession.getUsername(),
|
||||||
aslSession.getUserFullName(),
|
aslSession.getUserFullName(),
|
||||||
aslSession.getUserAvatarId());
|
aslSession.getUserAvatarId());
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
|
|
||||||
|
@ -499,11 +504,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||||
|
|
||||||
"forwarded the Document Workflow titled: " + escapeHtml(documentName) +
|
"forwarded the Document Workflow titled: " + escapeHtml(documentName) +
|
||||||
" from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
" from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
||||||
false,
|
false,
|
||||||
aslSession.getUsername(),
|
aslSession.getUsername(),
|
||||||
aslSession.getUserFullName(),
|
aslSession.getUserFullName(),
|
||||||
aslSession.getUserAvatarId());
|
aslSession.getUserAvatarId());
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
@ -543,10 +548,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
||||||
new Date(),
|
new Date(),
|
||||||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||||
notificationText,
|
notificationText,
|
||||||
false,
|
false,
|
||||||
aslSession.getUsername(),
|
aslSession.getUsername(),
|
||||||
aslSession.getUserFullName(),
|
aslSession.getUserFullName(),
|
||||||
aslSession.getUserAvatarId());
|
aslSession.getUserAvatarId());
|
||||||
|
|
||||||
return saveNotification(not);
|
return saveNotification(not);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue