mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-05-14 12:25:28 +00:00
Compare commits
1 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
790cca7278 |
@@ -26,9 +26,11 @@ import dev.sheldan.abstracto.linkembed.service.management.MessageEmbedPostManage
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
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.entities.channel.middleman.GuildMessageChannel;
|
||||||
import net.dv8tion.jda.api.interactions.commands.CommandInteraction;
|
import net.dv8tion.jda.api.interactions.commands.CommandInteraction;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
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.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -191,11 +193,20 @@ public class MessageEmbedServiceBean implements MessageEmbedService {
|
|||||||
.builder()
|
.builder()
|
||||||
.message(embeddedMessage)
|
.message(embeddedMessage)
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messageToSend =
|
Optional<GuildChannel> existingChannel =
|
||||||
templateService.renderEmbedTemplate(MESSAGE_EMBED_CLEANUP_REPLACEMENT_TEMPLATE, model, embeddingMessage.getServerId());
|
channelService.getGuildChannelFromServerOptional(embeddingMessage.getServerId(), embeddingMessage.getChannelId());
|
||||||
return channelService.editMessageInAChannelFuture(messageToSend, embeddingMessage.getServerId(), embeddingMessage.getChannelId(),
|
// if the channel doesnt exist, we dont need to cleanup
|
||||||
embeddingMessage.getMessageId());
|
if(existingChannel.isPresent()) {
|
||||||
}).toList();
|
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) -> {
|
return FutureUtils.toSingleFutureGeneric(editList).whenComplete((unused, throwable) -> {
|
||||||
if(throwable != null) {
|
if(throwable != null) {
|
||||||
log.warn("Failed to cleanup embedded messages..", throwable);
|
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());
|
log.debug("Thread {} is closed - ignoring.", model.getThreadId());
|
||||||
return ModmailThreadActionListenerResult.IGNORED;
|
return ModmailThreadActionListenerResult.IGNORED;
|
||||||
}
|
}
|
||||||
Instant timeStampToConsider = getTimestampToUse(thread);
|
Instant timeStampToConsider = getTimestampToUse(thread, duration);
|
||||||
boolean mustBeReminded = timeInPastDuration.isAfter(timeStampToConsider);
|
boolean mustBeReminded = timeInPastDuration.isAfter(timeStampToConsider);
|
||||||
if (mustBeReminded) {
|
if (mustBeReminded) {
|
||||||
sendReminder(thread)
|
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) {
|
if (thread.getRemindersSnoozedUntil() != null) {
|
||||||
return thread.getRemindersSnoozedUntil();
|
return thread.getRemindersSnoozedUntil().minus(configuredDuration);
|
||||||
}
|
}
|
||||||
return getUpdatedOrCrated(thread);
|
return getUpdatedOrCrated(thread);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user