mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-20 13:26:50 +00:00
[AB-242] refactoring suggestions
adding veto and unsuggest command adding support for configuration whether or not a reply mentions the message adding support to reply to a message via template changed default mention config to exclude role mentions
This commit is contained in:
@@ -3,14 +3,14 @@ package dev.sheldan.abstracto.suggestion.exception;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
|
||||
public class SuggestionUpdateException extends AbstractoRunTimeException implements Templatable {
|
||||
public SuggestionUpdateException() {
|
||||
super("Not possible to update suggestion.");
|
||||
public class UnSuggestNotPossibleException extends AbstractoRunTimeException implements Templatable {
|
||||
public UnSuggestNotPossibleException() {
|
||||
super("Not possible to remove suggestion.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "suggestion_update_exception";
|
||||
return "un_suggest_not_possible_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,10 +44,6 @@ public class Suggestion implements Serializable {
|
||||
@JoinColumn(name = "server_id", referencedColumnName = "id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@Getter
|
||||
@Column(name = "suggestion_date")
|
||||
private Instant suggestionDate;
|
||||
|
||||
@Getter
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "state")
|
||||
@@ -59,4 +55,15 @@ public class Suggestion implements Serializable {
|
||||
@Column(name = "updated")
|
||||
private Instant updated;
|
||||
|
||||
@Column(name = "suggestion_text")
|
||||
private String suggestionText;
|
||||
|
||||
@Getter
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "command_channel_id")
|
||||
private AChannel commandChannel;
|
||||
|
||||
@Column(name = "command_message_id")
|
||||
private Long commandMessageId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package dev.sheldan.abstracto.suggestion.model.database;
|
||||
|
||||
public enum SuggestionState {
|
||||
NEW, ACCEPTED, REJECTED
|
||||
NEW, ACCEPTED, REJECTED, VETOED
|
||||
}
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
package dev.sheldan.abstracto.suggestion.model.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.context.UserInitiatedServerContext;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.utils.MessageUtils;
|
||||
import dev.sheldan.abstracto.suggestion.model.database.SuggestionState;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
// TODO change user initiated context so slim context, and remove database entities referenced
|
||||
public class SuggestionLog extends UserInitiatedServerContext {
|
||||
public class SuggestionLog {
|
||||
private Long suggestionId;
|
||||
private SuggestionState state;
|
||||
private Member suggester;
|
||||
private User suggester;
|
||||
private Member member;
|
||||
private AUserInAServer suggesterUser;
|
||||
private String text;
|
||||
private Message message;
|
||||
private String reason;
|
||||
private Long originalMessageId;
|
||||
private Long serverId;
|
||||
private Long originalChannelId;
|
||||
private String originalMessageUrl;
|
||||
private Long originalMessageId;
|
||||
|
||||
public String getOriginalMessageUrl() {
|
||||
return MessageUtils.buildMessageUrl(serverId, originalChannelId , originalMessageId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package dev.sheldan.abstracto.suggestion.service;
|
||||
|
||||
import dev.sheldan.abstracto.suggestion.model.template.SuggestionLog;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface SuggestionService {
|
||||
CompletableFuture<Void> createSuggestionMessage(Member member, String text, SuggestionLog log);
|
||||
CompletableFuture<Void> acceptSuggestion(Long suggestionId, String text, SuggestionLog log);
|
||||
CompletableFuture<Void> rejectSuggestion(Long suggestionId, String text, SuggestionLog log);
|
||||
CompletableFuture<Void> createSuggestionMessage(Message commandMessage, String text);
|
||||
CompletableFuture<Void> acceptSuggestion(Long suggestionId, Message commandMessage, String text);
|
||||
CompletableFuture<Void> vetoSuggestion(Long suggestionId, Message commandMessage, String text);
|
||||
CompletableFuture<Void> rejectSuggestion(Long suggestionId, Message commandMessage, String text);
|
||||
CompletableFuture<Void> removeSuggestion(Long suggestionId, Member member);
|
||||
void cleanUpSuggestions();
|
||||
}
|
||||
|
||||
@@ -6,11 +6,18 @@ import dev.sheldan.abstracto.suggestion.model.database.SuggestionState;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface SuggestionManagementService {
|
||||
Suggestion createSuggestion(Member suggester, String text, Message message, Long suggestionId);
|
||||
Suggestion createSuggestion(AUserInAServer suggester, String text, Message message, Long suggestionId);
|
||||
Optional<Suggestion> getSuggestion(Long suggestionId, Long serverId);
|
||||
Suggestion createSuggestion(Member suggester, String text, Message message, Long suggestionId, Message commandMessage);
|
||||
Suggestion createSuggestion(AUserInAServer suggester, String text, Message message, Long suggestionId, Message commandMessage);
|
||||
Optional<Suggestion> getSuggestionOptional(Long serverId, Long suggestionId);
|
||||
Suggestion getSuggestion(Long serverId, Long suggestionId);
|
||||
void setSuggestionState(Suggestion suggestion, SuggestionState newState);
|
||||
void deleteSuggestion(Long serverId, Long suggestionId);
|
||||
void deleteSuggestion(List<Suggestion> suggestions);
|
||||
void deleteSuggestion(Suggestion suggestion);
|
||||
List<Suggestion> getSuggestionsUpdatedBeforeNotNew(Instant date);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user