mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-29 15:55:18 +00:00
[AB-xxx] adding modmail thread reminders and auto closing
fixing sending cv2 components to interactions fixing error handling for message embeds
This commit is contained in:
@@ -22,6 +22,8 @@ public class ModMailFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY = "modMailClosingText";
|
||||
public static final String MOD_MAIL_APPEAL_SERVER = "modMailAppealServer";
|
||||
public static final String MOD_MAIL_REMINDER_DURATION = "modMailReminderDuration";
|
||||
public static final String MOD_MAIL_AUTO_CLOSE_DURATION = "modMailAutoCloseDuration";
|
||||
@Autowired
|
||||
private ModMailFeatureValidator modMailFeatureValidator;
|
||||
|
||||
@@ -55,13 +57,18 @@ public class ModMailFeatureConfig implements FeatureConfig {
|
||||
return List.of(ModMailMode.LOGGING,
|
||||
ModMailMode.SEPARATE_MESSAGE,
|
||||
ModMailMode.THREAD_CONTAINER,
|
||||
ModMailMode.MOD_MAIL_APPEALS
|
||||
ModMailMode.MOD_MAIL_APPEALS,
|
||||
ModMailMode.THREAD_AUTO_CLOSE,
|
||||
ModMailMode.THREAD_REMINDER
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return List.of(MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY, MOD_MAIL_APPEAL_SERVER);
|
||||
return List.of(MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY,
|
||||
MOD_MAIL_APPEAL_SERVER,
|
||||
MOD_MAIL_REMINDER_DURATION,
|
||||
MOD_MAIL_AUTO_CLOSE_DURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,8 @@ public enum ModMailMode implements FeatureMode {
|
||||
LOGGING("log"),
|
||||
SEPARATE_MESSAGE("threadMessage"),
|
||||
THREAD_CONTAINER("threadContainer"),
|
||||
THREAD_REMINDER("threadReminder"),
|
||||
THREAD_AUTO_CLOSE("threadAutoClose"),
|
||||
MOD_MAIL_APPEALS("modMailAppeals");
|
||||
|
||||
private final String key;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.sheldan.abstracto.modmail.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.Prioritized;
|
||||
import dev.sheldan.abstracto.core.listener.AbstractoListener;
|
||||
import dev.sheldan.abstracto.core.listener.ListenerExecutionResult;
|
||||
import dev.sheldan.abstracto.modmail.model.listener.ModmailThreadActionListenerModel;
|
||||
|
||||
public interface ModmailThreadActionListener extends
|
||||
AbstractoListener<ModmailThreadActionListenerModel, ModmailThreadActionListener.ModmailThreadActionListenerResult>, Prioritized {
|
||||
|
||||
enum ModmailThreadActionListenerResult implements ListenerExecutionResult {
|
||||
FINAL, IGNORED, PROCESSED
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,9 @@ public class ModMailThread implements Serializable {
|
||||
@Column(name = "closed")
|
||||
private Instant closed;
|
||||
|
||||
@Column(name = "reminders_snoozed_until")
|
||||
private Instant remindersSnoozedUntil;
|
||||
|
||||
@Column(name = "appeal", nullable = false)
|
||||
private Boolean appeal;
|
||||
|
||||
@@ -92,4 +95,8 @@ public class ModMailThread implements Serializable {
|
||||
@Column(name = "state")
|
||||
private ModMailThreadState state;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "previous_state")
|
||||
private ModMailThreadState previousState;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ public enum ModMailThreadState {
|
||||
* Staff member responded to the mod mail thread
|
||||
*/
|
||||
MOD_REPLIED,
|
||||
/**
|
||||
* Staff member paused the thread to not be closed
|
||||
*/
|
||||
PAUSED,
|
||||
/**
|
||||
* The thread was closed by a staff member and the channel was removed
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.sheldan.abstracto.modmail.model.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.ListenerModel;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
import dev.sheldan.abstracto.modmail.model.database.ModMailThreadState;
|
||||
import java.time.Instant;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ModmailThreadActionListenerModel implements ListenerModel {
|
||||
private long threadId;
|
||||
private ServerUser serverUser;
|
||||
private long serverId;
|
||||
private ModMailThreadState state;
|
||||
private Boolean appeal;
|
||||
private Instant created;
|
||||
private Instant updated;
|
||||
private long messageCount;
|
||||
private long subscriberCount;
|
||||
private long channelId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.sheldan.abstracto.modmail.model.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ModmailThreadReminderModel {
|
||||
private List<RoleDisplay> pingRoles;
|
||||
private MemberDisplay memberDisplay;
|
||||
private Instant autoCloseInstant;
|
||||
private boolean paused;
|
||||
private Instant created;
|
||||
private Instant updated;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.modmail.model.ClosingContext;
|
||||
import dev.sheldan.abstracto.modmail.model.database.ModMailThread;
|
||||
import java.time.Duration;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||
@@ -103,6 +104,8 @@ public interface ModMailThreadService {
|
||||
|
||||
boolean isModMailThread(AChannel channel);
|
||||
boolean isModMailThread(Long channelId);
|
||||
void snoozeThreadReminder(ModMailThread thread, Duration snoozeDuration);
|
||||
void setPauseOfThreadTo(ModMailThread thread, boolean paused);
|
||||
|
||||
CompletableFuture<Void> rejectAppeal(ModMailThread modMailThread, String reason, Member memberPerforming);
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ public interface ModMailThreadManagementService {
|
||||
* @return A list of {@link ModMailThread} which contains all the current mod mail threads for the member, should be at most one
|
||||
*/
|
||||
List<ModMailThread> getModMailThreadForUser(AUserInAServer aUserInAServer);
|
||||
List<ModMailThread> getAllOpenThreads();
|
||||
|
||||
/**
|
||||
* Retrieves the *latest* {@link ModMailThread} of the {@link AUserInAServer}, which means, the latest thread which is in the state
|
||||
|
||||
Reference in New Issue
Block a user