Skip to content

Commit

Permalink
fix: Ensure Kudos sending notification happens after Activity Generat…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Jul 23, 2024
1 parent e579304 commit efd6ad2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import io.meeds.kudos.model.Kudos;
import io.meeds.kudos.service.KudosService;
import io.meeds.kudos.service.utils.Utils;

import jakarta.annotation.PostConstruct;

Expand All @@ -52,7 +53,7 @@ public class KudosSentNotificationListener extends Listener<KudosService, Kudos>

@PostConstruct
public void init() {
listenerService.addListener("exo.kudos.sent", this);
listenerService.addListener(Utils.KUDOS_ACTIVITY_EVENT, this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import org.exoplatform.commons.api.notification.NotificationContext;
import org.exoplatform.commons.api.notification.model.NotificationInfo;
import org.exoplatform.commons.api.notification.plugin.BaseNotificationPlugin;
Expand Down Expand Up @@ -66,13 +68,13 @@ public NotificationInfo makeNotification(NotificationContext ctx) {
}
ActivityManager activityManager = ExoContainerContext.getService(ActivityManager.class);
ExoSocialActivity activity = activityManager.getActivity(String.valueOf(kudos.getActivityId()));
if (activity.isComment()) {
if (activity != null && activity.isComment()) {
activity = activityManager.getActivity(activity.getParentId());
}

return NotificationInfo.instance()
.to(toList)
.setSpaceId(activity == null ? 0l : Long.parseLong(activity.getSpaceId()))
.setSpaceId(activity == null || StringUtils.isBlank(activity.getSpaceId()) ? 0l : Long.parseLong(activity.getSpaceId()))
.with(SocialNotificationUtils.ACTIVITY_ID.getKey(), String.valueOf(kudos.getActivityId()))
.with("ENTITY_ID", kudos.getEntityId())
.with("ENTITY_TYPE", kudos.getEntityType())
Expand Down

0 comments on commit efd6ad2

Please sign in to comment.