mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-27 23:09:05 +00:00
[AB-xx] fixing reaction reports being stored when they should not be
This commit is contained in:
@@ -83,7 +83,7 @@ public class ReactionReportServiceBean implements ReactionReportService {
|
|||||||
Duration maxAge = Duration.of(cooldownSeconds, ChronoUnit.SECONDS);
|
Duration maxAge = Duration.of(cooldownSeconds, ChronoUnit.SECONDS);
|
||||||
Optional<ReactionReport> recentReportOptional = reactionReportManagementService.findRecentReactionReportAboutUser(reportedUser, maxAge);
|
Optional<ReactionReport> recentReportOptional = reactionReportManagementService.findRecentReactionReportAboutUser(reportedUser, maxAge);
|
||||||
boolean singularMessage = featureModeService.featureModeActive(ModerationFeatureDefinition.REPORT_REACTIONS, serverId, ReportReactionMode.SINGULAR_MESSAGE);
|
boolean singularMessage = featureModeService.featureModeActive(ModerationFeatureDefinition.REPORT_REACTIONS, serverId, ReportReactionMode.SINGULAR_MESSAGE);
|
||||||
boolean anonym = featureModeService.featureModeActive(ModerationFeatureDefinition.REPORT_REACTIONS, reporter.getServerId(), ReportReactionMode.ANONYMOUS);
|
boolean anonymous = featureModeService.featureModeActive(ModerationFeatureDefinition.REPORT_REACTIONS, reporter.getServerId(), ReportReactionMode.ANONYMOUS);
|
||||||
if(recentReportOptional.isPresent() && singularMessage) {
|
if(recentReportOptional.isPresent() && singularMessage) {
|
||||||
ReactionReport report = recentReportOptional.get();
|
ReactionReport report = recentReportOptional.get();
|
||||||
log.info("Report is already present in channel {} with message {}. Updating field.", report.getReportChannel().getId(), report.getReportMessageId());
|
log.info("Report is already present in channel {} with message {}. Updating field.", report.getReportChannel().getId(), report.getReportMessageId());
|
||||||
@@ -102,8 +102,12 @@ public class ReactionReportServiceBean implements ReactionReportService {
|
|||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(REACTION_REPORT_TEMPLATE_KEY, model, serverId);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(REACTION_REPORT_TEMPLATE_KEY, model, serverId);
|
||||||
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, ReactionReportPostTarget.REACTION_REPORTS, serverId);
|
List<CompletableFuture<Message>> messageFutures = postTargetService.sendEmbedInPostTarget(messageToSend, ReactionReportPostTarget.REACTION_REPORTS, serverId);
|
||||||
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
return FutureUtils.toSingleFutureGeneric(messageFutures)
|
||||||
.thenAccept(unused -> reportMessageCreatedListenerManager.sendReportMessageCreatedEvent(reportedMessage, messageFutures.get(0).join(), anonym ? null : reporter))
|
.thenAccept(unused -> reportMessageCreatedListenerManager.sendReportMessageCreatedEvent(reportedMessage, messageFutures.get(0).join(), anonymous ? null : reporter))
|
||||||
.thenAccept(unused -> self.createReactionReportInDb(reportedMessage, messageFutures.get(0).join(), reporter));
|
.thenAccept(unused -> {
|
||||||
|
if(!anonymous) {
|
||||||
|
self.createReactionReportInDb(reportedMessage, messageFutures.get(0).join(), reporter);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,13 +124,12 @@ public class ReactionReportServiceBean implements ReactionReportService {
|
|||||||
} else {
|
} else {
|
||||||
log.info("Creation reaction report in message {} about message {} in database.", reportMessage.getIdLong(), cachedMessage.getMessageId());
|
log.info("Creation reaction report in message {} about message {} in database.", reportMessage.getIdLong(), cachedMessage.getMessageId());
|
||||||
reactionReportManagementService.createReactionReport(cachedMessage, reportMessage);
|
reactionReportManagementService.createReactionReport(cachedMessage, reportMessage);
|
||||||
updateModerationUserReportCooldown(reporter);
|
|
||||||
}
|
}
|
||||||
|
updateModerationUserReportCooldown(reporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateModerationUserReportCooldown(ServerUser reporter) {
|
public void updateModerationUserReportCooldown(ServerUser reporter) {
|
||||||
if(!featureModeService.featureModeActive(ModerationFeatureDefinition.REPORT_REACTIONS, reporter.getServerId(), ReportReactionMode.ANONYMOUS)) {
|
|
||||||
AUserInAServer reporterAUserInServer = userInServerManagementService.loadOrCreateUser(reporter);
|
AUserInAServer reporterAUserInServer = userInServerManagementService.loadOrCreateUser(reporter);
|
||||||
Optional<ModerationUser> optionalModerationUser = moderationUserManagementService.findModerationUser(reporterAUserInServer);
|
Optional<ModerationUser> optionalModerationUser = moderationUserManagementService.findModerationUser(reporterAUserInServer);
|
||||||
Instant reportTimeStamp = Instant.now();
|
Instant reportTimeStamp = Instant.now();
|
||||||
@@ -138,7 +141,6 @@ public class ReactionReportServiceBean implements ReactionReportService {
|
|||||||
moderationUserManagementService.createModerationUserWithReportTimeStamp(reporterAUserInServer, reportTimeStamp);
|
moderationUserManagementService.createModerationUserWithReportTimeStamp(reporterAUserInServer, reportTimeStamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowedToReport(ServerUser reporter) {
|
public boolean allowedToReport(ServerUser reporter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user