mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 12:10:21 +00:00
[AB-139] changing the places at which there might be an uncached member object
fixing integer validator fixing syncing roles not working if the role did not change in the database fixing warn id being flipped fixing star stats model
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package dev.sheldan.abstracto.modmail.models.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class LoadedModmailThreadMessage {
|
||||
private CompletableFuture<Message> messageFuture;
|
||||
private CompletableFuture<Member> memberFuture;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.sheldan.abstracto.modmail.models.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class LoadedModmailThreadMessageList {
|
||||
private List<LoadedModmailThreadMessage> messageList;
|
||||
public List<CompletableFuture> getAllFutures() {
|
||||
List<CompletableFuture> futures = new ArrayList<>();
|
||||
messageList.forEach(loadedModmailThreadMessage -> {
|
||||
futures.add(loadedModmailThreadMessage.getMemberFuture());
|
||||
futures.add(loadedModmailThreadMessage.getMessageFuture());
|
||||
});
|
||||
return futures;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import dev.sheldan.abstracto.modmail.models.database.ModMailMessage;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ public class ModMailLoggedMessageModel {
|
||||
/**
|
||||
* A reference to the {@link FullUserInServer} which is the author. The member part is null, if the member left the guild.
|
||||
*/
|
||||
private FullUserInServer author;
|
||||
private Member author;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,7 +26,7 @@ public class ModMailNotificationModel extends ServerContext {
|
||||
/**
|
||||
* The {@link FullUserInServer} for which this thread is about
|
||||
*/
|
||||
private FullUserInServer threadUser;
|
||||
private Member member;
|
||||
/**
|
||||
* A list of roles which will be notified upon creation of the mod mail thread.
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.modmail.models.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
/**
|
||||
* This is the model used when a new mod mail thread is opened and a message containing some information about the user
|
||||
@@ -15,9 +15,9 @@ import lombok.Setter;
|
||||
@Builder
|
||||
public class ModMailThreaderHeader {
|
||||
/**
|
||||
* A {@link FullUserInServer} instance to retrieve information from
|
||||
* A {@link Member} instance to retrieve information from
|
||||
*/
|
||||
private FullUserInServer threadUser;
|
||||
private Member member;
|
||||
/**
|
||||
* The latest {@link ModMailThread}, before the current opened one. This is null if there is no closed mod mail thread
|
||||
* for the user
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.modmail.models.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,17 +17,13 @@ import java.util.List;
|
||||
@Builder
|
||||
public class ModMailUserReplyModel {
|
||||
/**
|
||||
* The {@link FullUserInServer} from which the message is and whose mod mail thread it is
|
||||
* The {@link Member} from which the message is and whose mod mail thread it is
|
||||
*/
|
||||
private FullUserInServer threadUser;
|
||||
private Member member;
|
||||
/**
|
||||
* The {@link Message} which was posted, which contains all the possible information
|
||||
*/
|
||||
private Message postedMessage;
|
||||
/**
|
||||
* The {@link ModMailThread} for which the {@link Message} was a reply for
|
||||
*/
|
||||
private ModMailThread modMailThread;
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package dev.sheldan.abstracto.modmail.service;
|
||||
|
||||
import dev.sheldan.abstracto.modmail.models.database.ModMailMessage;
|
||||
import dev.sheldan.abstracto.modmail.models.dto.LoadedModmailThreadMessageList;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Service to handle the messages of a {@link dev.sheldan.abstracto.modmail.models.database.ModMailThread}
|
||||
@@ -13,7 +13,7 @@ public interface ModMailMessageService {
|
||||
/**
|
||||
* Loads the given mod mail messages in the form of {@link Message} from Discord and returns the created promises, some of which might fail, if the message was already deleted
|
||||
* @param modMailMessages The list of {@link ModMailMessage} to load
|
||||
* @return A list of futures which contain the individual results of actively loading the {@link Message}
|
||||
* @return A instance of {@link LoadedModmailThreadMessageList} which contain the individual results of actively loading the {@link Message} and the {@link net.dv8tion.jda.api.entities.Member}
|
||||
*/
|
||||
List<CompletableFuture<Message>> loadModMailMessages(List<ModMailMessage> modMailMessages);
|
||||
LoadedModmailThreadMessageList loadModMailMessages(List<ModMailMessage> modMailMessages);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package dev.sheldan.abstracto.modmail.service;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.core.models.FullUserInServer;
|
||||
import dev.sheldan.abstracto.core.models.UndoActionInstance;
|
||||
import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.modmail.models.database.ModMailThread;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
|
||||
@@ -21,12 +21,12 @@ public interface ModMailThreadService {
|
||||
* Creates a new mod mail thread for the given user. including: the {@link net.dv8tion.jda.api.entities.TextChannel}
|
||||
* in the appropriate {@link net.dv8tion.jda.api.entities.Category} and calls the methods responsible for storing
|
||||
* the necessary data in the database, notifying the users and sending messages related to the creation of the {@link ModMailThread}
|
||||
* @param userInAServer The {@link AUserInAServer} to create the mod mail thread for
|
||||
* @param member The {@link AUserInAServer} to create the mod mail thread for
|
||||
* @param initialMessage The initial message sparking this mod mail thread, null in case it was created by a command
|
||||
* @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
|
||||
*/
|
||||
CompletableFuture<Void> createModMailThreadForUser(FullUserInServer userInAServer, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated, List<UndoActionInstance> undoActions);
|
||||
CompletableFuture<Void> createModMailThreadForUser(Member member, Message initialMessage, MessageChannel feedBackChannel, boolean userInitiated, List<UndoActionInstance> undoActions);
|
||||
|
||||
/**
|
||||
* Changes the configuration value of the category used to create mod mail threads to the given ID.
|
||||
@@ -52,18 +52,20 @@ public interface ModMailThreadService {
|
||||
* @param modMailThread The {@link ModMailThread} on which the user answered
|
||||
* @param message The {@link Message} object which was sent by the user to answer with
|
||||
*/
|
||||
CompletableFuture<Void> relayMessageToModMailThread(ModMailThread modMailThread, Message message, List<UndoActionInstance> undoActions);
|
||||
CompletableFuture<Message> relayMessageToModMailThread(ModMailThread modMailThread, Message message, List<UndoActionInstance> undoActions);
|
||||
|
||||
/**
|
||||
* Forwards a message send by a moderator to the direct message channel opened with the user. If the message is
|
||||
* marked as anonymous, the bot will take the place of the author, in other case the author is shown in the embed.
|
||||
* @param modMailThread The {@link ModMailThread} to which the reply was sent to
|
||||
* @param threadId The id of the {@link ModMailThread} to which the reply was sent to
|
||||
* @param text The parsed text of the reply
|
||||
* @param message The pure {@link Message} containing the command which caused the reply
|
||||
* @param anonymous Whether or nor the message should be send anonymous
|
||||
* @param feedBack The {@link MessageChannel} in which feedback about possible exceptions should be sent to
|
||||
* @param undoActions list of {@link UndoActionInstance} to execute in case this fails
|
||||
* @param targetMember The {@link Member} the {@link ModMailThread} is about.
|
||||
*/
|
||||
CompletableFuture<Void> relayMessageToDm(ModMailThread modMailThread, String text, Message message, boolean anonymous, MessageChannel feedBack, List<UndoActionInstance> undoActions);
|
||||
CompletableFuture<Void> relayMessageToDm(Long threadId, String text, Message message, boolean anonymous, MessageChannel feedBack, List<UndoActionInstance> undoActions, Member targetMember);
|
||||
|
||||
/**
|
||||
* Closes the mod mail thread which means: deletes the {@link net.dv8tion.jda.api.entities.TextChannel} associated with the mod mail thread,
|
||||
|
||||
@@ -29,7 +29,14 @@ public interface ModMailThreadManagementService {
|
||||
* @param modMailThreadId The ID of the mod mail to search for
|
||||
* @return An {@link Optional} containing the mod mail thread or empty
|
||||
*/
|
||||
Optional<ModMailThread> getById(Long modMailThreadId);
|
||||
Optional<ModMailThread> getByIdOptional(Long modMailThreadId);
|
||||
|
||||
/**
|
||||
* Retrieves the {@link ModMailThread} by the given ID in an optional, if it exists, and an {@literal Optional#empty()} otherwise
|
||||
* @param modMailThreadId The ID of the mod mail to search for
|
||||
* @return An {@link Optional} containing the mod mail thread or empty
|
||||
*/
|
||||
ModMailThread getById(Long modMailThreadId);
|
||||
|
||||
/**
|
||||
* Retrieves a {@link ModMailThread} found in the {@link net.dv8tion.jda.api.entities.MessageChannel} given by the
|
||||
|
||||
Reference in New Issue
Block a user