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) {
|
||||
_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;
|
||||
try {
|
||||
channels = getStoreInstance().getUserNotificationChannels(notification2Save.getUserid());
|
||||
|
@ -73,12 +77,13 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
}
|
||||
if (channels.contains(NotificationChannelType.EMAIL))
|
||||
EmailPlugin.sendNotification(notification2Save, aslSession.getGroupName());
|
||||
|
||||
|
||||
if (channels.isEmpty()) {
|
||||
_log.info("Notification was not needed as the user decided not to be notified");
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
for (String userId : newAddedUserIds)
|
||||
addedUsersFullNames.append(um.getUserByScreenName(userId).getFullname()).append(" ");
|
||||
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.WP_FOLDER_ADDEDUSER,
|
||||
|
@ -187,7 +192,7 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
|
||||
return saveNotification(not);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
|
@ -339,22 +344,22 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
@Override
|
||||
public boolean notifyCommentReply(String userIdToNotify, String feedid, String commentText, String feedOwnerFullName) {
|
||||
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);
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.COMMENT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
new Date(),
|
||||
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
||||
notificationText,
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
return saveNotification(not);
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.COMMENT,
|
||||
userIdToNotify, //user no notify
|
||||
feedid, //the post
|
||||
new Date(),
|
||||
"/group/data-e-infrastructure-gateway?oid="+feedid,
|
||||
notificationText,
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
return saveNotification(not);
|
||||
}
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -465,10 +470,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
*/
|
||||
@Override
|
||||
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: "
|
||||
+ escapeHtml(documentName) + ". Your role is: " + assignedRoleName;
|
||||
|
||||
|
||||
Notification not = new Notification(
|
||||
UUID.randomUUID().toString(),
|
||||
NotificationType.DOCUMENT_WORKFLOW_STEP_REQUEST_TASK,
|
||||
|
@ -477,10 +482,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
new Date(),
|
||||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||
notificationText,
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
|
||||
return saveNotification(not);
|
||||
|
||||
|
@ -499,11 +504,11 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||
|
||||
"forwarded the Document Workflow titled: " + escapeHtml(documentName) +
|
||||
" from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
" from status \"" + fromStepName + "\" to status \"" + toStepName +"\". In " + aslSession.getGroupName(),
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
|
||||
return saveNotification(not);
|
||||
}
|
||||
|
@ -543,10 +548,10 @@ public class ApplicationNotificationsManager extends SocialPortalBridge implemen
|
|||
new Date(),
|
||||
getApplicationUrl()+"?oid="+documentWorkflowId,
|
||||
notificationText,
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
false,
|
||||
aslSession.getUsername(),
|
||||
aslSession.getUserFullName(),
|
||||
aslSession.getUserAvatarId());
|
||||
|
||||
return saveNotification(not);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue