[AB-298] fixing various issues related to modmail:

fixing editing a message without messages but only embeds not possible in channel service
refactoring closing parameters to use an object instead of parameters always
adding a progress indicator to closing a modmail thread
adding a notification to contact in order to show where the thread was created
fixing configuration for category (this caused the setup to fail, because there was no default value) and threadMessage feature modes not being correct
refactored model for closing header and added additional information
refactored modmail message logging to use the message history instead of individually loading the messages
adding nicer exception in case the mod mail message update failed
adding creation of AUserInAServer in case the user did not interact on the server yet
changed ID of modmail thread to be identical to the channel it was created in, this is so we can load the channel easier
This commit is contained in:
Sheldan
2021-07-04 12:14:04 +02:00
parent 61eefd53c3
commit 18929c9a01
28 changed files with 483 additions and 363 deletions

View File

@@ -281,7 +281,7 @@ public class ChannelServiceBean implements ChannelService {
@Override
public CompletableFuture<Message> editMessageInAChannelFuture(MessageToSend messageToSend, MessageChannel channel, Long messageId) {
MessageAction messageAction;
if(!StringUtils.isBlank(messageToSend.getMessages().get(0))) {
if(!messageToSend.getMessages().isEmpty() && !StringUtils.isBlank(messageToSend.getMessages().get(0))) {
log.debug("Editing message {} with new text content.", messageId);
messageAction = channel.editMessageById(messageId, messageToSend.getMessages().get(0));
if(messageToSend.getEmbeds() != null && !messageToSend.getEmbeds().isEmpty()) {

View File

@@ -205,6 +205,12 @@ public class MessageServiceBean implements MessageService {
return loadMessage(message.getGuild().getIdLong(), message.getChannel().getIdLong(), message.getIdLong());
}
@Override
public CompletableFuture<Message> editMessageWithNewTemplate(Message message, String templateKey, Object model) {
MessageToSend messageToSend = templateService.renderEmbedTemplate(templateKey, model, message.getGuild().getIdLong());
return channelService.editMessageInAChannelFuture(messageToSend, message.getChannel(), message.getIdLong());
}
@Override
public MessageAction editMessage(Message message, MessageEmbed messageEmbed) {
metricService.incrementCounter(MESSAGE_EDIT_METRIC);