Skip to content

Commit

Permalink
fix: Fix the order of the gamification processor for cancel kudos eve…
Browse files Browse the repository at this point in the history
…n - MEED-7416 (#526)

This PR will fix ix the order of the gamification processor for cancel
kudos event
  • Loading branch information
AzmiTouil authored and exo-swf committed Sep 5, 2024
1 parent aebc78f commit a1fc672
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,7 +45,6 @@
/**
* A listener to add comment or activity
*/
@Asynchronous
@Component
@Profile("gamification")
public class GamificationIntegrationListener extends Listener<KudosService, Kudos> {
Expand All @@ -61,25 +58,24 @@ public void init() {
listenerService.addListener("kudos.cancel.activity", this);
}

@ExoTransactional
@Override
public void onEvent(Event<KudosService, Kudos> event) throws Exception {
public void onEvent(Event<KudosService, Kudos> event) {
Kudos kudos = event.getData();
String eventName = event.getEventName();

saveSendKudosAchievement(kudos, eventName);
saveRecieveKudosAchievement(kudos, eventName);
}

private void saveSendKudosAchievement(Kudos kudos, String eventName) throws Exception {
private void saveSendKudosAchievement(Kudos kudos, String eventName) {
Map<String, String> gam = buildGamificationEventDetails(GAMIFICATION_SEND_KUDOS_EVENT_NAME,
kudos.getSenderId(),
kudos.getReceiverId(),
String.valueOf(kudos.getActivityId()));
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<String, String> gam = buildGamificationEventDetails(GAMIFICATION_RECEIVE_KUDOS_EVENT_NAME,
kudos.getReceiverId(),
kudos.getSenderId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,6 +35,7 @@
import jakarta.annotation.PostConstruct;

@Component
@Order(Ordered.LOWEST_PRECEDENCE)
public class KudosCanceledListener extends Listener<KudosService, Kudos> {

@Autowired
Expand All @@ -47,7 +50,7 @@ public void init() {
}

@Override
public void onEvent(Event<KudosService, Kudos> event) throws Exception {
public void onEvent(Event<KudosService, Kudos> event) {
Kudos kudos = event.getData();
if (kudos != null && kudos.getActivityId() > 0) {
activityManager.deleteActivity(String.valueOf(kudos.getActivityId()));
Expand Down

0 comments on commit a1fc672

Please sign in to comment.