[AB-98] adding twitch support

upgrading to java 17
upgrade of dependencies
This commit is contained in:
Sheldan
2023-07-06 23:05:51 +02:00
parent 346e462185
commit 6409bbaa1d
167 changed files with 3964 additions and 489 deletions

View File

@@ -123,7 +123,7 @@
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<scope>runtime</scope>
<classifier>jakarta</classifier>
</dependency>
<dependency>

View File

@@ -46,6 +46,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.UnexpectedRollbackException;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
@@ -327,12 +328,10 @@ public class CommandReceivedHandler extends ListenerAdapter {
});
}
@Transactional
public void reportException(CommandContext context, Command foundCommand, Throwable throwable, String s) {
reportException(context.getMessage(), context.getChannel(), context.getAuthor(), foundCommand, throwable, s);
}
@Transactional
public void reportException(Message message, MessageChannel channel, Member member, Command foundCommand, Throwable throwable, String s) {
UserInitiatedServerContext userInitiatedContext = buildUserInitiatedServerContext(member, channel, member.getGuild());
CommandContext.CommandContextBuilder commandContextBuilder = CommandContext.builder()
@@ -349,7 +348,6 @@ public class CommandReceivedHandler extends ListenerAdapter {
self.executePostCommandListener(foundCommand, commandContext, commandResult);
}
@Transactional
public void reportException(MessageReceivedEvent event, Command foundCommand, Throwable throwable, String s) {
reportException(event.getMessage(), event.getChannel(), event.getMember(), foundCommand, throwable, s);
}

View File

@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Nonnull;
@@ -158,7 +159,7 @@ public class SlashCommandListenerBean extends ListenerAdapter {
});
}
@Transactional
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void executePostCommandListener(Command foundCommand, SlashCommandInteractionEvent event, CommandResult result) {
for (PostCommandExecution postCommandExecution : executions) {
postCommandExecution.executeSlash(event, result, foundCommand);

View File

@@ -84,7 +84,9 @@ public class SlashCommandServiceBean implements SlashCommandService {
.findAny();
SubcommandGroupData groupData = commandGroup.orElseGet(() -> new SubcommandGroupData(groupName, description));
groupData.addSubcommands(slashCommand);
rootCommand.addSubcommandGroups(groupData);
if(commandGroup.isEmpty()) {
rootCommand.addSubcommandGroups(groupData);
}
}
List<OptionData> requiredParameters = getParameters(commandConfiguration, isTemplated, internalCommandName, serverId);
slashCommand.addOptions(requiredParameters);

View File

@@ -5,10 +5,10 @@ import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.io.Serializable;
@Entity

View File

@@ -19,7 +19,7 @@ public interface EmoteRepository extends JpaRepository<AEmote, Integer> {
boolean existsByEmoteId(Long emoteId);
boolean existsByEmoteIdAndServerRef(String emoteId, AServer server);
boolean existsByEmoteIdAndServerRef(Long emoteId, AServer server);
@Override
Optional<AEmote> findById(@NonNull Integer aLong);

View File

@@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import javax.persistence.LockModeType;
import jakarta.persistence.LockModeType;
@Repository
public interface LockRepository extends JpaRepository<ALock, Long> {

View File

@@ -355,6 +355,17 @@ public class ChannelServiceBean implements ChannelService {
return messageAction.submit();
}
@Override
public CompletableFuture<Message> editMessageInAChannelFuture(MessageToSend messageToSend, Long serverId, Long channelId, Long messageId) {
Optional<GuildChannel> textChannelFromServer = getGuildChannelFromServerOptional(serverId, channelId);
if(textChannelFromServer.isPresent() && textChannelFromServer.get() instanceof GuildMessageChannel) {
GuildMessageChannel messageChannel = (GuildMessageChannel) textChannelFromServer.get();
return editMessageInAChannelFuture(messageToSend, messageChannel, messageId);
} else {
throw new ChannelNotInGuildException(channelId);
}
}
@Override
public CompletableFuture<Message> editEmbedMessageInAChannel(MessageEmbed embedToSend, MessageChannel channel, Long messageId) {
metricService.incrementCounter(MESSAGE_EDIT_METRIC);

View File

@@ -13,11 +13,11 @@ import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
import net.dv8tion.jda.api.requests.restaction.MessageEditAction;
import net.dv8tion.jda.api.utils.messages.MessageEditData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -87,6 +87,17 @@ public class MessageServiceBean implements MessageService {
return channelService.getMessageChannelFromServer(serverId, channelId).deleteMessageById(messageId).submit();
}
@Override
public CompletableFuture<Void> deleteMessagesInChannelInServer(Long serverId, Long channelId, List<Long> messageId) {
List<String> messageIds = messageId.stream().map(Object::toString).toList();
GuildMessageChannel guildMessageChannel = channelService.getMessageChannelFromServer(serverId, channelId);
if(messageIds.size() == 1) {
return guildMessageChannel.deleteMessageById(messageId.get(0)).submit();
} else {
return guildMessageChannel.deleteMessagesByIds(messageIds).submit();
}
}
@Override
public CompletableFuture<Message> createStatusMessage(MessageToSend messageToSend, AChannel channel) {
return channelService.sendMessageEmbedToSendToAChannel(messageToSend, channel).get(0);

View File

@@ -7,7 +7,7 @@ spring.jpa.properties.hibernate.generate_statistics = false
spring.jpa.properties.hibernate.cache.use_second_level_cache=false
spring.jpa.properties.hibernate.cache.use_query_cache=false
spring.jpa.properties.hibernate.cache.region.factory_class=org.hibernate.cache.jcache.JCacheRegionFactory
spring.jpa.properties.javax.persistence.sharedCache.mode=ENABLE_SELECTIVE
spring.jpa.properties.jakarta.persistence.sharedCache.mode=ENABLE_SELECTIVE
spring.jpa.properties.hibernate.javax.cache.missing_cache_strategy = create
spring.cache.jcache.config=classpath:ehcache.xml