mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-06 08:25:31 +00:00
added command to completely silently close a mod mail thread (no logging, no notification)
this is part of the mod mai logging feature, because without logging the normal closeSilently behaves the same way by default
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package dev.sheldan.abstracto.modmail.commands;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||
import dev.sheldan.abstracto.core.command.condition.CommandCondition;
|
||||
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.modmail.commands.condition.RequiresModMailCondition;
|
||||
import dev.sheldan.abstracto.modmail.config.ModMailFeatures;
|
||||
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
|
||||
import dev.sheldan.abstracto.modmail.service.ModMailThreadService;
|
||||
import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementService;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class CloseNoLog extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
private RequiresModMailCondition requiresModMailCondition;
|
||||
|
||||
@Autowired
|
||||
private ModMailThreadManagementService modMailThreadManagementService;
|
||||
|
||||
@Autowired
|
||||
private ModMailThreadService modMailThreadService;
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
ModMailThread thread = modMailThreadManagementService.getByChannel(commandContext.getUserInitiatedContext().getChannel());
|
||||
modMailThreadService.closeModMailThread(thread, commandContext.getChannel(), null, false, false);
|
||||
return CommandResult.fromSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("closeNoLog")
|
||||
.module(ModMailModuleInterface.MODMAIL)
|
||||
.help(helpInfo)
|
||||
.templated(true)
|
||||
.causesReaction(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureEnum getFeature() {
|
||||
return ModMailFeatures.MOD_MAIL_LOGGING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommandCondition> getConditions() {
|
||||
List<CommandCondition> conditions = super.getConditions();
|
||||
conditions.add(requiresModMailCondition);
|
||||
return conditions;
|
||||
}
|
||||
}
|
||||
@@ -354,12 +354,17 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
|
||||
|
||||
@Override
|
||||
public synchronized void closeModMailThread(ModMailThread modMailThread, MessageChannel feedBack, String note, Boolean notifyUser) {
|
||||
boolean loggingEnabled = featureFlagService.isFeatureEnabled(modMailLoggingFeature, modMailThread.getServer());
|
||||
closeModMailThread(modMailThread, feedBack, note, notifyUser, loggingEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeModMailThread(ModMailThread modMailThread, MessageChannel feedBack, String note, Boolean notifyUser, Boolean logThread) {
|
||||
Long modMailThreadId = modMailThread.getId();
|
||||
log.info("Starting closing procedure for thread {}", modMailThread.getId());
|
||||
List<ModMailMessage> modMailMessages = modMailThread.getMessages();
|
||||
boolean loggingEnabled = featureFlagService.isFeatureEnabled(modMailLoggingFeature, modMailThread.getServer());
|
||||
List<UndoActionInstance> undoActions = new ArrayList<>();
|
||||
if(loggingEnabled) {
|
||||
if(logThread) {
|
||||
List<CompletableFuture<Message>> messages = modMailMessageService.loadModMailMessages(modMailMessages);
|
||||
log.trace("Loading {} mod mail thread messages.", messages.size());
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
|
||||
@@ -18,4 +18,5 @@ public interface ModMailThreadService {
|
||||
void relayMessageToModMailThread(ModMailThread modMailThread, Message message);
|
||||
void relayMessageToDm(ModMailThread modMailThread, String text, Message message, Boolean anonymous, MessageChannel feedBack);
|
||||
void closeModMailThread(ModMailThread modMailThread, MessageChannel feedBack, String note, Boolean notifyUser);
|
||||
void closeModMailThread(ModMailThread modMailThread, MessageChannel feedBack, String note, Boolean notifyUser, Boolean logThread);
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ Disabling notifications of messages sent by the user::
|
||||
* Description: Removes your subscription from the current thread, and you will no longer be notified when a message from the member arrives.
|
||||
Closing the mod mail thread::
|
||||
* Usage: `close [note]`
|
||||
* Description: Closes the thread, deletes the text channel containing the thread and logs the interactions between the member and the moderators in the `modmailLog` post target.
|
||||
* Description: Closes the thread, deletes the text channel containing the thread and logs the interactions between the member and the moderators in the `modmailLog` post target. (only if `modmail_logging` is enabled)
|
||||
When closing a thread, a closing header with general information will be send and the note will be displayed there.
|
||||
When a thread is closed this way the user is notified of this.
|
||||
Closing the mod mail thread without notifying the user::
|
||||
* Usage: `closeSilently [note]`
|
||||
* Description: Closes the thread, deletes the text channel containing the thread and logs the interactions between the member and the moderators in the `modmailLog` post target.
|
||||
* Description: Closes the thread, deletes the text channel containing the thread and logs the interactions between the member and the moderators in the `modmailLog` post target. (only if `modmail_logging` is enabled)
|
||||
When closing a thread, a closing header with general information will be send and the note will be displayed there.
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
Closes the mod mail thread, which means: logging the messages to mod mail log, deleting the channel the thread was in and notifying the use that the thread was closed.
|
||||
Closes the mod mail thread, which means: logging the messages to mod mail log (if `modmail_logging` is enabled), deleting the channel the thread was in and notifying the use that the thread was closed.
|
||||
@@ -0,0 +1 @@
|
||||
Closes the mod mail thread, does *not* notify the user and does *not* log the thread.
|
||||
@@ -0,0 +1 @@
|
||||
Closes the mod mail thread, which means deleting the channel the thread was in. This command does not notify the user nor does it log the content of the thread.
|
||||
@@ -0,0 +1 @@
|
||||
closeNoLog
|
||||
@@ -1 +1 @@
|
||||
Closes the mod mail thread, which means: logging the messages to mod mail log and deleting the channel the thread was in.
|
||||
Closes the mod mail thread, which means: logging the messages to mod mail log (if `modmail_logging` is enabled) and deleting the channel the thread was in.
|
||||
Reference in New Issue
Block a user