Skip to content

Commit bef7807

Browse files
committed
Bugfix with missing unmute/unban record
1 parent d3c5663 commit bef7807

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

application/src/main/java/org/togetherjava/tjbot/commands/moderation/temp/TemporaryModerationRoutine.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.time.Instant;
1515
import java.util.Map;
1616
import java.util.Objects;
17+
import java.util.Optional;
1718
import java.util.concurrent.Executors;
1819
import java.util.concurrent.ScheduledExecutorService;
1920
import java.util.concurrent.TimeUnit;
@@ -86,14 +87,15 @@ private void processGroupedActions(@NotNull RevocationGroupIdentifier groupIdent
8687
// but also if the system automatically revoked a temp-ban already itself
8788
ModerationAction revokeActionType =
8889
getRevocableActionByType(groupIdentifier.type).getRevokeType();
89-
ActionRecord lastRevokeAction = actionsStore
90-
.findLastActionAgainstTargetByType(groupIdentifier.guildId, groupIdentifier.targetId,
91-
revokeActionType)
92-
.orElseThrow();
93-
if (lastRevokeAction.issuedAt().isAfter(lastApplyAction.issuedAt())
94-
&& (lastRevokeAction.actionExpiresAt() == null
95-
|| lastRevokeAction.actionExpiresAt().isAfter(Instant.now()))) {
96-
return;
90+
Optional<ActionRecord> lastRevokeActionOpt = actionsStore.findLastActionAgainstTargetByType(
91+
groupIdentifier.guildId, groupIdentifier.targetId, revokeActionType);
92+
if (lastRevokeActionOpt.isPresent()) {
93+
ActionRecord lastRevokeAction = lastRevokeActionOpt.orElseThrow();
94+
if (lastRevokeAction.issuedAt().isAfter(lastApplyAction.issuedAt())
95+
&& (lastRevokeAction.actionExpiresAt() == null
96+
|| lastRevokeAction.actionExpiresAt().isAfter(Instant.now()))) {
97+
return;
98+
}
9799
}
98100

99101
revokeAction(groupIdentifier);
@@ -102,7 +104,7 @@ private void processGroupedActions(@NotNull RevocationGroupIdentifier groupIdent
102104
private void revokeAction(@NotNull RevocationGroupIdentifier groupIdentifier) {
103105
Guild guild = jda.getGuildById(groupIdentifier.guildId);
104106
if (guild == null) {
105-
logger.info(
107+
logger.debug(
106108
"Attempted to revoke a temporary moderation action but the bot is not connected to the guild '{}' anymore, skipping revoking.",
107109
groupIdentifier.guildId);
108110
return;

0 commit comments

Comments
 (0)