mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-22 17:45:48 +00:00
Compare commits
16 Commits
v1.5.37
...
2024080220
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3545c4af0 | ||
|
|
fa187f8817 | ||
|
|
c39b7ebeec | ||
|
|
5cbad801ff | ||
|
|
826bee1f81 | ||
|
|
99bf9a9be0 | ||
|
|
5b5e4973a7 | ||
|
|
65e956827c | ||
|
|
b258a8bc54 | ||
|
|
9864b7d875 | ||
|
|
27466b7333 | ||
|
|
bfb8969d1f | ||
|
|
0097ff801a | ||
|
|
b6a188c04d | ||
|
|
2fa1adde02 | ||
|
|
cb8b64cc01 |
2
.env
2
.env
@@ -1,2 +1,2 @@
|
|||||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||||
VERSION=1.5.36
|
VERSION=1.5.39
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>assignable-roles-int</artifactId>
|
<artifactId>assignable-roles-int</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>entertainment</artifactId>
|
<artifactId>entertainment</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>entertainment</artifactId>
|
<artifactId>entertainment</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>experience-tracking</artifactId>
|
<artifactId>experience-tracking</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class AddMemberToChannelLevelAction implements LevelActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(AUserExperience aUserExperience, LevelAction levelAction) {
|
public boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction) {
|
||||||
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class AddRoleLevelAction implements LevelActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(AUserExperience aUserExperience, LevelAction levelAction) {
|
public boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction) {
|
||||||
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class RemoveMemberFromChannelLevelAction implements LevelActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(AUserExperience aUserExperience, LevelAction levelAction) {
|
public boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction) {
|
||||||
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class RemoveRoleLevelAction implements LevelActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(AUserExperience aUserExperience, LevelAction levelAction) {
|
public boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction) {
|
||||||
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package dev.sheldan.abstracto.experience.listener;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import dev.sheldan.abstracto.core.exception.InputFormatException;
|
||||||
|
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
|
import dev.sheldan.abstracto.core.service.MemberService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
|
import dev.sheldan.abstracto.core.utils.ParseUtils;
|
||||||
|
import dev.sheldan.abstracto.experience.model.LevelActionPayload;
|
||||||
|
import dev.sheldan.abstracto.experience.model.SendMessageToChannelLevelActionMessageModel;
|
||||||
|
import dev.sheldan.abstracto.experience.model.SendMessageToChannelLevelActionPayload;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.LevelAction;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class SendMessageToChannelLevelAction implements LevelActionListener {
|
||||||
|
|
||||||
|
public static final String ACTION_NAME = "send_message_to_channel_above_level";
|
||||||
|
private static final String LEVEL_ACTION_SEND_MESSAGE_TEMPLATE_KEY = "levelAction_sendMessageToChannel_template";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Gson gson;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return ACTION_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(AUserExperience userExperience, LevelAction levelAction, MemberActionModification container) {
|
||||||
|
SendMessageToChannelLevelActionPayload payload = (SendMessageToChannelLevelActionPayload) levelAction.getLoadedPayload();
|
||||||
|
SendMessageToChannelLevelActionMessageModel.SendMessageToChannelLevelActionMessageModelBuilder messageModelBuilder = SendMessageToChannelLevelActionMessageModel
|
||||||
|
.builder()
|
||||||
|
.level(userExperience.getLevelOrDefault())
|
||||||
|
.templateKey(payload.getTemplateKey())
|
||||||
|
.experience(userExperience.getExperience());
|
||||||
|
ServerUser serverUser = ServerUser.fromAUserInAServer(userExperience.getUser());
|
||||||
|
memberService.getMemberInServerAsync(serverUser).thenAccept(member -> {
|
||||||
|
messageModelBuilder.memberDisplay(MemberDisplay.fromMember(member));
|
||||||
|
SendMessageToChannelLevelActionMessageModel model = messageModelBuilder.build();
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(LEVEL_ACTION_SEND_MESSAGE_TEMPLATE_KEY, model, serverUser.getServerId());
|
||||||
|
GuildMessageChannel targetChannel = channelService.getMessageChannelFromServer(serverUser.getServerId(), payload.getChannelId());
|
||||||
|
FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, targetChannel)).thenAccept(unused -> {
|
||||||
|
log.info("Send message to channel action sent a message to channel {} for user {} in server {}.", payload.getChannelId(), serverUser.getUserId(), serverUser.getServerId());
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.warn("Send message to channel action failed to send a message to channel {} for user {} in server {}.", payload.getChannelId(), serverUser.getUserId(), serverUser.getServerId(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.warn("Failed to load member {} in server {} for send message level action towards channel {}.", serverUser.getUserId(), serverUser.getServerId(), payload.getChannelId());
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction) {
|
||||||
|
if(!oldLevel.equals(aUserExperience.getLevelOrDefault())) { // this means the user changed level now, this is the path from gaining a lot of experience
|
||||||
|
boolean jumpedLevelToMatch = oldLevel < levelAction.getLevel().getLevel() && aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
|
// this boolean means that the user did NOT have the action earlier, but does now (and more than that)
|
||||||
|
return jumpedLevelToMatch || aUserExperience.getLevelOrDefault().equals(levelAction.getLevel().getLevel()); // or the user matches the level _exactly_, this is the path from normally gaining experience
|
||||||
|
} else {
|
||||||
|
// This case is useful for re-joining, because this means, that the user did _not_ change level, and already is somewhere way above
|
||||||
|
return aUserExperience.getLevelOrDefault() >= levelAction.getLevel().getLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void prepareAction(LevelAction levelAction) {
|
||||||
|
levelAction.setLoadedPayload(gson.fromJson(levelAction.getPayload(), SendMessageToChannelLevelActionPayload.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LevelActionPayload createPayload(Guild guild, String input) {
|
||||||
|
if(!input.contains(";")) {
|
||||||
|
throw new InputFormatException(input, "<#channel>;template_key");
|
||||||
|
}
|
||||||
|
String channelPart = input.substring(0, input.indexOf(";"));
|
||||||
|
GuildChannel channel = ParseUtils.parseGuildChannelFromText(channelPart, guild);
|
||||||
|
String templateKey = input.substring(input.indexOf(";") + 1);
|
||||||
|
return SendMessageToChannelLevelActionPayload
|
||||||
|
.builder()
|
||||||
|
.channelId(channel.getIdLong())
|
||||||
|
.templateKey(templateKey)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.sheldan.abstracto.experience.model;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class SendMessageToChannelLevelActionMessageModel implements LevelActionPayload {
|
||||||
|
private MemberDisplay memberDisplay;
|
||||||
|
private Integer level;
|
||||||
|
private Long experience;
|
||||||
|
private String templateKey;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.sheldan.abstracto.experience.model;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class SendMessageToChannelLevelActionPayload implements LevelActionPayload {
|
||||||
|
private Long channelId;
|
||||||
|
private String templateKey;
|
||||||
|
}
|
||||||
@@ -337,8 +337,8 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
|||||||
.builder()
|
.builder()
|
||||||
.build();
|
.build();
|
||||||
boolean userChangesLevel = !Objects.equals(newLevel.getLevel(), aUserExperience.getCurrentLevel().getLevel());
|
boolean userChangesLevel = !Objects.equals(newLevel.getLevel(), aUserExperience.getCurrentLevel().getLevel());
|
||||||
|
Integer oldLevel = aUserExperience.getCurrentLevel() != null ? aUserExperience.getCurrentLevel().getLevel() : 0;
|
||||||
if(userChangesLevel) {
|
if(userChangesLevel) {
|
||||||
Integer oldLevel = aUserExperience.getCurrentLevel() != null ? aUserExperience.getCurrentLevel().getLevel() : 0;
|
|
||||||
log.info("User {} in server {} changed level. New {}, Old {}.", member.getIdLong(),
|
log.info("User {} in server {} changed level. New {}, Old {}.", member.getIdLong(),
|
||||||
member.getGuild().getIdLong(), newLevel.getLevel(),
|
member.getGuild().getIdLong(), newLevel.getLevel(),
|
||||||
oldLevel);
|
oldLevel);
|
||||||
@@ -373,7 +373,7 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
|||||||
}
|
}
|
||||||
aUserExperience.setMessageCount(aUserExperience.getMessageCount() + 1L);
|
aUserExperience.setMessageCount(aUserExperience.getMessageCount() + 1L);
|
||||||
if(userChangesLevel && featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, server, ExperienceFeatureMode.LEVEL_ACTION)) {
|
if(userChangesLevel && featureModeService.featureModeActive(ExperienceFeatureDefinition.EXPERIENCE, server, ExperienceFeatureMode.LEVEL_ACTION)) {
|
||||||
levelActionService.applyLevelActionsToUser(aUserExperience)
|
levelActionService.applyLevelActionsToUser(aUserExperience, oldLevel)
|
||||||
.thenAccept(unused -> {
|
.thenAccept(unused -> {
|
||||||
log.info("Executed level actions for user {}.", userInServerId);
|
log.info("Executed level actions for user {}.", userInServerId);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ public class LevelActionServiceBean implements LevelActionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user) {
|
public CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user) {
|
||||||
|
return applyLevelActionsToUser(user, user.getLevelOrDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user, Integer oldLevel) {
|
||||||
if(levelActions == null || levelActions.isEmpty()) {
|
if(levelActions == null || levelActions.isEmpty()) {
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
@@ -60,8 +65,16 @@ public class LevelActionServiceBean implements LevelActionService {
|
|||||||
|
|
||||||
Map<Integer, List<LevelAction>> actionConfigMap = new HashMap<>();
|
Map<Integer, List<LevelAction>> actionConfigMap = new HashMap<>();
|
||||||
|
|
||||||
|
Map<String, LevelActionListener> actionStringListenerMap = levelActions
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(a -> a.getName().toLowerCase(), Function.identity()));
|
||||||
|
|
||||||
levelActionsOfUserInServer.forEach(levelAction -> {
|
levelActionsOfUserInServer.forEach(levelAction -> {
|
||||||
if(levelAction.getLevel().getLevel() > user.getLevelOrDefault()) {
|
LevelActionListener listener = actionStringListenerMap.get(levelAction.getAction());
|
||||||
|
if(listener == null) { // if for some reason the config is still in the database, but we don't have code for it anymore
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!listener.shouldExecute(user, oldLevel, levelAction)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(actionConfigMap.containsKey(levelAction.getLevel().getLevel())) {
|
if(actionConfigMap.containsKey(levelAction.getLevel().getLevel())) {
|
||||||
@@ -73,9 +86,6 @@ public class LevelActionServiceBean implements LevelActionService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, LevelActionListener> actionStringListenerMap = levelActions
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toMap(a -> a.getName().toLowerCase(), Function.identity()));
|
|
||||||
|
|
||||||
List<Integer> levels = actionConfigMap
|
List<Integer> levels = actionConfigMap
|
||||||
.keySet()
|
.keySet()
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package dev.sheldan.abstracto.experience.listener;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.AExperienceLevel;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.LevelAction;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class AddRoleLevelActionTest {
|
||||||
|
@InjectMocks
|
||||||
|
private AddRoleLevelAction action;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AUserExperience exp;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private LevelAction levelAction;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AExperienceLevel level;
|
||||||
|
|
||||||
|
private final Integer LOW_LEVEL = 1;
|
||||||
|
private final Integer MID_LEVEL = 2;
|
||||||
|
private final Integer HIGH_LEVEL = 3;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
when(levelAction.getLevel()).thenReturn(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // rejoin too low case
|
||||||
|
public void noLevelChangeActionNotReached() {
|
||||||
|
executeTest(LOW_LEVEL, LOW_LEVEL, HIGH_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // re-join exact case
|
||||||
|
public void noLevelChangeActionReached() {
|
||||||
|
executeTest(LOW_LEVEL, LOW_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // normal leveling, higher action
|
||||||
|
public void levelChangeActionNotReached() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, HIGH_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // normal leveling
|
||||||
|
public void levelChangeActionReached() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, MID_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // a case for this is a large experience jump
|
||||||
|
public void levelChangeActionOverJumped() {
|
||||||
|
executeTest(LOW_LEVEL, HIGH_LEVEL, MID_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // a case for this is a re-join
|
||||||
|
public void noLevelChangeActionOverJumped() {
|
||||||
|
executeTest(HIGH_LEVEL, HIGH_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // we dont want to re-execute previous actions (previous = lower level)
|
||||||
|
public void levelChangeActionEqualsPrevious() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // we dont want to re-execute previous actions (previous = way lower level)
|
||||||
|
public void levelChangeActionBelow() {
|
||||||
|
executeTest(MID_LEVEL, HIGH_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeTest(Integer oldLevel, Integer currentLevel, Integer actionLevel, boolean expected) {
|
||||||
|
when(exp.getLevelOrDefault()).thenReturn(currentLevel);
|
||||||
|
when(level.getLevel()).thenReturn(actionLevel);
|
||||||
|
Assertions.assertThat(action.shouldExecute(exp, oldLevel, levelAction)).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package dev.sheldan.abstracto.experience.listener;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.AExperienceLevel;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
||||||
|
import dev.sheldan.abstracto.experience.model.database.LevelAction;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
|
public class RemoveMemberFromChannelLevelActionTest {
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private SendMessageToChannelLevelAction action;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AUserExperience exp;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private LevelAction levelAction;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AExperienceLevel level;
|
||||||
|
|
||||||
|
private final Integer LOW_LEVEL = 1;
|
||||||
|
private final Integer MID_LEVEL = 2;
|
||||||
|
private final Integer HIGH_LEVEL = 3;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
when(levelAction.getLevel()).thenReturn(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // rejoin too low case
|
||||||
|
public void noLevelChangeActionNotReached() {
|
||||||
|
executeTest(LOW_LEVEL, LOW_LEVEL, HIGH_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // re-join exact case
|
||||||
|
public void noLevelChangeActionReached() {
|
||||||
|
executeTest(LOW_LEVEL, LOW_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // normal leveling, higher action
|
||||||
|
public void levelChangeActionNotReached() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, HIGH_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // normal leveling
|
||||||
|
public void levelChangeActionReached() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, MID_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // a case for this is a large experience jump
|
||||||
|
public void levelChangeActionOverJumped() {
|
||||||
|
executeTest(LOW_LEVEL, HIGH_LEVEL, MID_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // a case for this is a re-join
|
||||||
|
public void noLevelChangeActionOverJumped() {
|
||||||
|
executeTest(HIGH_LEVEL, HIGH_LEVEL, LOW_LEVEL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // we dont want to re-execute previous actions (previous = lower level)
|
||||||
|
public void levelChangeActionEqualsPrevious() {
|
||||||
|
executeTest(LOW_LEVEL, MID_LEVEL, LOW_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // we dont want to re-execute previous actions (previous = way lower level)
|
||||||
|
public void levelChangeActionBelow() {
|
||||||
|
executeTest(MID_LEVEL, HIGH_LEVEL, LOW_LEVEL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeTest(Integer oldLevel, Integer currentLevel, Integer actionLevel, boolean expected) {
|
||||||
|
when(exp.getLevelOrDefault()).thenReturn(currentLevel);
|
||||||
|
when(level.getLevel()).thenReturn(actionLevel);
|
||||||
|
Assertions.assertThat(action.shouldExecute(exp, oldLevel, levelAction)).isEqualTo(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>experience-tracking</artifactId>
|
<artifactId>experience-tracking</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ import dev.sheldan.abstracto.experience.model.LevelActionPayload;
|
|||||||
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
import dev.sheldan.abstracto.experience.model.database.AUserExperience;
|
||||||
import dev.sheldan.abstracto.experience.model.database.LevelAction;
|
import dev.sheldan.abstracto.experience.model.database.LevelAction;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public interface LevelActionListener {
|
public interface LevelActionListener {
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
void apply(AUserExperience userExperience, LevelAction levelAction, MemberActionModification container);
|
void apply(AUserExperience userExperience, LevelAction levelAction, MemberActionModification container);
|
||||||
|
|
||||||
boolean shouldExecute(AUserExperience aUserExperience, LevelAction levelAction);
|
boolean shouldExecute(AUserExperience aUserExperience, Integer oldLevel, LevelAction levelAction);
|
||||||
|
|
||||||
void prepareAction(LevelAction levelAction);
|
void prepareAction(LevelAction levelAction);
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
|
|
||||||
public interface LevelActionService {
|
public interface LevelActionService {
|
||||||
CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user);
|
CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user);
|
||||||
|
CompletableFuture<Void> applyLevelActionsToUser(AUserExperience user, Integer oldLevel);
|
||||||
List<String> getAvailableLevelActions();
|
List<String> getAvailableLevelActions();
|
||||||
Optional<LevelActionListener> getLevelActionListenerForName(String name);
|
Optional<LevelActionListener> getLevelActionListenerForName(String name);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-impl</artifactId>
|
<artifactId>giveaway-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway-int</artifactId>
|
<artifactId>giveaway-int</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>giveaway</artifactId>
|
<artifactId>giveaway</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-impl</artifactId>
|
<artifactId>image-generation-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation-int</artifactId>
|
<artifactId>image-generation-int</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>image-generation</artifactId>
|
<artifactId>image-generation</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>invite-filter</artifactId>
|
<artifactId>invite-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>invite-filter</artifactId>
|
<artifactId>invite-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation-int</artifactId>
|
<artifactId>moderation-int</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>link-embed</artifactId>
|
<artifactId>link-embed</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>link-embed</artifactId>
|
<artifactId>link-embed</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>logging</artifactId>
|
<artifactId>logging</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>logging</artifactId>
|
<artifactId>logging</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation</artifactId>
|
<artifactId>moderation</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>moderation</artifactId>
|
<artifactId>moderation</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>modmail</artifactId>
|
<artifactId>modmail</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class Contact extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
User user = slashCommandParameterService.getCommandOption(USER_PARMETER, event, User.class);
|
User user = slashCommandParameterService.getCommandOption(USER_PARMETER, event, User.class);
|
||||||
AUserInAServer userInAServer = userManagementService.loadOrCreateUser(user.getIdLong(), event.getGuild().getIdLong());
|
AUserInAServer userInAServer = userManagementService.loadOrCreateUser(event.getGuild().getIdLong(), user.getIdLong());
|
||||||
// if this AUserInAServer already has an open thread, we should instead post a message
|
// if this AUserInAServer already has an open thread, we should instead post a message
|
||||||
// containing a link to the channel, instead of opening a new one
|
// containing a link to the channel, instead of opening a new one
|
||||||
if(modMailThreadManagementService.hasOpenModMailThreadForUser(userInAServer)) {
|
if(modMailThreadManagementService.hasOpenModMailThreadForUser(userInAServer)) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>modmail</artifactId>
|
<artifactId>modmail</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto</groupId>
|
<groupId>dev.sheldan.abstracto</groupId>
|
||||||
<artifactId>abstracto-application</artifactId>
|
<artifactId>abstracto-application</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>profanity-filter</artifactId>
|
<artifactId>profanity-filter</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>profanity-filter</artifactId>
|
<artifactId>profanity-filter</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>remind</artifactId>
|
<artifactId>remind</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<changeSet author="Sheldan" id="reminder-resize_text">
|
||||||
|
<modifyDataType columnName="text"
|
||||||
|
newDataType="VARCHAR(4000)"
|
||||||
|
tableName="reminder"/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="reminder.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -6,4 +6,5 @@
|
|||||||
<include file="1.2.10-remind/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.2.10-remind/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.2.12/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.2.12/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.4.3/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.3/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="1.5.39/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>remind</artifactId>
|
<artifactId>remind</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>repost-detection</artifactId>
|
<artifactId>repost-detection</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>repost-detection</artifactId>
|
<artifactId>repost-detection</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>starboard</artifactId>
|
<artifactId>starboard</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>starboard</artifactId>
|
<artifactId>starboard</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>statistic</artifactId>
|
<artifactId>statistic</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>statistic</artifactId>
|
<artifactId>statistic</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>sticky-roles</artifactId>
|
<artifactId>sticky-roles</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-impl</artifactId>
|
<artifactId>sticky-roles-impl</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>sticky-roles</artifactId>
|
<artifactId>sticky-roles</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>sticky-roles-int</artifactId>
|
<artifactId>sticky-roles-int</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>suggestion</artifactId>
|
<artifactId>suggestion</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -105,6 +105,9 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SuggestionVoteManagementService suggestionVoteManagementService;
|
private SuggestionVoteManagementService suggestionVoteManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
@Value("${abstracto.feature.suggestion.removalMaxAge}")
|
@Value("${abstracto.feature.suggestion.removalMaxAge}")
|
||||||
private Long removalMaxAgeSeconds;
|
private Long removalMaxAgeSeconds;
|
||||||
|
|
||||||
@@ -155,18 +158,18 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
List<ButtonConfigModel> buttonConfigModels = Arrays.asList(model.getAgreeButtonModel(), model.getDisAgreeButtonModel(), model.getRemoveVoteButtonModel());
|
List<ButtonConfigModel> buttonConfigModels = Arrays.asList(model.getAgreeButtonModel(), model.getDisAgreeButtonModel(), model.getRemoveVoteButtonModel());
|
||||||
return FutureUtils.toSingleFutureGeneric(completableFutures)
|
return FutureUtils.toSingleFutureGeneric(completableFutures)
|
||||||
.thenCompose(aVoid -> self.addVotingPossibility(suggestionChannelId, suggestionMessageId, text, suggester, serverId, newSuggestionId, completableFutures, buttonConfigModels, useButtons))
|
.thenCompose(aVoid -> self.addVotingPossibility(suggestionChannelId, suggestionMessageId, text, suggester, serverId, newSuggestionId, completableFutures, buttonConfigModels, useButtons))
|
||||||
.thenCompose(aVoid -> self.createSuggestionThread(serverId, newSuggestionId, suggester, text, autoEvaluationEnabled, autoEvaluationTargetDate));
|
.thenCompose(aVoid -> self.createSuggestionThread(serverId, newSuggestionId, suggester, text, autoEvaluationEnabled, autoEvaluationTargetDate, completableFutures));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompletableFuture<Void> createSuggestionThread(Long serverId, Long suggestionId, Member suggester, String suggestionText,
|
public CompletableFuture<Void> createSuggestionThread(Long serverId, Long suggestionId, Member suggester, String suggestionText,
|
||||||
Boolean autoEvaluationEnabled, Instant autoEvaluationTargetDate) {
|
Boolean autoEvaluationEnabled, Instant autoEvaluationTargetDate, List<CompletableFuture<Message>> completableFutures) {
|
||||||
if(featureModeService.featureModeActive(SuggestionFeatureDefinition.SUGGEST, serverId, SuggestionFeatureMode.SUGGESTION_THREAD)) {
|
if(featureModeService.featureModeActive(SuggestionFeatureDefinition.SUGGEST, serverId, SuggestionFeatureMode.SUGGESTION_THREAD)) {
|
||||||
Optional<GuildMessageChannel> suggestionTargetChannelOptional = postTargetService.getPostTargetChannel(SuggestionPostTarget.SUGGESTION, serverId);
|
Optional<GuildMessageChannel> suggestionTargetChannelOptional = postTargetService.getPostTargetChannel(SuggestionPostTarget.SUGGESTION, serverId);
|
||||||
log.info("Trying to create thread for suggestion {} in server {}.", suggestionId, serverId);
|
log.info("Trying to create thread for suggestion {} in server {}.", suggestionId, serverId);
|
||||||
if (suggestionTargetChannelOptional.isPresent()) {
|
if (suggestionTargetChannelOptional.isPresent()) {
|
||||||
GuildMessageChannel messageChannel = suggestionTargetChannelOptional.get();
|
GuildMessageChannel messageChannel = suggestionTargetChannelOptional.get();
|
||||||
if(messageChannel instanceof IThreadContainer) {
|
if(messageChannel instanceof IThreadContainer threadContainer) {
|
||||||
SuggestionThreadModel model = SuggestionThreadModel
|
SuggestionThreadModel model = SuggestionThreadModel
|
||||||
.builder()
|
.builder()
|
||||||
.suggestionId(suggestionId)
|
.suggestionId(suggestionId)
|
||||||
@@ -176,10 +179,15 @@ public class SuggestionServiceBean implements SuggestionService {
|
|||||||
.text(suggestionText)
|
.text(suggestionText)
|
||||||
.autoEvaluationTargetDate(autoEvaluationTargetDate)
|
.autoEvaluationTargetDate(autoEvaluationTargetDate)
|
||||||
.build();
|
.build();
|
||||||
IThreadContainer threadContainer = (IThreadContainer) messageChannel;
|
|
||||||
String threadName = templateService.renderTemplate("suggestion_thread_name", model, serverId);
|
String threadName = templateService.renderTemplate("suggestion_thread_name", model, serverId);
|
||||||
return threadContainer.createThreadChannel(threadName).submit()
|
if(!completableFutures.isEmpty()) {
|
||||||
.thenAccept(threadChannel -> log.info("Created thread for suggestion {} in server {}.", suggestionId, serverId));
|
Long suggestionMessageId = completableFutures.get(0).join().getIdLong();
|
||||||
|
return channelService.createThreadChannel(threadContainer, threadName, suggestionMessageId)
|
||||||
|
.thenAccept(threadChannel -> log.info("Created thread for suggestion {} in server {} using the suggestion message {} as starter.", suggestionId, serverId, suggestionMessageId));
|
||||||
|
} else {
|
||||||
|
return channelService.createThreadChannel(threadContainer, threadName)
|
||||||
|
.thenAccept(threadChannel -> log.info("Created thread for suggestion {} in server {}.", suggestionId, serverId));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info("Suggestion thread was not created - post target for suggestions does not allow to create threads");
|
log.info("Suggestion thread was not created - post target for suggestions does not allow to create threads");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>suggestion</artifactId>
|
<artifactId>suggestion</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>twitch</artifactId>
|
<artifactId>twitch</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>twitch</artifactId>
|
<artifactId>twitch</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>utility</artifactId>
|
<artifactId>utility</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>utility</artifactId>
|
<artifactId>utility</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>voice-channel-context</artifactId>
|
<artifactId>voice-channel-context</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>voice-channel-context</artifactId>
|
<artifactId>voice-channel-context</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>webservices</artifactId>
|
<artifactId>webservices</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>webservices</artifactId>
|
<artifactId>webservices</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto</groupId>
|
<groupId>dev.sheldan.abstracto</groupId>
|
||||||
<artifactId>abstracto-application</artifactId>
|
<artifactId>abstracto-application</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ package dev.sheldan.abstracto.core.listener.sync.jda;
|
|||||||
import dev.sheldan.abstracto.core.listener.ListenerService;
|
import dev.sheldan.abstracto.core.listener.ListenerService;
|
||||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||||
import dev.sheldan.abstracto.core.models.listener.MemberJoinModel;
|
import dev.sheldan.abstracto.core.models.listener.MemberJoinModel;
|
||||||
import dev.sheldan.abstracto.core.service.FeatureConfigService;
|
|
||||||
import dev.sheldan.abstracto.core.service.FeatureFlagService;
|
|
||||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
|
||||||
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
import dev.sheldan.abstracto.core.utils.BeanUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||||
@@ -25,15 +22,6 @@ public class JoinListenerBean extends ListenerAdapter {
|
|||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private List<JoinListener> listenerList;
|
private List<JoinListener> listenerList;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FeatureConfigService featureConfigService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FeatureFlagService featureFlagService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserInServerManagementService userInServerManagementService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ListenerService listenerService;
|
private ListenerService listenerService;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.*;
|
import net.dv8tion.jda.api.entities.*;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.Category;
|
import net.dv8tion.jda.api.entities.channel.concrete.Category;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
|
||||||
@@ -116,6 +117,16 @@ public class ChannelServiceBean implements ChannelService {
|
|||||||
sendTextToChannel(text, channel);
|
sendTextToChannel(text, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<ThreadChannel> createThreadChannel(IThreadContainer threadContainer, String name) {
|
||||||
|
return threadContainer.createThreadChannel(name).submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<ThreadChannel> createThreadChannel(IThreadContainer threadContainer, String name, Long messageId) {
|
||||||
|
return threadContainer.createThreadChannel(name, messageId).submit();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Message> sendTextToAChannel(String text, AChannel channel) {
|
public CompletableFuture<Message> sendTextToAChannel(String text, AChannel channel) {
|
||||||
GuildMessageChannel guildMessageChannel = getGuildMessageChannelFromAChannel(channel);
|
GuildMessageChannel guildMessageChannel = getGuildMessageChannelFromAChannel(channel);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
spring.jpa.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
||||||
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
|
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
|
||||||
spring.jpa.properties.hibernate.format_sql = false
|
spring.jpa.properties.hibernate.format_sql = false
|
||||||
|
spring.datasource.hikari.maxLifeTime=600000
|
||||||
|
|
||||||
spring.jpa.properties.hibernate.generate_statistics = false
|
spring.jpa.properties.hibernate.generate_statistics = false
|
||||||
spring.jpa.properties.hibernate.cache.use_second_level_cache=false
|
spring.jpa.properties.hibernate.cache.use_second_level_cache=false
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>1.5.37</version>
|
<version>1.5.41-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package dev.sheldan.abstracto.core.exception;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.exception.InputFormatExceptionModel;
|
||||||
|
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||||
|
|
||||||
|
public class InputFormatException extends AbstractoRunTimeException implements Templatable {
|
||||||
|
|
||||||
|
private final InputFormatExceptionModel model;
|
||||||
|
|
||||||
|
|
||||||
|
public InputFormatException(String wrongFormat, String validFormat) {
|
||||||
|
super("Input format exception ");
|
||||||
|
this.model = InputFormatExceptionModel
|
||||||
|
.builder()
|
||||||
|
.invalidFormat(wrongFormat)
|
||||||
|
.validFormat(validFormat)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "input_invalid_format_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user