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
new file mode 100644
index 000000000..fd770d33f
--- /dev/null
+++ b/kudos-services/src/main/java/org/exoplatform/kudos/activity/KudosActivityTypePlugin.java
@@ -0,0 +1,56 @@
+/**
+ * This file is part of the Meeds project (https://meeds.io/).
+ *
+ * Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.exoplatform.kudos.activity;
+
+import org.apache.commons.lang3.StringUtils;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.kudos.model.Kudos;
+import org.exoplatform.kudos.service.KudosService;
+import org.exoplatform.social.core.ActivityTypePlugin;
+import org.exoplatform.social.core.activity.model.ExoSocialActivity;
+
+public class KudosActivityTypePlugin extends ActivityTypePlugin {
+
+ private KudosService kudosService;
+
+ public KudosActivityTypePlugin(KudosService kudosService,
+ InitParams params) {
+ super(params);
+ this.kudosService = kudosService;
+ }
+
+ @Override
+ public boolean isEnableNotification(ExoSocialActivity activity, String username) {
+ if (StringUtils.isBlank(username)) {
+ return false;
+ } else {
+ Kudos kudos = this.kudosService.getKudosByActivityId(Long.parseLong(activity.getId().replace("comment", "")));
+ return kudos != null
+ && !StringUtils.equals(kudos.getReceiverId(), username)
+ && !StringUtils.equals(kudos.getSenderId(), 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();
+ }
+
+}
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 61b30b0cb..06c8f248e 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
@@ -131,7 +131,16 @@ protected MessageInfo makeMessage(NotificationContext ctx) { // NOSONAR
}
// body construction must be made after subject building
if (activity != null) {
- messageInfo.body(SocialNotificationUtils.getBody(ctx, templateContext, activity));
+ if (StringUtils.isNotBlank(activity.getParentCommentId())) {
+ String parentCommentTitle = Utils.getActivityManager().getActivityTitle(activity.getParentCommentId());
+ templateContext.put("ACTIVITY", parentCommentTitle);
+ } else if (StringUtils.isNotBlank(activity.getParentId())) {
+ String parentActivityTitle = Utils.getActivityManager().getActivityTitle(activity.getParentId());
+ templateContext.put("ACTIVITY", parentActivityTitle);
+ } else {
+ templateContext.put("ACTIVITY", "");
+ }
+ messageInfo.body(TemplateUtils.processGroovy(templateContext));
} else {
templateContext.put("ACTIVITY", "");
messageInfo.body(TemplateUtils.processGroovy(templateContext));
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
new file mode 100644
index 000000000..ee676f603
--- /dev/null
+++ b/kudos-services/src/main/java/org/exoplatform/kudos/notification/plugin/KudosActivityChildPlugin.java
@@ -0,0 +1,68 @@
+/**
+ * This file is part of the Meeds project (https://meeds.io/).
+ *
+ * Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.exoplatform.kudos.notification.plugin;
+
+import static org.exoplatform.kudos.service.utils.Utils.KUDOS_ACTIVITY_COMMENT_TYPE;
+
+import org.exoplatform.commons.api.notification.NotificationContext;
+import org.exoplatform.commons.api.notification.model.NotificationInfo;
+import org.exoplatform.commons.api.notification.plugin.AbstractNotificationChildPlugin;
+import org.exoplatform.commons.api.notification.service.template.TemplateContext;
+import org.exoplatform.commons.notification.template.TemplateUtils;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.kudos.model.Kudos;
+import org.exoplatform.kudos.service.KudosService;
+import org.exoplatform.social.notification.plugin.SocialNotificationUtils;
+
+public class KudosActivityChildPlugin extends AbstractNotificationChildPlugin {
+
+ private KudosService kudosService;
+
+ public KudosActivityChildPlugin(KudosService kudosService, InitParams initParams) {
+ super(initParams);
+ this.kudosService = kudosService;
+ }
+
+ @Override
+ public String makeContent(NotificationContext ctx) {
+ NotificationInfo notification = ctx.getNotificationInfo();
+ if (notification == null) {
+ return "";
+ }
+
+ String activityId = notification.getValueOwnerParameter(SocialNotificationUtils.ACTIVITY_ID.getKey());
+ Kudos kudos = kudosService.getKudosByActivityId(Long.parseLong(activityId.replace("comment", "")));
+ if (kudos == null) {
+ return "";
+ }
+ TemplateContext templateContext = new TemplateContext(getId(), getLanguage(notification));
+ templateContext.put("MESSAGE", kudos.getMessage());
+ return TemplateUtils.processGroovy(templateContext);
+ }
+
+ @Override
+ public String getId() {
+ return KUDOS_ACTIVITY_COMMENT_TYPE;
+ }
+
+ @Override
+ public boolean isValid(NotificationContext ctx) {
+ return false;
+ }
+
+}
diff --git a/kudos-services/src/main/resources/notification/KudosActivity.gtmpl b/kudos-services/src/main/resources/notification/KudosActivity.gtmpl
new file mode 100644
index 000000000..842d9456b
--- /dev/null
+++ b/kudos-services/src/main/resources/notification/KudosActivity.gtmpl
@@ -0,0 +1,20 @@
+<%
+/**
+ * This file is part of the Meeds project (https://meeds.io/).
+ *
+ * Copyright (C) 2023 Meeds Association contact@meeds.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+%>
+$MESSAGE
\ No newline at end of file
diff --git a/kudos-services/src/test/java/org/exoplatform/kudos/activity/KudosActivityChildPluginTest.java b/kudos-services/src/test/java/org/exoplatform/kudos/activity/KudosActivityChildPluginTest.java
new file mode 100644
index 000000000..158ec8e3a
--- /dev/null
+++ b/kudos-services/src/test/java/org/exoplatform/kudos/activity/KudosActivityChildPluginTest.java
@@ -0,0 +1,83 @@
+/**
+ * This file is part of the Meeds project (https://meeds.io/).
+ *
+ * Copyright (C) 2020 - 2023 Meeds Association contact@meeds.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.exoplatform.kudos.activity;
+
+import static org.exoplatform.kudos.service.utils.Utils.KUDOS_ACTIVITY_COMMENT_TYPE;
+import static org.mockito.Mockito.when;
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import org.exoplatform.commons.api.notification.NotificationContext;
+import org.exoplatform.commons.api.notification.model.NotificationInfo;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.kudos.model.Kudos;
+import org.exoplatform.kudos.notification.plugin.KudosActivityChildPlugin;
+import org.exoplatform.kudos.service.KudosService;
+import org.exoplatform.kudos.test.BaseKudosTest;
+import org.exoplatform.social.notification.plugin.SocialNotificationUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class KudosActivityChildPluginTest extends BaseKudosTest {
+
+ private static final long KUDOS_BY_ACTIVITY_ID = 5l;
+
+ private static final String KUDOS_MESSAGE = "KUDOS_MESSAGE";
+
+ @Mock
+ private KudosService kudosService;
+
+ @Mock
+ private InitParams initParams;
+
+ @Mock
+ private NotificationContext ctx;
+
+ @Mock
+ private NotificationInfo notification;
+
+ @Mock
+ private Kudos kudos;
+
+ @Test
+ public void testGetId() {
+ KudosActivityChildPlugin kudosActivityChildPlugin = new KudosActivityChildPlugin(kudosService, initParams);
+ assertEquals(KUDOS_ACTIVITY_COMMENT_TYPE, kudosActivityChildPlugin.getId());
+ }
+
+ @Test
+ public void testIsValid() {
+ KudosActivityChildPlugin kudosActivityChildPlugin = new KudosActivityChildPlugin(kudosService, initParams);
+ assertFalse(kudosActivityChildPlugin.isValid(null));
+ }
+
+ @Test
+ public void testMakeContent() {
+ KudosActivityChildPlugin kudosActivityChildPlugin = new KudosActivityChildPlugin(kudosService, initParams);
+ when(kudosService.getKudosByActivityId(KUDOS_BY_ACTIVITY_ID)).thenReturn(kudos);
+ when(kudos.getMessage()).thenReturn(KUDOS_MESSAGE);
+ when(ctx.getNotificationInfo()).thenReturn(notification);
+ when(notification.getValueOwnerParameter(SocialNotificationUtils.ACTIVITY_ID.getKey())).thenReturn(String.valueOf(KUDOS_BY_ACTIVITY_ID));
+
+ assertTrue(StringUtils.contains(kudosActivityChildPlugin.makeContent(ctx), KUDOS_MESSAGE));
+ }
+
+}
diff --git a/kudos-services/src/test/resources/conf/kudos-test-configuration.xml b/kudos-services/src/test/resources/conf/kudos-test-configuration.xml
index 7285e9091..88601d144 100644
--- a/kudos-services/src/test/resources/conf/kudos-test-configuration.xml
+++ b/kudos-services/src/test/resources/conf/kudos-test-configuration.xml
@@ -52,5 +52,54 @@
+
+ org.exoplatform.commons.api.notification.service.setting.PluginContainer
+
+
+ notification.plugins
+ addChildPlugin
+ org.exoplatform.kudos.notification.plugin.KudosActivityChildPlugin
+ Initial information for Kudos child notification plugin.
+
+
+ templatePath
+
+
+
+ template.gamification.KudosActivity
+ The template of KudosActivityChildPlugin
+
+
+
+
+
+
+
+ org.exoplatform.social.core.manager.ActivityManager
+
+ NewsActivityTypePlugin
+ addActivityTypePlugin
+ org.exoplatform.kudos.activity.KudosActivityTypePlugin
+
+
+ type
+ exokudos:activity
+
+
+ enableNotification
+ true
+
+
+
+
+
org.exoplatform.commons.search.index.IndexingOperationProcessor
diff --git a/kudos-webapps/src/main/webapp/WEB-INF/conf/kudos/notification-configuration.xml b/kudos-webapps/src/main/webapp/WEB-INF/conf/kudos/notification-configuration.xml
index 2da930e81..3257e1c93 100644
--- a/kudos-webapps/src/main/webapp/WEB-INF/conf/kudos/notification-configuration.xml
+++ b/kudos-webapps/src/main/webapp/WEB-INF/conf/kudos/notification-configuration.xml
@@ -32,7 +32,32 @@
org.exoplatform.commons.api.notification.service.setting.PluginContainer
-
+
+
+ notification.plugins
+ addChildPlugin
+ org.exoplatform.kudos.notification.plugin.KudosActivityChildPlugin
+ Initial information for Kudos child notification plugin.
+
+
+ templatePath
+
+
+
+ template.gamification.KudosActivity
+ The template of KudosActivityChildPlugin
+
+
+
+ notification.plugins
@@ -166,4 +191,23 @@
+
+ org.exoplatform.social.core.manager.ActivityManager
+
+ NewsActivityTypePlugin
+ addActivityTypePlugin
+ org.exoplatform.kudos.activity.KudosActivityTypePlugin
+
+
+ type
+ exokudos:activity
+
+
+ enableNotification
+ true
+
+
+
+
+
\ No newline at end of file