mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-29 15:55:18 +00:00
[AB-xxx] changing duration for reminder snooze, so that it doesnt add the duration _after_ the snooze again, the snooze is intended to be the duration at which the reminders start again
fixing message embed cleanup job not being able to deal with missing channels
This commit is contained in:
@@ -26,9 +26,11 @@ import dev.sheldan.abstracto.linkembed.service.management.MessageEmbedPostManage
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.CommandInteraction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -191,11 +193,20 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
.builder()
|
||||
.message(embeddedMessage)
|
||||
.build();
|
||||
MessageToSend messageToSend =
|
||||
templateService.renderEmbedTemplate(MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE, model, embeddingMessage.getServerId());
|
||||
return channelService.editMessageInAChannelFuture(messageToSend, embeddingMessage.getServerId(), embeddingMessage.getChannelId(),
|
||||
embeddingMessage.getMessageId());
|
||||
}).toList();
|
||||
Optional<GuildChannel> existingChannel =
|
||||
channelService.getGuildChannelFromServerOptional(embeddingMessage.getServerId(), embeddingMessage.getChannelId());
|
||||
// if the channel doesnt exist, we dont need to cleanup
|
||||
if(existingChannel.isPresent()) {
|
||||
MessageToSend messageToSend =
|
||||
templateService.renderEmbedTemplate(MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE, model, embeddingMessage.getServerId());
|
||||
return channelService.editMessageInAChannelFuture(messageToSend, embeddingMessage.getServerId(), embeddingMessage.getChannelId(),
|
||||
embeddingMessage.getMessageId());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
return FutureUtils.toSingleFutureGeneric(editList).whenComplete((unused, throwable) -> {
|
||||
if(throwable != null) {
|
||||
log.warn("Failed to cleanup embedded messages..", throwable);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ModmailReminderListener implements ModmailThreadActionListener {
|
||||
log.debug("Thread {} is closed - ignoring.", model.getThreadId());
|
||||
return ModmailThreadActionListenerResult.IGNORED;
|
||||
}
|
||||
Instant timeStampToConsider = getTimestampToUse(thread);
|
||||
Instant timeStampToConsider = getTimestampToUse(thread, duration);
|
||||
boolean mustBeReminded = timeInPastDuration.isAfter(timeStampToConsider);
|
||||
if (mustBeReminded) {
|
||||
sendReminder(thread)
|
||||
@@ -97,9 +97,9 @@ public class ModmailReminderListener implements ModmailThreadActionListener {
|
||||
}
|
||||
|
||||
|
||||
private static Instant getTimestampToUse(ModMailThread thread) {
|
||||
private static Instant getTimestampToUse(ModMailThread thread, Duration configuredDuration) {
|
||||
if (thread.getRemindersSnoozedUntil() != null) {
|
||||
return thread.getRemindersSnoozedUntil();
|
||||
return thread.getRemindersSnoozedUntil().minus(configuredDuration);
|
||||
}
|
||||
return getUpdatedOrCrated(thread);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user