Skip to content

Commit

Permalink
fix: Fix Task Mention content generation - MEED-2529 - Meeds-io/MIPs#80
Browse files Browse the repository at this point in the history
… (#244)

Prior to this change, the content of Task in notification was mentioning the username instead of the User Full name. This change will ensure to change to use the full name in Task Comment Message instead of user mentioning.
  • Loading branch information
boubaker authored and exo-swf committed Sep 19, 2023
1 parent 7b3b5bb commit 7b676d7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.exoplatform.container.RootContainer;
import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.task.dto.ProjectDto;
import org.exoplatform.task.dto.TaskDto;
Expand Down Expand Up @@ -128,6 +129,10 @@ protected Set<String> getReceiver(TaskDto task, NotificationContext ctx) {
return receivers;
}

protected String getPortalOwner() {
return CommonsUtils.getService(UserPortalConfigService.class).getDefaultPortal();
}

private String buildTaskUrl(TaskDto t, ExoContainer container, WebAppController controller) {
return CommonsUtils.getCurrentDomain() + TaskUtil.buildTaskURL(t, CommonsUtils.getCurrentSite(), container, controller.getRouter());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.exoplatform.commons.api.notification.NotificationContext;
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.social.core.utils.MentionUtils;
import org.exoplatform.task.dto.CommentDto;
import org.exoplatform.task.dto.TaskDto;

Expand All @@ -48,7 +49,7 @@ public NotificationInfo makeNotification(NotificationContext ctx) {
CommentDto comment = ctx.value(NotificationUtils.COMMENT);
NotificationInfo info = super.makeNotification(ctx);
info.with(NotificationUtils.TASKS, String.valueOf(task.getId()));
info.with(NotificationUtils.COMMENT_TEXT, comment.getComment());
info.with(NotificationUtils.COMMENT_TEXT, MentionUtils.substituteUsernames(getPortalOwner(), comment.getComment()));
// Override the activityId
String projectId = "project.";
if (task.getStatus() != null && task.getStatus().getProject() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.exoplatform.commons.api.notification.NotificationContext;
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.social.core.utils.MentionUtils;
import org.exoplatform.task.dto.CommentDto;
import org.exoplatform.task.dto.TaskDto;

Expand All @@ -47,7 +48,7 @@ public NotificationInfo makeNotification(NotificationContext ctx) {
TaskDto task = ctx.value(NotificationUtils.TASK);
CommentDto comment = ctx.value(NotificationUtils.COMMENT);
NotificationInfo info = super.makeNotification(ctx);
info.with(NotificationUtils.COMMENT_TEXT, comment.getComment());
info.with(NotificationUtils.COMMENT_TEXT, MentionUtils.substituteUsernames(getPortalOwner(), comment.getComment()));
// Override the activityId
String projectId = "project.";
if (task.getStatus() != null && task.getStatus().getProject() != null) {
Expand Down

0 comments on commit 7b676d7

Please sign in to comment.