[AB-99/AB-66] changed commands to use embeds for exceptions instead of direct messages

added models instead of using HashMaps for exceptions
added a lot of exceptions for different cases
refactored a few commands to be fully async instead of fire and forget
This commit is contained in:
Sheldan
2020-08-29 01:24:06 +02:00
parent fbb36ae9d5
commit 552ecc26b8
285 changed files with 1607 additions and 847 deletions

View File

@@ -54,6 +54,7 @@ public class AnonReply extends AbstractConditionableCommand {
.name("anonReply")
.module(ModMailModuleInterface.MODMAIL)
.parameters(parameters)
.supportsEmbedException(true)
.help(helpInfo)
.templated(true)
.causesReaction(true)

View File

@@ -63,6 +63,7 @@ public class Close extends AbstractConditionableCommand {
.module(ModMailModuleInterface.MODMAIL)
.parameters(parameters)
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -56,6 +56,7 @@ public class CloseNoLog extends AbstractConditionableCommand {
.name("closeNoLog")
.module(ModMailModuleInterface.MODMAIL)
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -58,6 +58,7 @@ public class CloseSilently extends AbstractConditionableCommand {
.module(ModMailModuleInterface.MODMAIL)
.parameters(parameters)
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -8,7 +8,7 @@ import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.command.execution.ContextConverter;
import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
@@ -17,8 +17,6 @@ import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import dev.sheldan.abstracto.modmail.models.template.ModMailThreadExistsModel;
import dev.sheldan.abstracto.modmail.service.ModMailThreadService;
import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementService;
import dev.sheldan.abstracto.templating.model.MessageToSend;
import dev.sheldan.abstracto.templating.service.TemplateService;
import net.dv8tion.jda.api.entities.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -57,7 +55,7 @@ public class Contact extends AbstractConditionableCommand {
model.setExistingModMailThread(existingThread);
channelService.sendEmbedTemplateInChannel("modmail_thread_already_exists", model, commandContext.getChannel());
} else {
FullUser fullUser = FullUser
FullUserInServer fullUser = FullUserInServer
.builder()
.aUserInAServer(user)
.member(targetUser)
@@ -77,6 +75,7 @@ public class Contact extends AbstractConditionableCommand {
.module(ModMailModuleInterface.MODMAIL)
.parameters(parameters)
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -44,6 +44,7 @@ public class RemoveModMailRole extends AbstractConditionableCommand {
.name("removeModMailRole")
.module(ModMailModuleInterface.MODMAIL)
.aliases(aliases)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.templated(true)

View File

@@ -53,6 +53,7 @@ public class Reply extends AbstractConditionableCommand {
.module(ModMailModuleInterface.MODMAIL)
.parameters(parameters)
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -42,6 +42,7 @@ public class SetModMailCategory extends AbstractConditionableCommand {
.name("setModMailCategory")
.module(ModMailModuleInterface.MODMAIL)
.aliases(aliases)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.templated(true)

View File

@@ -44,6 +44,7 @@ public class SetModMailRole extends AbstractConditionableCommand {
.name("setModMailRole")
.module(ModMailModuleInterface.MODMAIL)
.aliases(aliases)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.templated(true)

View File

@@ -15,7 +15,6 @@ import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementS
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@@ -48,8 +47,8 @@ public class Subscribe extends AbstractConditionableCommand {
return CommandConfiguration.builder()
.name("subscribe")
.module(ModMailModuleInterface.MODMAIL)
.parameters(new ArrayList<>())
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -15,7 +15,6 @@ import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementS
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@@ -48,8 +47,8 @@ public class UnSubscribe extends AbstractConditionableCommand {
return CommandConfiguration.builder()
.name("unSubscribe")
.module(ModMailModuleInterface.MODMAIL)
.parameters(new ArrayList<>())
.help(helpInfo)
.supportsEmbedException(true)
.templated(true)
.causesReaction(true)
.build();

View File

@@ -4,6 +4,7 @@ import dev.sheldan.abstracto.core.command.Command;
import dev.sheldan.abstracto.core.command.condition.ConditionResult;
import dev.sheldan.abstracto.core.command.execution.CommandContext;
import dev.sheldan.abstracto.modmail.condition.ModMailContextCondition;
import dev.sheldan.abstracto.modmail.exception.NotInModMailThreadException;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import dev.sheldan.abstracto.modmail.service.management.ModMailThreadManagementService;
import dev.sheldan.abstracto.templating.service.TemplateService;
@@ -29,7 +30,6 @@ public class RequiresModMailCondition implements ModMailContextCondition {
if(thread != null) {
return ConditionResult.builder().result(true).build();
}
String text = templateService.renderSimpleTemplate("modmail_not_in_modmail_thread");
return ConditionResult.builder().result(false).reason(text).build();
throw new NotInModMailThreadException();
}
}

View File

@@ -3,7 +3,6 @@ package dev.sheldan.abstracto.modmail.listener;
import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.listener.PrivateMessageReceivedListener;
import dev.sheldan.abstracto.core.models.database.AUser;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import dev.sheldan.abstracto.core.service.management.UserManagementService;
import dev.sheldan.abstracto.modmail.config.ModMailFeatures;
@@ -16,8 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* This listener is the core mechanic behind mod mail, if the bot receives a message via DM, this listener is executed
* and checks if the message should be forwarded to an existing mod mail thread, or if a new thread should be created/the

View File

@@ -7,7 +7,7 @@ import dev.sheldan.abstracto.core.exception.PostTargetNotFoundException;
import dev.sheldan.abstracto.core.exception.UserInServerNotFoundException;
import dev.sheldan.abstracto.core.models.FeatureValidationResult;
import dev.sheldan.abstracto.core.models.FullGuild;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.core.models.UndoActionInstance;
import dev.sheldan.abstracto.core.models.database.*;
import dev.sheldan.abstracto.core.service.*;
@@ -130,7 +130,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
@Override
public void createModMailThreadForUser(FullUser aUserInAServer, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated) {
public void createModMailThreadForUser(FullUserInServer aUserInAServer, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated) {
Long serverId = aUserInAServer.getAUserInAServer().getServerReference().getId();
Long categoryId = configService.getLongValue(MODMAIL_CATEGORY, serverId);
User user = aUserInAServer.getMember().getUser();
@@ -151,14 +151,14 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
/**
* this method is responsible for creating the instance in the database, sending the header in the newly created text channel and forwarding the initial message
* by the user (if any), after this is complete, this method executes the method to perform the mod mail notification.
* @param aUserInAServer The {@link FullUser} for which a {@link ModMailThread} is being created
* @param aUserInAServer The {@link FullUserInServer} for which a {@link ModMailThread} is being created
* @param initialMessage The {@link Message} which was sent by the user to open a thread, this is null, if the thread was opened via a command
* @param channel The created {@link TextChannel} in which the mod mail thread is dealt with
* @param userInitiated Whether or not the thread was initiated by a member
* @param undoActions The list of actions to undo, in case an exception occurs
*/
@Transactional
public void performModMailThreadSetup(FullUser aUserInAServer, Message initialMessage, TextChannel channel, boolean userInitiated, List<UndoActionInstance> undoActions) {
public void performModMailThreadSetup(FullUserInServer aUserInAServer, Message initialMessage, TextChannel channel, boolean userInitiated, List<UndoActionInstance> undoActions) {
try {
ModMailThread thread = createThreadObject(channel, aUserInAServer);
sendModMailHeader(channel, aUserInAServer, undoActions);
@@ -181,12 +181,12 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
/**
* Sends the message containing the pings to notify the staff members to handle the opened {@link ModMailThread}
* @param aUserInAServer The {@link FullUser} which opened the thread
* @param aUserInAServer The {@link FullUserInServer} which opened the thread
* @param thread The {@link ModMailThread} instance which was created
* @param undoActions The list of {@link UndoActionInstance} to perform, in case an exception occurs
*/
@Transactional
public void sendModMailNotification(FullUser aUserInAServer, ModMailThread thread, List<UndoActionInstance> undoActions) {
public void sendModMailNotification(FullUserInServer aUserInAServer, ModMailThread thread, List<UndoActionInstance> undoActions) {
List<ModMailRole> rolesToPing = modMailRoleManagementService.getRolesForServer(thread.getServer());
ModMailNotificationModel modMailNotificationModel = ModMailNotificationModel
.builder()
@@ -207,10 +207,10 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
/**
* Creates the instance of the {@link ModMailThread} in the database.
* @param channel The {@link TextChannel} in which the {@link ModMailThread} is being done
* @param user The {@link FullUser} which the thread is about
* @param user The {@link FullUserInServer} which the thread is about
* @return The created instance of {@link ModMailThread}
*/
public ModMailThread createThreadObject(TextChannel channel, FullUser user) {
public ModMailThread createThreadObject(TextChannel channel, FullUserInServer user) {
AChannel channel2 = channelManagementService.createChannel(channel.getIdLong(), AChannelType.TEXT, user.getAUserInAServer().getServerReference());
log.info("Creating mod mail thread in channel {} with db channel {}", channel.getIdLong(), channel2.getId());
return modMailThreadManagementService.createModMailThread(user.getAUserInAServer(), channel2);
@@ -265,7 +265,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
.setAction(reactionEmote -> {
AUserInAServer chosenServer = choices.get(reactionEmote.getEmoji());
Member memberInServer = botService.getMemberInServer(chosenServer);
FullUser fullUser = FullUser.builder().member(memberInServer).aUserInAServer(chosenServer).build();
FullUserInServer fullUser = FullUserInServer.builder().member(memberInServer).aUserInAServer(chosenServer).build();
self.createModMailThreadForUser(fullUser, initialMessage, initialMessage.getChannel(), true);
})
.build();
@@ -274,7 +274,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
// if exactly one server is available, open the thread directly
AUserInAServer chosenServer = choices.get(availableGuilds.get(0).getReactionEmote());
Member memberInServer = botService.getMemberInServer(chosenServer);
FullUser fullUser = FullUser.builder().member(memberInServer).aUserInAServer(chosenServer).build();
FullUserInServer fullUser = FullUserInServer.builder().member(memberInServer).aUserInAServer(chosenServer).build();
self.createModMailThreadForUser(fullUser, initialMessage, initialMessage.getChannel(), true);
} else {
// in case there is no server available, send an error message
@@ -293,7 +293,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
* @param aUserInAServer The {@link AUserInAServer} which the {@link ModMailThread} is about
* @param undoActions The list of {@link UndoActionInstance} to execute in case an exception occurs
*/
private void sendModMailHeader(TextChannel channel, FullUser aUserInAServer, List<UndoActionInstance> undoActions) {
private void sendModMailHeader(TextChannel channel, FullUserInServer aUserInAServer, List<UndoActionInstance> undoActions) {
ModMailThread latestThread = modMailThreadManagementService.getLatestModMailThread(aUserInAServer.getAUserInAServer());
List<ModMailThread> oldThreads = modMailThreadManagementService.getModMailThreadForUser(aUserInAServer.getAUserInAServer());
ModMailThreaderHeader header = ModMailThreaderHeader
@@ -320,8 +320,8 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
} else {
// in this case there was no text channel on the server associated with the mod mail thread
// close the existing one, so the user can start a new one
message.getChannel().sendMessage(templateService.renderTemplate("modmail_failed_to_forward_message", new Object())).queue();
self.closeModMailThreadInDb(modMailThread.getId());
message.getChannel().sendMessage(templateService.renderTemplate("modmail_failed_to_forward_message", new Object())).queue();
}
}
@@ -336,16 +336,16 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
*/
public CompletableFuture<Void> sendUserReply(TextChannel textChannel, ModMailThread modMailThread, Message message) {
Long modMailThreadId = modMailThread.getId();
FullUser fullUser = FullUser
FullUserInServer fullUser = FullUserInServer
.builder()
.aUserInAServer(modMailThread.getUser())
.member(botService.getMemberInServer(modMailThread.getUser()))
.build();
List<FullUser> subscribers = new ArrayList<>();
List<FullUserInServer> subscribers = new ArrayList<>();
List<ModMailThreadSubscriber> subscriberList = modMailSubscriberManagementService.getSubscribersForThread(modMailThread);
subscriberList.forEach(modMailThreadSubscriber -> {
FullUser subscriber = FullUser
FullUserInServer subscriber = FullUserInServer
.builder()
.aUserInAServer(modMailThreadSubscriber.getSubscriber())
.member(botService.getMemberInServer(modMailThreadSubscriber.getSubscriber()))
@@ -431,7 +431,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
if(modMailThreadOpt.isPresent()) {
ModMailThread modMailThread = modMailThreadOpt.get();
try {
FullUser fullUser = FullUser
FullUserInServer fullUser = FullUserInServer
.builder()
.aUserInAServer(aUserInAServer)
.member(botService.getMemberInServer(aUserInAServer))
@@ -745,7 +745,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
ModMailThread modMailThread = modMailThreadOpt.get();
AUserInAServer moderator = userInServerManagementService.loadUser(message.getMember());
Member userInGuild = botService.getMemberInServer(modMailThread.getUser());
FullUser fullThreadUser = FullUser
FullUserInServer fullThreadUser = FullUserInServer
.builder()
.aUserInAServer(modMailThread.getUser())
.member(userInGuild)

View File

@@ -9,7 +9,7 @@ import dev.sheldan.abstracto.templating.Templatable;
*/
public class InvalidCategoryException extends AbstractoRunTimeException implements Templatable {
public InvalidCategoryException() {
super("");
super("Invalid category given for setup");
}
@Override

View File

@@ -8,7 +8,7 @@ import dev.sheldan.abstracto.templating.Templatable;
*/
public class AlreadySubscribedException extends AbstractoRunTimeException implements Templatable {
public AlreadySubscribedException() {
super("");
super("Already subscribed to mod mail thread");
}
@Override

View File

@@ -1,12 +1,11 @@
package dev.sheldan.abstracto.modmail.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.modmail.models.exception.ModMailCategoryIdExceptionModel;
import dev.sheldan.abstracto.templating.Templatable;
import lombok.Getter;
import lombok.Setter;
import java.util.HashMap;
/**
* This exception is thrown when a {@link net.dv8tion.jda.api.entities.Member} tries to set the mod mail category
* via a command, and the new value does not qualify as a valid {@link net.dv8tion.jda.api.entities.Category}
@@ -15,22 +14,20 @@ import java.util.HashMap;
@Getter
@Setter
public class ModMailCategoryIdException extends AbstractoRunTimeException implements Templatable {
private Long categoryId;
private final ModMailCategoryIdExceptionModel model;
public ModMailCategoryIdException(Long categoryId) {
super("");
this.categoryId = categoryId;
super("Mod mail category has not been setup");
this.model = ModMailCategoryIdExceptionModel.builder().categoryId(categoryId).build();
}
@Override
public String getTemplateName() {
return "modmail_category_not_setup";
return "modmail_category_not_setup_exception";
}
@Override
public Object getTemplateModel() {
HashMap<String, Long> params = new HashMap<>();
params.put("categoryId", this.categoryId);
return params;
return model;
}
}

View File

@@ -1,32 +1,29 @@
package dev.sheldan.abstracto.modmail.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.modmail.models.template.exception.ModMailThreadNotFoundExceptionModel;
import dev.sheldan.abstracto.templating.Templatable;
import java.util.HashMap;
/**
* This exception is raised, when for some reason the mod mail thread is not found in the database anymore, but the context which is executed stems from a mod mail thread.
* For example if it is attempted to log a thread, without the thread existing in the database.
*/
public class ModMailThreadNotFoundException extends AbstractoRunTimeException implements Templatable {
private final Long modMailThreadId;
private final ModMailThreadNotFoundExceptionModel model;
public ModMailThreadNotFoundException(Long modMailThreadId) {
super("");
this.modMailThreadId = modMailThreadId;
super("Mod mail thread not found");
this.model = ModMailThreadNotFoundExceptionModel.builder().modMailThreadId(modMailThreadId).build();
}
@Override
public String getTemplateName() {
return "modmail_cannot_find_modmail_thread_exception_text";
return "modmail_cannot_find_modmail_thread_exception";
}
@Override
public Object getTemplateModel() {
HashMap<String, Long> params = new HashMap<>();
params.put("id", this.modMailThreadId);
return params;
return model;
}
}

View File

@@ -0,0 +1,21 @@
package dev.sheldan.abstracto.modmail.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.templating.Templatable;
public class NoModMailServerAvailable extends AbstractoRunTimeException implements Templatable {
public NoModMailServerAvailable() {
super("No modmail server available");
}
@Override
public String getTemplateName() {
return "modmail_no_server_available_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,17 @@
package dev.sheldan.abstracto.modmail.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.templating.Templatable;
public class NotInModMailThreadException extends AbstractoRunTimeException implements Templatable {
@Override
public String getTemplateName() {
return "modmail_not_in_modmail_thread_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -8,7 +8,7 @@ import dev.sheldan.abstracto.templating.Templatable;
*/
public class NotSubscribedException extends AbstractoRunTimeException implements Templatable {
public NotSubscribedException() {
super("");
super("Not subscribed to modmail thread");
}
@Override

View File

@@ -0,0 +1,12 @@
package dev.sheldan.abstracto.modmail.models.exception;
import lombok.Builder;
import lombok.Getter;
import java.io.Serializable;
@Getter
@Builder
public class ModMailCategoryIdExceptionModel implements Serializable {
private final Long categoryId;
}

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import lombok.Builder;
import lombok.Getter;
@@ -22,7 +22,7 @@ public class ModMailExceptionModel {
/**
* A user associated with this exception, depends on the exact behaviour of the exception.
*/
private FullUser user;
private FullUserInServer user;
/**
* The exception which was thrown
*/

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailMessage;
import lombok.Builder;
import lombok.Getter;
@@ -24,9 +24,9 @@ public class ModMailLoggedMessageModel {
private ModMailMessage modMailMessage;
/**
* A reference to the {@link FullUser} which is the author. The member part is null, if the member left the guild.
* A reference to the {@link FullUserInServer} which is the author. The member part is null, if the member left the guild.
*/
private FullUser author;
private FullUserInServer author;
}

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import lombok.Builder;
import lombok.Getter;
@@ -16,9 +16,9 @@ import net.dv8tion.jda.api.entities.Message;
@Builder
public class ModMailModeratorReplyModel {
/**
* A {@link FullUser} reference representing the user the thread is about. The member attribute is null, if the user left the guild
* A {@link FullUserInServer} reference representing the user the thread is about. The member attribute is null, if the user left the guild
*/
private FullUser threadUser;
private FullUserInServer threadUser;
/**
* The staff {@link Member} which replied to the thread, be it anonymously or normal.
*/

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.core.models.context.ServerContext;
import dev.sheldan.abstracto.modmail.models.database.ModMailRole;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
@@ -23,9 +23,9 @@ public class ModMailNotificationModel extends ServerContext {
*/
private ModMailThread modMailThread;
/**
* The {@link FullUser} for which this thread is about
* The {@link FullUserInServer} for which this thread is about
*/
private FullUser threadUser;
private FullUserInServer threadUser;
/**
* A list of roles which will be notified upon creation of the mod mail thread.
*/

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import lombok.Builder;
import lombok.Getter;
@@ -15,9 +15,9 @@ import lombok.Setter;
@Builder
public class ModMailThreaderHeader {
/**
* A {@link FullUser} instance to retrieve information from
* A {@link FullUserInServer} instance to retrieve information from
*/
private FullUser threadUser;
private FullUserInServer threadUser;
/**
* The latest {@link ModMailThread}, before the current opened one. This is null if there is no closed mod mail thread
* for the user

View File

@@ -1,6 +1,6 @@
package dev.sheldan.abstracto.modmail.models.template;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
import lombok.Builder;
import lombok.Getter;
@@ -17,9 +17,9 @@ import java.util.List;
@Builder
public class ModMailUserReplyModel {
/**
* The {@link FullUser} from which the message is and whose mod mail thread it is
* The {@link FullUserInServer} from which the message is and whose mod mail thread it is
*/
private FullUser threadUser;
private FullUserInServer threadUser;
/**
* The {@link Message} which was posted, which contains all the possible information
*/
@@ -29,8 +29,8 @@ public class ModMailUserReplyModel {
*/
private ModMailThread modMailThread;
/**
* List of {@link FullUser} which are registered as subscribers for a particular mod mail thread and will be pinged
* List of {@link FullUserInServer} which are registered as subscribers for a particular mod mail thread and will be pinged
* when the user sends a new message
*/
private List<FullUser> subscribers;
private List<FullUserInServer> subscribers;
}

View File

@@ -0,0 +1,13 @@
package dev.sheldan.abstracto.modmail.models.template.exception;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Builder
public class ModMailThreadNotFoundExceptionModel implements Serializable {
private final Long modMailThreadId;
}

View File

@@ -1,8 +1,7 @@
package dev.sheldan.abstracto.modmail.service;
import dev.sheldan.abstracto.core.models.FullUser;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.FullUserInServer;
import dev.sheldan.abstracto.core.models.database.AUser;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
@@ -23,7 +22,7 @@ public interface ModMailThreadService {
* @param feedBackChannel The {@link MessageChannel} in which feedback about exceptions should be posted to
* @param userInitiated Whether or not the mod mail thread was initiated by a user
*/
void createModMailThreadForUser(FullUser userInAServer, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated);
void createModMailThreadForUser(FullUserInServer userInAServer, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated);
/**
* Changes the configuration value of the category used to create mod mail threads to the given ID.