From 8f0f356e83cfe39c0fc0fd7bea78d0f75a97f0de Mon Sep 17 00:00:00 2001 From: Azmi TOUIL <42934070+AzmiTouil@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:27:08 +0200 Subject: [PATCH] fix: Fix the order of the gamification processor for cancel kudos even - MEED-7416 (#526) This PR will fix ix the order of the gamification processor for cancel kudos event --- .../listener/GamificationIntegrationListener.java | 10 +++------- .../io/meeds/kudos/listener/KudosCanceledListener.java | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/kudos-services/src/main/java/io/meeds/kudos/listener/GamificationIntegrationListener.java b/kudos-services/src/main/java/io/meeds/kudos/listener/GamificationIntegrationListener.java index cf799dbe0..5bf07b9c4 100644 --- a/kudos-services/src/main/java/io/meeds/kudos/listener/GamificationIntegrationListener.java +++ b/kudos-services/src/main/java/io/meeds/kudos/listener/GamificationIntegrationListener.java @@ -33,8 +33,6 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; -import org.exoplatform.commons.api.persistence.ExoTransactional; -import org.exoplatform.services.listener.Asynchronous; import org.exoplatform.services.listener.Event; import org.exoplatform.services.listener.Listener; import org.exoplatform.services.listener.ListenerService; @@ -47,7 +45,6 @@ /** * A listener to add comment or activity */ -@Asynchronous @Component @Profile("gamification") public class GamificationIntegrationListener extends Listener { @@ -61,9 +58,8 @@ public void init() { listenerService.addListener("kudos.cancel.activity", this); } - @ExoTransactional @Override - public void onEvent(Event event) throws Exception { + public void onEvent(Event event) { Kudos kudos = event.getData(); String eventName = event.getEventName(); @@ -71,7 +67,7 @@ public void onEvent(Event event) throws Exception { saveRecieveKudosAchievement(kudos, eventName); } - private void saveSendKudosAchievement(Kudos kudos, String eventName) throws Exception { + private void saveSendKudosAchievement(Kudos kudos, String eventName) { Map gam = buildGamificationEventDetails(GAMIFICATION_SEND_KUDOS_EVENT_NAME, kudos.getSenderId(), kudos.getReceiverId(), @@ -79,7 +75,7 @@ private void saveSendKudosAchievement(Kudos kudos, String eventName) throws Exce listenerService.broadcast(getGamificationEventName(eventName), gam, String.valueOf(kudos.getTechnicalId())); } - private void saveRecieveKudosAchievement(Kudos kudos, String eventName) throws Exception { + private void saveRecieveKudosAchievement(Kudos kudos, String eventName) { Map gam = buildGamificationEventDetails(GAMIFICATION_RECEIVE_KUDOS_EVENT_NAME, kudos.getReceiverId(), kudos.getSenderId(), diff --git a/kudos-services/src/main/java/io/meeds/kudos/listener/KudosCanceledListener.java b/kudos-services/src/main/java/io/meeds/kudos/listener/KudosCanceledListener.java index cdee060a4..55017448c 100644 --- a/kudos-services/src/main/java/io/meeds/kudos/listener/KudosCanceledListener.java +++ b/kudos-services/src/main/java/io/meeds/kudos/listener/KudosCanceledListener.java @@ -20,6 +20,8 @@ package io.meeds.kudos.listener; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.exoplatform.services.listener.Event; @@ -33,6 +35,7 @@ import jakarta.annotation.PostConstruct; @Component +@Order(Ordered.LOWEST_PRECEDENCE) public class KudosCanceledListener extends Listener { @Autowired @@ -47,7 +50,7 @@ public void init() { } @Override - public void onEvent(Event event) throws Exception { + public void onEvent(Event event) { Kudos kudos = event.getData(); if (kudos != null && kudos.getActivityId() > 0) { activityManager.deleteActivity(String.valueOf(kudos.getActivityId()));