diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/activity/KudosActivityTypePlugin.java b/kudos-services/src/main/java/org/exoplatform/kudos/activity/KudosActivityTypePlugin.java index fd770d33f..e9e44a46f 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/activity/KudosActivityTypePlugin.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/activity/KudosActivityTypePlugin.java @@ -24,6 +24,7 @@ import org.exoplatform.kudos.service.KudosService; import org.exoplatform.social.core.ActivityTypePlugin; import org.exoplatform.social.core.activity.model.ExoSocialActivity; +import org.exoplatform.social.core.utils.MentionUtils; public class KudosActivityTypePlugin extends ActivityTypePlugin { @@ -50,7 +51,7 @@ public boolean isEnableNotification(ExoSocialActivity activity, String username) @Override public String getActivityTitle(ExoSocialActivity activity) { Kudos kudos = this.kudosService.getKudosByActivityId(Long.parseLong(activity.getId().replace("comment", ""))); - return kudos == null ? activity.getTitle() : kudos.getMessage(); + return kudos == null ? activity.getTitle() : MentionUtils.substituteUsernames(kudos.getMessage()); } } diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/activity/processor/ActivityKudosProcessor.java b/kudos-services/src/main/java/org/exoplatform/kudos/activity/processor/ActivityKudosProcessor.java index 0e634544c..e25f03541 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/activity/processor/ActivityKudosProcessor.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/activity/processor/ActivityKudosProcessor.java @@ -22,7 +22,7 @@ public ActivityKudosProcessor(KudosService kudosService, InitParams initParams) { super(initParams); this.kudosService = kudosService; - this.defaultPortal = userPortalConfigService.getDefaultPortal(); + this.defaultPortal = userPortalConfigService.getMetaPortal(); } @Override diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/listener/KudosSentActivityGeneratorListener.java b/kudos-services/src/main/java/org/exoplatform/kudos/listener/KudosSentActivityGeneratorListener.java index 6ff5fee54..1fd30d791 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/listener/KudosSentActivityGeneratorListener.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/listener/KudosSentActivityGeneratorListener.java @@ -101,7 +101,7 @@ private ExoSocialActivity createActivity(Kudos kudos, String parentCommentId) { ExoSocialActivityImpl activity = new ExoSocialActivityImpl(); activity.setParentCommentId(parentCommentId); activity.setType(org.exoplatform.kudos.service.utils.Utils.KUDOS_ACTIVITY_COMMENT_TYPE); - activity.setTitle("Kudos to " + kudos.getReceiverFullName()); + activity.setTitle(kudos.getMessage()); activity.setBody("Kudos to " + kudos.getReceiverFullName()); activity.setUserId(kudos.getSenderIdentityId()); org.exoplatform.kudos.service.utils.Utils.computeKudosActivityProperties(activity, kudos); diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/notification/builder/KudosTemplateBuilder.java b/kudos-services/src/main/java/org/exoplatform/kudos/notification/builder/KudosTemplateBuilder.java index 289e4a29f..67a8e8475 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/notification/builder/KudosTemplateBuilder.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/notification/builder/KudosTemplateBuilder.java @@ -24,6 +24,7 @@ import org.exoplatform.social.core.processor.I18NActivityProcessor; import org.exoplatform.social.core.service.LinkProvider; import org.exoplatform.social.core.space.model.Space; +import org.exoplatform.social.core.utils.MentionUtils; import org.exoplatform.social.notification.LinkProviderUtils; import org.exoplatform.social.notification.Utils; import org.exoplatform.social.notification.plugin.SocialNotificationUtils; @@ -128,10 +129,10 @@ protected MessageInfo makeMessage(NotificationContext ctx) { // NOSONAR // body construction must be made after subject building if (activity != null) { if (StringUtils.isNotBlank(activity.getParentCommentId())) { - String parentCommentTitle = Utils.getActivityManager().getActivityTitle(activity.getParentCommentId()); + String parentCommentTitle = getActivityTitle(activity.getParentCommentId(), language); templateContext.put("ACTIVITY", parentCommentTitle); } else if (StringUtils.isNotBlank(activity.getParentId())) { - String parentActivityTitle = Utils.getActivityManager().getActivityTitle(activity.getParentId()); + String parentActivityTitle = getActivityTitle(activity.getParentId(), language); templateContext.put("ACTIVITY", parentActivityTitle); } else { templateContext.put("ACTIVITY", ""); @@ -159,4 +160,9 @@ protected ExoSocialActivity getI18N(ExoSocialActivity activity, Locale locale) { return activity; } + private String getActivityTitle(String activityId, String language) { + return MentionUtils.substituteRoleWithLocale(Utils.getActivityManager().getActivityTitle(activityId), + Locale.forLanguageTag(language)); + } + } diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosActivityChildPlugin.java b/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosActivityChildPlugin.java index ee676f603..277bbf673 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosActivityChildPlugin.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosActivityChildPlugin.java @@ -19,6 +19,8 @@ import static org.exoplatform.kudos.service.utils.Utils.KUDOS_ACTIVITY_COMMENT_TYPE; +import java.util.Locale; + import org.exoplatform.commons.api.notification.NotificationContext; import org.exoplatform.commons.api.notification.model.NotificationInfo; import org.exoplatform.commons.api.notification.plugin.AbstractNotificationChildPlugin; @@ -27,6 +29,7 @@ import org.exoplatform.container.xml.InitParams; import org.exoplatform.kudos.model.Kudos; import org.exoplatform.kudos.service.KudosService; +import org.exoplatform.social.core.utils.MentionUtils; import org.exoplatform.social.notification.plugin.SocialNotificationUtils; public class KudosActivityChildPlugin extends AbstractNotificationChildPlugin { @@ -50,8 +53,10 @@ public String makeContent(NotificationContext ctx) { if (kudos == null) { return ""; } - TemplateContext templateContext = new TemplateContext(getId(), getLanguage(notification)); - templateContext.put("MESSAGE", kudos.getMessage()); + String language = getLanguage(notification); + String message = MentionUtils.substituteUsernames(kudos.getMessage(), Locale.forLanguageTag(language)); + TemplateContext templateContext = new TemplateContext(getId(), language); + templateContext.put("MESSAGE", message); return TemplateUtils.processGroovy(templateContext); } diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosReceiverNotificationPlugin.java b/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosReceiverNotificationPlugin.java index 99afa4325..c0c85d973 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosReceiverNotificationPlugin.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosReceiverNotificationPlugin.java @@ -28,6 +28,7 @@ import org.exoplatform.kudos.model.Kudos; import org.exoplatform.social.core.activity.model.ExoSocialActivity; import org.exoplatform.social.core.manager.ActivityManager; +import org.exoplatform.social.core.utils.MentionUtils; import org.exoplatform.social.notification.plugin.SocialNotificationUtils; public class KudosReceiverNotificationPlugin extends BaseNotificationPlugin { @@ -75,7 +76,8 @@ public NotificationInfo makeNotification(NotificationContext ctx) { .with("RECEIVER_ID", receiverId) .with("RECEIVER_TYPE", receiverType) .with("KUDOS_ID", String.valueOf(kudos.getTechnicalId())) - .with("KUDOS_MESSAGE", kudos.getMessage() == null ? "" : kudos.getMessage()) + .with("KUDOS_MESSAGE", + kudos.getMessage() == null ? "" : MentionUtils.substituteUsernames(kudos.getMessage())) .key(getId()) .end(); } diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/rest/KudosREST.java b/kudos-services/src/main/java/org/exoplatform/kudos/rest/KudosREST.java index 21e9ef0d3..d98b64957 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/rest/KudosREST.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/rest/KudosREST.java @@ -20,6 +20,7 @@ import static org.exoplatform.kudos.service.utils.Utils.timeFromSeconds; import java.util.List; +import java.util.Locale; import javax.annotation.security.RolesAllowed; import javax.ws.rs.*; @@ -33,12 +34,15 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; + +import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.exoplatform.commons.exception.ObjectNotFoundException; import org.exoplatform.kudos.exception.KudosAlreadyLinkedException; import org.exoplatform.kudos.model.*; import org.exoplatform.kudos.service.KudosService; +import org.exoplatform.portal.application.localization.LocalizationFilter; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.rest.resource.ResourceContainer; @@ -46,6 +50,7 @@ import org.exoplatform.social.core.identity.model.Identity; import org.exoplatform.social.core.identity.provider.OrganizationIdentityProvider; import org.exoplatform.social.core.manager.IdentityManager; +import org.exoplatform.social.core.utils.MentionUtils; @Path("/kudos/api/kudos") @@ -82,6 +87,7 @@ public Response getKudosByPeriodOfDate(@Parameter(description = "Timestamp in se } try { List allKudosByPeriod = kudosService.getKudosByPeriodOfDate(dateInSeconds, getLimit(limit)); + translateRoleMentions(allKudosByPeriod.toArray(new Kudos[0])); return Response.ok(allKudosByPeriod).build(); } catch (Exception e) { LOG.warn("Error getting kudos list of period with date {}", dateInSeconds, e); @@ -108,6 +114,7 @@ public Response getEntityKudos(@Parameter(description = "kudos entity type (for } try { List allKudosByEntity = kudosService.getKudosByEntity(entityType, entityId, getLimit(limit)); + translateRoleMentions(allKudosByEntity.toArray(new Kudos[0])); return Response.ok(allKudosByEntity).build(); } catch (Exception e) { LOG.warn("Error getting kudos entity of entity {}/{}", entityType, entityId, e); @@ -137,6 +144,7 @@ public Response getKudosByActivityId( org.exoplatform.services.security.Identity currentUser = ConversationState.getCurrent().getIdentity(); try { Kudos kudos = kudosService.getKudosByActivityId(getActivityId(activityId), currentUser); + translateRoleMentions(kudos); return Response.ok(kudos).build(); } catch (IllegalAccessException e) { LOG.error("Access denied to user {} to access Kudos of activity by id {}", currentUser.getUserId(), activityId); @@ -171,6 +179,7 @@ public Response getKudosListOfActivity(@Parameter(description = "kudos parent ac org.exoplatform.services.security.Identity currentUser = ConversationState.getCurrent().getIdentity(); try { List kudosList = kudosService.getKudosListOfActivity(activityId, currentUser); + translateRoleMentions(kudosList.toArray(new Kudos[0])); return Response.ok(kudosList).build(); } catch (IllegalAccessException e) { LOG.error("Access denied to user {} to access Kudos of parent activity by id {}", currentUser.getUserId(), activityId); @@ -247,6 +256,7 @@ public Response getKudosByDates(@QueryParam("startDateInSeconds") long startDate } try { List allKudosByPeriod = kudosService.getKudosByPeriod(startDateInSeconds, endDateInSeconds, getLimit(limit)); + translateRoleMentions(allKudosByPeriod.toArray(new Kudos[0])); return Response.ok(allKudosByPeriod).build(); } catch (Exception e) { LOG.warn("Error getting kudos list of period: from {} to {}", startDateInSeconds, endDateInSeconds, e); @@ -322,6 +332,7 @@ public Response getReceivedKudosByPeriod(@Parameter(description = "User or space period.getStartDateInSeconds(), period.getEndDateInSeconds(), getLimit(limit)); + translateRoleMentions(kudos.toArray(new Kudos[0])); kudosList.setKudos(kudos); return Response.ok(kudosList).build(); } @@ -394,6 +405,7 @@ public Response getSentKudosByPeriod(@Parameter(description = "User or space ide period.getStartDateInSeconds(), period.getEndDateInSeconds(), getLimit(limit)); + translateRoleMentions(kudos.toArray(new Kudos[0])); kudosList.setKudos(kudos); return Response.ok(kudosList).build(); } @@ -432,6 +444,7 @@ public Response createKudos(@RequestBody(description = "Kudos object to create", try { kudos.setSenderId(getCurrentUserId()); Kudos kudosSent = kudosService.createKudos(kudos, getCurrentUserId()); + translateRoleMentions(kudosSent); return Response.ok(kudosSent).build(); } catch (Exception e) { LOG.warn("Error saving kudos: {}", kudos, e); @@ -513,8 +526,20 @@ private int getLimit(int limit) { return limit; } - private Long getActivityId(String commentId) { return (commentId == null || commentId.trim().isEmpty()) ? null : Long.valueOf(commentId.replace("comment", "")); } + + private void translateRoleMentions(Kudos ...kudosList) { + if (ArrayUtils.isEmpty(kudosList)) { + return; + } + Locale userLocale = LocalizationFilter.getCurrentLocale(); + for (Kudos kudos : kudosList) { + if (kudos != null) { + kudos.setMessage(MentionUtils.substituteUsernames(kudos.getMessage(), userLocale)); + } + } + } + } diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java b/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java index 8ea7dcd3f..d98fcd57e 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/service/utils/Utils.java @@ -1,17 +1,28 @@ package org.exoplatform.kudos.service.utils; -import java.time.*; -import java.util.*; +import static org.exoplatform.social.core.manager.ActivityManagerImpl.REMOVABLE; + +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.TimeZone; -import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.exoplatform.commons.api.notification.model.ArgumentLiteral; import org.exoplatform.commons.api.settings.data.Context; import org.exoplatform.commons.api.settings.data.Scope; import org.exoplatform.commons.utils.CommonsUtils; import org.exoplatform.kudos.entity.KudosEntity; -import org.exoplatform.kudos.model.*; +import org.exoplatform.kudos.model.GlobalSettings; +import org.exoplatform.kudos.model.Kudos; +import org.exoplatform.kudos.model.KudosEntityType; +import org.exoplatform.kudos.model.KudosPeriod; +import org.exoplatform.kudos.model.KudosPeriodType; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.ConversationState; @@ -28,8 +39,6 @@ import org.exoplatform.social.core.space.spi.SpaceService; import org.exoplatform.social.core.utils.MentionUtils; -import static org.exoplatform.social.core.manager.ActivityManagerImpl.REMOVABLE; - public class Utils { private static final Log LOG = ExoLogger.getLogger(Utils.class); @@ -141,17 +150,13 @@ public static String getReceiverType(String receiverType) { return SPACE_ACCOUNT_TYPE.equals(receiverType) ? SPACE_ACCOUNT_TYPE : USER_ACCOUNT_TYPE; } - public static Kudos fromEntity(KudosEntity kudosEntity, String defaultPortal) { + public static Kudos fromEntity(KudosEntity kudosEntity) { if (kudosEntity == null) { return null; } Kudos kudos = new Kudos(); kudos.setTechnicalId(kudosEntity.getId()); - if (defaultPortal == null) { - kudos.setMessage(kudosEntity.getMessage()); - } else { - kudos.setMessage(MentionUtils.substituteUsernames(defaultPortal, kudosEntity.getMessage())); - } + kudos.setMessage(kudosEntity.getMessage()); kudos.setEntityId(String.valueOf(kudosEntity.getEntityId())); kudos.setActivityId(kudosEntity.getActivityId()); if (kudosEntity.getParentEntityId() != null && kudosEntity.getParentEntityId() != 0) { @@ -254,7 +259,7 @@ public static void computeKudosActivityProperties(ExoSocialActivity activity, Ku String receiverLink = "" + kudos.getReceiverFullName() + ""; receiverLink = StringEscapeUtils.unescapeHtml4(receiverLink); - String kudosMessage = kudos.getMessage(); + String kudosMessage = MentionUtils.substituteUsernames(kudos.getMessage()); String message = StringUtils.isBlank(kudosMessage) ? "." : ": " + kudosMessage; if (activity.getTemplateParams() != null) { diff --git a/kudos-services/src/main/java/org/exoplatform/kudos/storage/KudosStorage.java b/kudos-services/src/main/java/org/exoplatform/kudos/storage/KudosStorage.java index 95febc47a..76f66728a 100644 --- a/kudos-services/src/main/java/org/exoplatform/kudos/storage/KudosStorage.java +++ b/kudos-services/src/main/java/org/exoplatform/kudos/storage/KudosStorage.java @@ -9,7 +9,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.picocontainer.Startable; @@ -24,7 +23,6 @@ import org.exoplatform.kudos.model.KudosEntityType; import org.exoplatform.kudos.model.KudosPeriod; import org.exoplatform.kudos.service.utils.Utils; -import org.exoplatform.portal.config.UserPortalConfigService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.social.core.identity.model.Identity; @@ -33,8 +31,6 @@ import org.exoplatform.social.core.manager.IdentityManager; import org.exoplatform.social.core.space.model.Space; -import jakarta.annotation.PostConstruct; - @Service // FIXME Should be @Repository instead, but Kept with @Service to expose it // into Kernel Container public class KudosStorage implements Startable { @@ -47,16 +43,6 @@ public class KudosStorage implements Startable { @Autowired private IdentityManager identityManager; - @Autowired - private UserPortalConfigService userPortalConfigService; - - private String defaultPortal; - - @PostConstruct - public void init() { - this.defaultPortal = userPortalConfigService.getMetaPortal(); - } - /** * @deprecated kept to be able to use this service as Kernel Service in Unit * Tests To delete once the Unit Tests migrated @@ -68,8 +54,6 @@ public void start() { PortalContainer container = PortalContainer.getInstance(); this.kudosDAO = container.getComponentInstanceOfType(KudosDAO.class); this.identityManager = container.getComponentInstanceOfType(IdentityManager.class); - this.defaultPortal = container.getComponentInstanceOfType(UserPortalConfigService.class) - .getDefaultPortal(); } public Kudos getKudoById(long id) { @@ -78,7 +62,7 @@ public Kudos getKudoById(long id) { LOG.warn("Can't find Kudos with id {}", id); return null; } else { - return fromEntity(kudosEntity, defaultPortal); + return fromEntity(kudosEntity); } } @@ -86,7 +70,7 @@ public Kudos createKudos(Kudos kudos) { KudosEntity kudosEntity = toEntity(kudos); kudosEntity.setId(null); kudosEntity = kudosDAO.create(kudosEntity); - return fromEntity(kudosEntity, defaultPortal); + return fromEntity(kudosEntity); } public void deleteKudosById(long kudosId) { @@ -113,7 +97,7 @@ public List getKudosByPeriod(KudosPeriod kudosPeriod, int limit) { if (kudosEntities != null) { for (KudosEntity kudosEntity : kudosEntities) { if (kudosEntity != null) { - kudosList.add(fromEntity(kudosEntity, defaultPortal)); + kudosList.add(fromEntity(kudosEntity)); } } } @@ -128,7 +112,7 @@ public List getKudosByEntity(String entityType, String entityId, int limi if (kudosEntities != null) { for (KudosEntity kudosEntity : kudosEntities) { if (kudosEntity != null) { - kudosList.add(fromEntity(kudosEntity, defaultPortal)); + kudosList.add(fromEntity(kudosEntity)); } } } @@ -173,7 +157,7 @@ public List getKudosByPeriodAndReceiver(KudosPeriod kudosPeriod, String r List kudosList = new ArrayList<>(); for (KudosEntity kudosEntity : kudosEntities) { if (kudosEntity != null) { - kudosList.add(fromEntity(kudosEntity, defaultPortal)); + kudosList.add(fromEntity(kudosEntity)); } } return kudosList; @@ -187,7 +171,7 @@ public List getKudosByPeriodAndSender(KudosPeriod kudosPeriod, long sende if (kudosEntities != null) { for (KudosEntity kudosEntity : kudosEntities) { if (kudosEntity != null) { - kudosList.add(fromEntity(kudosEntity, defaultPortal)); + kudosList.add(fromEntity(kudosEntity)); } } } @@ -225,15 +209,15 @@ private IdentityManager getIdentityManager() { public Kudos getKudosByActivityId(Long activityId) { KudosEntity kudosEntity = kudosDAO.getKudosByActivityId(activityId); - return fromEntity(kudosEntity, defaultPortal); + return fromEntity(kudosEntity); } public List getKudosListOfActivity(Long activityId) { List kudosEntities = kudosDAO.getKudosListOfActivity(activityId); return CollectionUtils.isEmpty(kudosEntities) ? Collections.emptyList() : kudosEntities.stream() - .map(entity -> Utils.fromEntity(entity, defaultPortal)) - .collect(Collectors.toList()); + .map(Utils::fromEntity) + .toList(); } public long countKudosOfActivity(Long activityId) { @@ -243,7 +227,7 @@ public long countKudosOfActivity(Long activityId) { public Kudos updateKudos(Kudos kudos) { KudosEntity kudosEntity = toEntity(kudos); kudosEntity = kudosDAO.update(kudosEntity); - return fromEntity(kudosEntity, defaultPortal); + return fromEntity(kudosEntity); } } diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosRestTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosRestTest.java index 14d161188..88ab1701f 100644 --- a/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosRestTest.java +++ b/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosRestTest.java @@ -107,7 +107,7 @@ protected T getService(Class componentType) { protected Kudos newKudosDTO() { KudosEntity entity = newKudosInstance(parentEntityId, entityId, entityType, receiverId, senderId, createdTimestamp, message); - return Utils.fromEntity(entity, DEFAULT_PORTAL); + return Utils.fromEntity(entity); } protected KudosEntity newKudos() { diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosTest.java index 47f7f1553..024176402 100644 --- a/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosTest.java +++ b/kudos-services/src/test/java/org/exoplatform/kudos/test/BaseKudosTest.java @@ -78,7 +78,7 @@ protected T getService(Class componentType) { protected Kudos newKudosDTO() { KudosEntity entity = newKudosInstance(parentEntityId, entityId, entityType, receiverId, senderId, createdTimestamp, message); - return Utils.fromEntity(entity, DEFAULT_PORTAL); + return Utils.fromEntity(entity); } protected KudosEntity newKudos() { diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/test/dao/KudosDAOTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/test/dao/KudosDAOTest.java index a3d24bbbf..ac663db37 100644 --- a/kudos-services/src/test/java/org/exoplatform/kudos/test/dao/KudosDAOTest.java +++ b/kudos-services/src/test/java/org/exoplatform/kudos/test/dao/KudosDAOTest.java @@ -233,7 +233,7 @@ public void testGetKudosByActivityId() { kudos.setActivityId(activityId); kudosDAO.create(kudos); KudosEntity newKudos = kudosDAO.getKudosByActivityId(activityId); - compareResults(newKudos, fromEntity(kudos, DEFAULT_PORTAL)); + compareResults(newKudos, fromEntity(kudos)); } } diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/test/rest/KudosRestTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/test/rest/KudosRestTest.java index 1490abb44..447440367 100644 --- a/kudos-services/src/test/java/org/exoplatform/kudos/test/rest/KudosRestTest.java +++ b/kudos-services/src/test/java/org/exoplatform/kudos/test/rest/KudosRestTest.java @@ -133,7 +133,7 @@ public void testGetKudosByActivityId() throws Exception { KudosService kudosService = getService(KudosService.class); KudosEntity kudosEntity = newKudosInstance(); - Kudos kudos = kudosService.createKudos(Utils.fromEntity(kudosEntity, DEFAULT_PORTAL), "root4"); + Kudos kudos = kudosService.createKudos(Utils.fromEntity(kudosEntity), "root4"); long activityId = 5; kudosService.updateKudosGeneratedActivityId(kudos.getTechnicalId(), activityId); @@ -243,7 +243,7 @@ public void testGetKudosListOfActivity() throws Exception { KudosEntity kudosEntity = newKudosInstance(); kudosEntity.setEntityType(KudosEntityType.SPACE_PROFILE.ordinal()); - Kudos parentKudos = kudosService.createKudos(Utils.fromEntity(kudosEntity, DEFAULT_PORTAL), senderUsername); + Kudos parentKudos = kudosService.createKudos(Utils.fromEntity(kudosEntity), senderUsername); ActivityManager activityManager = getService(ActivityManager.class); ExoSocialActivity activity = new ExoSocialActivityImpl(); @@ -257,7 +257,7 @@ public void testGetKudosListOfActivity() throws Exception { childKudosEntity.setEntityType(KudosEntityType.ACTIVITY.ordinal()); childKudosEntity.setEntityId(250l); childKudosEntity.setParentEntityId(parentKudos.getActivityId()); - Kudos childKudos = kudosService.createKudos(Utils.fromEntity(childKudosEntity, DEFAULT_PORTAL), senderUsername); + Kudos childKudos = kudosService.createKudos(Utils.fromEntity(childKudosEntity), senderUsername); getKudosListOfActivity("%20", senderUsername, 400); getKudosListOfActivity(activityId, "root3", 404); @@ -282,7 +282,7 @@ public void testGetKudosListOfActivity() throws Exception { subCommentKudosEntity.setEntityType(KudosEntityType.COMMENT.ordinal()); subCommentKudosEntity.setEntityId(255l); subCommentKudosEntity.setParentEntityId(parentKudos.getActivityId()); - Kudos subCommentKudos = kudosService.createKudos(Utils.fromEntity(subCommentKudosEntity, DEFAULT_PORTAL), senderUsername); + Kudos subCommentKudos = kudosService.createKudos(Utils.fromEntity(subCommentKudosEntity), senderUsername); kudosList = getKudosListOfActivity(activityId, senderUsername, 200); diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/test/service/KudosServiceTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/test/service/KudosServiceTest.java index 939a79749..771fe8ff6 100644 --- a/kudos-services/src/test/java/org/exoplatform/kudos/test/service/KudosServiceTest.java +++ b/kudos-services/src/test/java/org/exoplatform/kudos/test/service/KudosServiceTest.java @@ -560,7 +560,7 @@ public void testGetKudosByActivityId() throws Exception { // NOSONAR KudosStorage kudosStorage = getService(KudosStorage.class); KudosEntity kudosEntity = newKudos(); kudosEntity.setEntityType(KudosEntityType.USER_PROFILE.ordinal()); - Kudos kudos = kudosService.createKudos(Utils.fromEntity(kudosEntity, DEFAULT_PORTAL), SENDER_REMOTE_ID); + Kudos kudos = kudosService.createKudos(Utils.fromEntity(kudosEntity), SENDER_REMOTE_ID); Kudos storedKudos = kudosStorage.getKudoById(kudos.getTechnicalId()); Kudos newKudos = kudosService.getKudosByActivityId(storedKudos.getActivityId()); compareResults(Utils.toEntity(storedKudos), newKudos); @@ -574,7 +574,7 @@ public void testGetKudosListOfActivity() throws Exception { KudosEntity kudosEntity = newKudosInstance(); kudosEntity.setEntityType(KudosEntityType.SPACE_PROFILE.ordinal()); - Kudos parentKudos = kudosService.createKudos(Utils.fromEntity(kudosEntity, DEFAULT_PORTAL), SENDER_REMOTE_ID); + Kudos parentKudos = kudosService.createKudos(Utils.fromEntity(kudosEntity), SENDER_REMOTE_ID); ActivityManager activityManager = getService(ActivityManager.class); ExoSocialActivity activity = new ExoSocialActivityImpl(); @@ -587,7 +587,7 @@ public void testGetKudosListOfActivity() throws Exception { childKudosEntity.setEntityType(KudosEntityType.ACTIVITY.ordinal()); childKudosEntity.setEntityId(250l); childKudosEntity.setParentEntityId(parentKudos.getActivityId()); - Kudos childKudos = kudosService.createKudos(Utils.fromEntity(childKudosEntity, DEFAULT_PORTAL), SENDER_REMOTE_ID); + Kudos childKudos = kudosService.createKudos(Utils.fromEntity(childKudosEntity), SENDER_REMOTE_ID); try { // NOSONAR Test expected exception kudosService.getKudosListOfActivity(activity.getId(), null); @@ -627,7 +627,7 @@ public void testGetKudosListOfActivity() throws Exception { subCommentKudosEntity.setEntityType(KudosEntityType.COMMENT.ordinal()); subCommentKudosEntity.setEntityId(255l); subCommentKudosEntity.setParentEntityId(parentKudos.getActivityId()); - Kudos subCommentKudos = kudosService.createKudos(Utils.fromEntity(subCommentKudosEntity, DEFAULT_PORTAL), SENDER_REMOTE_ID); + Kudos subCommentKudos = kudosService.createKudos(Utils.fromEntity(subCommentKudosEntity), SENDER_REMOTE_ID); kudosList = kudosService.getKudosListOfActivity(activity.getId(), new org.exoplatform.services.security.Identity("root")); diff --git a/kudos-webapps/src/main/webapp/vue-app/kudos/components/KudosApp.vue b/kudos-webapps/src/main/webapp/vue-app/kudos/components/KudosApp.vue index fa52487e9..0c22e0cba 100644 --- a/kudos-webapps/src/main/webapp/vue-app/kudos/components/KudosApp.vue +++ b/kudos-webapps/src/main/webapp/vue-app/kudos/components/KudosApp.vue @@ -183,7 +183,7 @@ :ck-editor-id="ckEditorId" :placeholder="$t('exoplatform.kudos.label.kudosMessagePlaceholder')" :suggestor-type-of-relation="typeOfRelation" - :suggester-space-u-r-l="spaceURL" + :suggester-space-pretty-name="spacePrettyName" :object-id="metadataObjectId" :object-type="objectType" class="flex" @@ -267,7 +267,6 @@ export default { identity: null, currentUserId: eXo.env.portal.userIdentityId, selectedReceiver: null, - spaceURL: null, audience: '', objectType: 'activity', readOnlySpace: false, @@ -308,7 +307,7 @@ export default { } }, audience() { - this.spaceURL = this.audience?.remoteId || null; + this.spacePrettyName = this.audience?.remoteId || null; this.spaceId = this.audience?.spaceId || null; }, audienceChoice(newVal) { @@ -337,7 +336,7 @@ export default { searchOptions() { return { currentUser: this.username, - spaceURL: this.spaceURL, + spacePrettyName: this.spacePrettyName, activityId: this.entityId }; }, @@ -352,7 +351,7 @@ export default { return { searchPlaceholder: this.$t('exoplatform.kudos.receiver.searchPlaceholder'), placeholder: this.$t('exoplatform.kudos.receiver.placeholder'), - noDataLabel: this.spaceURL ? this.$t('exoplatform.kudos.receiver.noDataLabelInSpace') : this.$t('exoplatform.kudos.receiver.noDataLabel'), + noDataLabel: this.spacePrettyName ? this.$t('exoplatform.kudos.receiver.noDataLabelInSpace') : this.$t('exoplatform.kudos.receiver.noDataLabel'), }; }, KudosAllowedInfo() { @@ -562,7 +561,7 @@ export default { this.entityOwner = event?.detail?.owner || eXo.env.portal.userName; this.parentEntityId = event?.detail?.parentId || ''; this.ignoreRefresh = event && event.detail && event.detail.ignoreRefresh; - this.spaceURL = event && event.detail && event.detail.spaceURL || null; + this.spacePrettyName = event && event.detail && event.detail.spaceURL || null; this.metadataObjectId = null; this.$refs.drawer.open(); this.$refs.drawer.startLoading();