mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-07 18:03:50 +00:00
Compare commits
18 Commits
abstracto-
...
abstracto-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
244000bbe4 | ||
|
|
134f25955c | ||
|
|
ddb256cf75 | ||
|
|
08edcbdf8e | ||
|
|
fd9a446f9e | ||
|
|
d2c17cb1fc | ||
|
|
9de7a59295 | ||
|
|
f9d0e5fa00 | ||
|
|
ef421961ca | ||
|
|
fe8519489c | ||
|
|
72c73b8b34 | ||
|
|
2b3b0f42c4 | ||
|
|
92b8e1dd8b | ||
|
|
b94801192e | ||
|
|
f5f0cbcb1e | ||
|
|
47f33758c9 | ||
|
|
0a79fe2318 | ||
|
|
da97f040f9 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -46,5 +46,5 @@ jobs:
|
||||
working-directory: ./abstracto-application/installer/src/main/docker/deployment
|
||||
run: docker-compose build && docker-compose push
|
||||
env:
|
||||
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto
|
||||
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto/
|
||||
VERSION: ${{ env.version }}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>assignable-roles</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>assignable-roles-int</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ public class LoveCalc extends AbstractConditionableCommand {
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(Parameter.builder().name("firstSubject").type(String.class).templated(true).optional(true).build());
|
||||
parameters.add(Parameter.builder().name("secondSubject").type(String.class).templated(true).optional(true).build());
|
||||
parameters.add(Parameter.builder().name("firstSubject").type(String.class).templated(true).build());
|
||||
parameters.add(Parameter.builder().name("secondSubject").type(String.class).templated(true).build());
|
||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||
return CommandConfiguration.builder()
|
||||
.name("loveCalc")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>entertainment</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>experience-tracking</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
|
||||
@Slf4j
|
||||
public class MessageEmbedServiceBean implements MessageEmbedService {
|
||||
|
||||
private Pattern messageRegex = Pattern.compile("(?<whole>https://discord(?:app)?.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+");
|
||||
private final Pattern messageRegex = Pattern.compile("(?<whole>(?:https?://)?(?:\\w+\\.)?discord(?:app)?\\.com/channels/(?<server>\\d+)/(?<channel>\\d+)/(?<message>\\d+)(?:.*?))+");
|
||||
|
||||
public static final String MESSAGE_EMBED_TEMPLATE = "message_embed";
|
||||
public static final String REMOVAL_EMOTE = "removeEmbed";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>link-embed</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>moderation</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>modmail</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>repost-detection</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ public interface StarboardPostReactionRepository extends JpaRepository<Starboard
|
||||
|
||||
void deleteByStarboardPost(StarboardPost post);
|
||||
|
||||
long countByStarboardPost(StarboardPost post);
|
||||
|
||||
@Query(value = "SELECT r.reactor_user_in_server_id as userId, COUNT(*) AS starCount \n" +
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
"INNER JOIN starboard_post p ON p.id = r.post_id\n" +
|
||||
|
||||
@@ -18,6 +18,8 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
|
||||
List<StarboardPost> findByServer_Id(Long serverId);
|
||||
|
||||
Long countByServer_Id(Long serverId);
|
||||
|
||||
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
||||
" FROM starboard_post p \n" +
|
||||
" INNER JOIN starboard_post_reaction r ON p.id = r.post_id\n" +
|
||||
@@ -30,6 +32,16 @@ public interface StarboardPostRepository extends JpaRepository<StarboardPost, Lo
|
||||
" LIMIT :count", nativeQuery = true)
|
||||
List<Long> getTopStarboardPostsForUser(Long serverId, Long userId, Integer count);
|
||||
|
||||
@Query(value = "SELECT p.id, COUNT(*) AS starCount \n" +
|
||||
" FROM starboard_post p \n" +
|
||||
" INNER JOIN starboard_post_reaction r ON p.id = r.post_id\n" +
|
||||
" WHERE p.server_id = :serverId\n" +
|
||||
" AND p.ignored = false\n" +
|
||||
" GROUP BY p.id \n" +
|
||||
" ORDER BY starCount DESC \n" +
|
||||
" LIMIT :count", nativeQuery = true)
|
||||
List<Long> getTopStarboardPostsForServer(Long serverId, Integer count);
|
||||
|
||||
@Query(value = "SELECT COUNT(*) AS starCount\n" +
|
||||
"FROM starboard_post_reaction r \n" +
|
||||
" INNER JOIN starboard_post p ON p.id = r.post_id \n" +
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -195,8 +196,8 @@ public class StarboardServiceBean implements StarboardService {
|
||||
allFutures.addAll(topStarReceiverFutures);
|
||||
return FutureUtils.toSingleFuture(allFutures).thenApply(aVoid -> {
|
||||
List<StarboardPost> starboardPosts = starboardPostManagementService.retrieveTopPosts(serverId, count);
|
||||
List<StarStatsPost> starStatsPosts = starboardPosts.stream().map(this::fromStarboardPost).collect(Collectors.toList());
|
||||
Integer postCount = starboardPostManagementService.getPostCount(serverId);
|
||||
List<StarStatsPost> starStatsPosts = starboardPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
||||
Long postCount = starboardPostManagementService.getPostCount(serverId);
|
||||
Integer reactionCount = starboardPostReactorManagementService.getStarCount(serverId);
|
||||
List<String> emotes = new ArrayList<>();
|
||||
for (int i = 1; i < count + 1; i++) {
|
||||
@@ -223,7 +224,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
Long receivedStars = starboardPostManagementService.retrieveReceivedStarsOfUserInServer(member.getGuild().getIdLong(), member.getIdLong());
|
||||
Long givenStars = starboardPostManagementService.retrieveGivenStarsOfUserInServer(member.getGuild().getIdLong(), member.getIdLong());
|
||||
List<StarboardPost> topPosts = starboardPostManagementService.retrieveTopPostsForUserInServer(member.getGuild().getIdLong(), member.getIdLong(), count);
|
||||
List<StarStatsPost> starStatsPosts = topPosts.stream().map(this::fromStarboardPost).collect(Collectors.toList());
|
||||
List<StarStatsPost> starStatsPosts = topPosts.stream().map(this::fromStarboardPost).sorted(Comparator.comparingLong(StarStatsPost::getStarCount).reversed()).collect(Collectors.toList());
|
||||
List<String> emotes = new ArrayList<>();
|
||||
for (int i = 1; i < count + 1; i++) {
|
||||
emotes.add(getStarboardRankingEmote(member.getGuild().getIdLong(), i));
|
||||
@@ -245,7 +246,7 @@ public class StarboardServiceBean implements StarboardService {
|
||||
.serverId(starboardPost.getServer().getId())
|
||||
.channelId(channel.getId())
|
||||
.messageId(starboardPost.getPostMessageId())
|
||||
.starCount(starboardPost.getReactions().size())
|
||||
.starCount(starboardPostReactorManagementService.getReactorCountOfPost(starboardPost))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,8 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
|
||||
@Override
|
||||
public List<StarboardPost> retrieveTopPosts(Long serverId, Integer count) {
|
||||
List<StarboardPost> posts = retrieveAllPosts(serverId);
|
||||
posts.sort(Comparator.comparingInt(o -> o.getReactions().size()));
|
||||
Collections.reverse(posts);
|
||||
return posts.subList(0, Math.min(count, posts.size()));
|
||||
List<Long> topPostIds = repository.getTopStarboardPostsForServer(serverId, count);
|
||||
return repository.findAllById(topPostIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,8 +84,8 @@ public class StarboardPostManagementServiceBean implements StarboardPostManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPostCount(Long serverId) {
|
||||
return retrieveAllPosts(serverId).size();
|
||||
public Long getPostCount(Long serverId) {
|
||||
return repository.countByServer_Id(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,4 +65,9 @@ public class StarboardPostReactorManagementServiceBean implements StarboardPostR
|
||||
return converter.convertToStarStatsUser(starReceivers, serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getReactorCountOfPost(StarboardPost starboardPost) {
|
||||
return repository.countByStarboardPost(starboardPost);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../dbchangelog-3.8.xsd" >
|
||||
<include file="starboard-tables/tables.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="additional_starboard_post-index">
|
||||
<createIndex indexName="idx_starboard_author" tableName="starboard_post">
|
||||
<column name="author_user_in_server_id"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="additional_starboard_reaction-index">
|
||||
<createIndex indexName="idx_starboard_reaction_user" tableName="starboard_post_reaction">
|
||||
<column name="reactor_user_in_server_id"/>
|
||||
</createIndex>
|
||||
<createIndex indexName="idx_starboard_reaction_post" tableName="starboard_post_reaction">
|
||||
<column name="post_id"/>
|
||||
</createIndex>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<include file="starboard_post.xml" relativeToChangelogFile="true"/>
|
||||
<include file="starboard_post_reaction.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -7,4 +7,5 @@
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog-3.8.xsd" >
|
||||
<include file="1.0-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.3-starboard/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -298,7 +298,7 @@ public class StarboardServiceBeanTest {
|
||||
List<CompletableFuture<StarStatsUser>> topGiver = Arrays.asList(statsUser, statsUser2);
|
||||
when(starboardPostReactorManagementService.retrieveTopStarGiver(SERVER_ID, limit)).thenReturn(topGiver);
|
||||
when(starboardPostReactorManagementService.retrieveTopStarReceiver(SERVER_ID, limit)).thenReturn(topGiver);
|
||||
when(starboardPostManagementService.getPostCount(SERVER_ID)).thenReturn(50);
|
||||
when(starboardPostManagementService.getPostCount(SERVER_ID)).thenReturn(50L);
|
||||
when(starboardPostReactorManagementService.getStarCount(SERVER_ID)).thenReturn(500);
|
||||
when(emoteService.getUsableEmoteOrDefault(SERVER_ID, "starboardBadge1")).thenReturn("1");
|
||||
when(emoteService.getUsableEmoteOrDefault(SERVER_ID, "starboardBadge2")).thenReturn("2");
|
||||
|
||||
@@ -198,7 +198,7 @@ public class StarboardPostManagementServiceBeanTest {
|
||||
StarboardPost starboardPost2 = Mockito.mock(StarboardPost.class);
|
||||
List<StarboardPost> posts = Arrays.asList(starboardPost1, starboardPost2);
|
||||
when(repository.findByServer_Id(SERVER_ID)).thenReturn(posts);
|
||||
Integer retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
||||
Long retrievedPostCount = testUnit.getPostCount(SERVER_ID);
|
||||
Assert.assertEquals(posts.size(), retrievedPostCount.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>starboard</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ public class GuildStarStatsModel {
|
||||
private List<StarStatsUser> starGiver;
|
||||
private Integer totalStars;
|
||||
private List<String> badgeEmotes;
|
||||
private Integer starredMessages;
|
||||
private Long starredMessages;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class StarStatsPost {
|
||||
private Long serverId;
|
||||
private Long channelId;
|
||||
private Long messageId;
|
||||
private Integer starCount;
|
||||
private Long starCount;
|
||||
|
||||
public String getMessageUrl() {
|
||||
return MessageUtils.buildMessageUrl(serverId ,channelId, messageId);
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface StarboardPostManagementService {
|
||||
Long retrieveGivenStarsOfUserInServer(Long serverId, Long userId);
|
||||
Long retrieveReceivedStarsOfUserInServer(Long serverId, Long userId);
|
||||
List<StarboardPost> retrieveAllPosts(Long serverId);
|
||||
Integer getPostCount(Long serverId);
|
||||
Long getPostCount(Long serverId);
|
||||
Optional<StarboardPost> findByMessageId(Long messageId);
|
||||
Optional<StarboardPost> findByStarboardPostId(Long postId);
|
||||
Optional<StarboardPost> findByStarboardPostMessageId(Long postId);
|
||||
|
||||
@@ -15,4 +15,5 @@ public interface StarboardPostReactorManagementService {
|
||||
Integer getStarCount(Long serverId);
|
||||
List<CompletableFuture<StarStatsUser>> retrieveTopStarGiver(Long serverId, Integer count);
|
||||
List<CompletableFuture<StarStatsUser>> retrieveTopStarReceiver(Long serverId, Integer count);
|
||||
Long getReactorCountOfPost(StarboardPost starboardPost);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>statistic</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>suggestion</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -2,6 +2,8 @@ package dev.sheldan.abstracto.core.command;
|
||||
|
||||
public class CommandConstants {
|
||||
|
||||
public static final String COMMAND_CHANNEL_GROUP_KEY = "command";
|
||||
|
||||
private CommandConstants() {
|
||||
|
||||
}
|
||||
|
||||
@@ -33,9 +33,13 @@ public class ChannelGroupCommandServiceBean implements ChannelGroupCommandServic
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// empty -> no groups, command enabled
|
||||
// not empty -> has groups, command is disabled in all
|
||||
return allChannelGroupsOfCommand.isEmpty();
|
||||
/*
|
||||
if we are here this means either:
|
||||
the command has no channel groups assigned -> enabled
|
||||
the command has one or more channel group and is enabled in these ones -> enabled
|
||||
the command has a channel group with channels (and it might be enabled/disabled, does not matter), but the given channel is not part of that group -> ok
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ChannelGroupCommandManagementServiceBean implements ChannelGroupCom
|
||||
AChannelGroupCommand channelGroupCommand = AChannelGroupCommand
|
||||
.builder()
|
||||
.command(command)
|
||||
.server(group.getServer())
|
||||
.group(group)
|
||||
.enabled(false)
|
||||
.build();
|
||||
|
||||
@@ -25,6 +25,7 @@ public class AsyncChannelGroupCreatedListenerManager {
|
||||
|
||||
@TransactionalEventListener
|
||||
public void executeListener(ChannelGroupCreatedListenerModel createdGroup){
|
||||
if(listener == null) return;
|
||||
listener.forEach(asyncChannelGroupCreatedListener ->
|
||||
listenerService.executeListener(asyncChannelGroupCreatedListener, createdGroup, channelGroupCreatedExecutor)
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import dev.sheldan.abstracto.core.metric.OkHttpMetrics;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import net.dv8tion.jda.internal.utils.IOUtil;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -26,7 +25,7 @@ public class BotServiceBean implements BotService {
|
||||
|
||||
@Override
|
||||
public void login() throws LoginException {
|
||||
JDABuilder builder = JDABuilder.create(System.getenv("TOKEN"), GatewayIntent.GUILD_MEMBERS, GUILD_VOICE_STATES,
|
||||
JDABuilder builder = JDABuilder.create(System.getenv("TOKEN"), GUILD_VOICE_STATES,
|
||||
GUILD_EMOJIS, GUILD_MEMBERS, GUILD_MESSAGE_REACTIONS, GUILD_MESSAGES,
|
||||
GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGE_REACTIONS, DIRECT_MESSAGES, GUILD_PRESENCES);
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import net.dv8tion.jda.api.requests.restaction.pagination.ReactionPaginationActi
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.Instant;
|
||||
@@ -86,6 +85,7 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
}
|
||||
List<MessageEmbed.Field> fields = embed.getFields();
|
||||
if(!fields.isEmpty()) {
|
||||
log.trace("Caching {} fields.", fields.size());
|
||||
List<CachedEmbedField> cachedEmbedFields = new ArrayList<>();
|
||||
fields.forEach(field -> {
|
||||
CachedEmbedField build = CachedEmbedField
|
||||
@@ -154,51 +154,52 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
@Override
|
||||
public CompletableFuture<CachedReactions> getCachedReactionFromReaction(MessageReaction reaction) {
|
||||
CompletableFuture<CachedReactions> future = new CompletableFuture<>();
|
||||
ReactionPaginationAction users = reaction.retrieveUsers();
|
||||
ReactionPaginationAction users = reaction.retrieveUsers().cache(false);
|
||||
CachedReactions.CachedReactionsBuilder builder = CachedReactions.builder();
|
||||
|
||||
List<ServerUser> aUsers = new ArrayList<>();
|
||||
users.forEachAsync(user -> {
|
||||
concreteSelf.loadUser(reaction, aUsers, user);
|
||||
log.trace("Loading user {} for reaction.", user.getIdLong());
|
||||
if(reaction.getGuild() != null) {
|
||||
aUsers.add(ServerUser.builder().userId(user.getIdLong()).serverId(reaction.getGuild().getIdLong()).build());
|
||||
}
|
||||
return false;
|
||||
}).thenAccept(o -> future.complete(builder.build()))
|
||||
.exceptionally(throwable -> {
|
||||
log.error("Failed to load reaction users.", throwable);
|
||||
return null;
|
||||
});
|
||||
builder.users(aUsers);
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
}).whenComplete((o, throwable) -> {
|
||||
log.trace("{} Users have been loaded. Completing future.", aUsers.size());
|
||||
if(throwable != null) {
|
||||
log.error("Reaction user retrieval failed. Completing with what we have.", throwable);
|
||||
}
|
||||
builder.users(aUsers);
|
||||
builder.self(reaction.isSelf());
|
||||
builder.emote(getCachedEmoteFromEmote(reaction.getReactionEmote(), reaction.getGuild()));
|
||||
future.complete(builder.build());
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void loadUser(MessageReaction reaction, List<ServerUser> aUsers, User user) {
|
||||
if(reaction.getGuild() != null) {
|
||||
aUsers.add(ServerUser.builder().userId(user.getIdLong()).serverId(reaction.getGuild().getIdLong()).build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CachedMessage> buildCachedMessageFromMessage(Message message) {
|
||||
CompletableFuture<CachedMessage> future = new CompletableFuture<>();
|
||||
List<CachedAttachment> attachments = new ArrayList<>();
|
||||
log.trace("Caching {} attachments.", message.getAttachments().size());
|
||||
message.getAttachments().forEach(attachment ->
|
||||
attachments.add(getCachedAttachment(attachment))
|
||||
);
|
||||
log.trace("Caching {} embeds.", message.getEmbeds().size());
|
||||
List<CachedEmbed> embeds = new ArrayList<>();
|
||||
message.getEmbeds().forEach(embed ->
|
||||
embeds.add(getCachedEmbedFromEmbed(embed))
|
||||
);
|
||||
|
||||
log.trace("Caching {} emotes.", message.getEmbeds().size());
|
||||
List<CachedEmote> emotes = new ArrayList<>();
|
||||
if(message.isFromGuild()) {
|
||||
message.getEmotesBag().forEach(emote -> emotes.add(getCachedEmoteFromEmote(emote, message.getGuild())));
|
||||
}
|
||||
|
||||
List<CompletableFuture<CachedReactions>> futures = new ArrayList<>();
|
||||
log.trace("Caching {} reactions.", message.getReactions().size());
|
||||
message.getReactions().forEach(messageReaction -> futures.add(getCachedReactionFromReaction(messageReaction)));
|
||||
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenAccept(aVoid ->
|
||||
{
|
||||
CachedAuthor cachedAuthor = CachedAuthor.builder().authorId(message.getAuthor().getIdLong()).isBot(message.getAuthor().isBot()).build();
|
||||
@@ -222,6 +223,23 @@ public class CacheEntityServiceBean implements CacheEntityService {
|
||||
log.error("Failed to load reactions for message {}. ", message.getId(), throwable);
|
||||
return null;
|
||||
});
|
||||
if(message.getReactions().isEmpty()) {
|
||||
CachedAuthor cachedAuthor = CachedAuthor.builder().authorId(message.getAuthor().getIdLong()).isBot(message.getAuthor().isBot()).build();
|
||||
CachedMessage.CachedMessageBuilder builder = CachedMessage.builder()
|
||||
.author(cachedAuthor)
|
||||
.messageId(message.getIdLong())
|
||||
.channelId(message.getChannel().getIdLong())
|
||||
.content(message.getContentRaw())
|
||||
.embeds(embeds)
|
||||
.emotes(emotes)
|
||||
.timeCreated(Instant.from(message.getTimeCreated()))
|
||||
.attachments(attachments);
|
||||
if(message.isFromGuild()) {
|
||||
builder.serverId(message.getGuild().getIdLong());
|
||||
}
|
||||
future.complete(builder
|
||||
.build());
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.sheldan.abstracto.core.command.CommandConstants.COMMAND_CHANNEL_GROUP_KEY;
|
||||
|
||||
@Component
|
||||
public class ChannelGroupServiceBean implements ChannelGroupService {
|
||||
|
||||
@@ -95,10 +97,7 @@ public class ChannelGroupServiceBean implements ChannelGroupService {
|
||||
@Override
|
||||
public void disableCommandInChannelGroup(String commandName, String channelGroupName, Long serverId) {
|
||||
AServer server = serverManagementService.loadOrCreate(serverId);
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findByNameAndServer(channelGroupName, server);
|
||||
if(channelGroup == null) {
|
||||
throw new ChannelGroupNotFoundException(channelGroupName, channelGroupManagementService.getAllAvailableAsString(server));
|
||||
}
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findByNameAndServerAndType(channelGroupName, server, COMMAND_CHANNEL_GROUP_KEY);
|
||||
ACommand command = commandManagementService.findCommandByName(commandName);
|
||||
if(command == null) {
|
||||
throw new CommandNotFoundException();
|
||||
@@ -109,10 +108,7 @@ public class ChannelGroupServiceBean implements ChannelGroupService {
|
||||
@Override
|
||||
public void enableCommandInChannelGroup(String commandName, String channelGroupName, Long serverId) {
|
||||
AServer server = serverManagementService.loadOrCreate(serverId);
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findByNameAndServer(channelGroupName, server);
|
||||
if(channelGroup == null) {
|
||||
throw new ChannelGroupNotFoundException(channelGroupName, channelGroupManagementService.getAllAvailableAsString(server));
|
||||
}
|
||||
AChannelGroup channelGroup = channelGroupManagementService.findByNameAndServerAndType(channelGroupName, server, COMMAND_CHANNEL_GROUP_KEY);
|
||||
ACommand command = commandManagementService.findCommandByName(commandName);
|
||||
if(command == null) {
|
||||
throw new CommandNotFoundException();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MessageCacheBean implements MessageCache {
|
||||
@Override
|
||||
@CachePut(key = "#message.id")
|
||||
public CompletableFuture<CachedMessage> putMessageInCache(Message message) {
|
||||
log.trace("Adding message {} to cache", message.getId());
|
||||
log.info("Adding message {} to cache.", message.getId());
|
||||
return cacheEntityService.buildCachedMessageFromMessage(message);
|
||||
}
|
||||
|
||||
@@ -50,26 +50,27 @@ public class MessageCacheBean implements MessageCache {
|
||||
@Override
|
||||
@CachePut(key = "#message.messageId.toString()")
|
||||
public CompletableFuture<CachedMessage> putMessageInCache(CachedMessage message) {
|
||||
log.trace("Adding cached message to cache");
|
||||
log.info("Adding cached message {} to cache.", message.getMessageId());
|
||||
return CompletableFuture.completedFuture(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#message.id")
|
||||
public CompletableFuture<CachedMessage> getMessageFromCache(Message message) {
|
||||
log.trace("Retrieving message {}", message.getId());
|
||||
log.trace("Retrieving message {}.", message.getId());
|
||||
return getMessageFromCache(message.getGuild().getIdLong(), message.getChannel().getIdLong(), message.getIdLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#messageId.toString()")
|
||||
public CompletableFuture<CachedMessage> getMessageFromCache(Long guildId, Long textChannelId, Long messageId) {
|
||||
log.trace("Retrieving message {} with parameters.", messageId);
|
||||
log.info("Retrieving message {}.", messageId);
|
||||
return concreteSelf.loadMessage(guildId, textChannelId, messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CachedMessage> loadMessage(Long guildId, Long textChannelId, Long messageId) {
|
||||
log.info("Loading message {} from channel {} in server {}.", messageId, textChannelId, guildId);
|
||||
CompletableFuture<CachedMessage> future = new CompletableFuture<>();
|
||||
Optional<Guild> guildOptional = guildService.getGuildByIdOptional(guildId);
|
||||
if(guildOptional.isPresent()) {
|
||||
|
||||
@@ -139,9 +139,13 @@ public class ChannelGroupManagementServiceBean implements ChannelGroupManagement
|
||||
public AChannelGroup findByNameAndServerAndType(String name, AServer server, String expectedType) {
|
||||
String lowerName = name.toLowerCase();
|
||||
Optional<AChannelGroup> channelOptional = channelGroupRepository.findByGroupNameAndServerAndChannelGroupType_GroupTypeKey(lowerName, server, expectedType);
|
||||
return channelOptional.orElseThrow( () -> {
|
||||
List<String> channelGroupNames = extractChannelGroupNames(findAllInServerWithType(server.getId(), expectedType));
|
||||
return new ChannelGroupNotFoundException(name.toLowerCase(), channelGroupNames);
|
||||
return channelOptional.orElseThrow(() -> {
|
||||
if(channelGroupRepository.existsByGroupNameAndServer(lowerName, server)) {
|
||||
return new ChannelGroupIncorrectTypeException(name.toLowerCase(), expectedType);
|
||||
} else {
|
||||
List<String> channelGroupNames = extractChannelGroupNames(findAllInServerWithType(server.getId(), expectedType));
|
||||
return new ChannelGroupNotFoundException(name.toLowerCase(), channelGroupNames);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../dbchangelog-3.8.xsd" >
|
||||
<include file="core-seedData/data.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="command-channelGroupType-insertion">
|
||||
<insert tableName="channel_group_type">
|
||||
<column name="group_type_key" value="command"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext ../../dbchangelog-3.8.xsd
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<include file="channelGroupType.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -9,4 +9,5 @@
|
||||
<include file="1.0-core/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.0-templating/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.1-core/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2-core/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,86 @@
|
||||
package dev.sheldan.abstracto.core.command.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.service.management.ChannelGroupCommandManagementService;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroupCommand;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChannelGroupCommandServiceBeanTest {
|
||||
|
||||
@InjectMocks
|
||||
private ChannelGroupCommandServiceBean testUnit;
|
||||
|
||||
@Mock
|
||||
private ChannelGroupCommandManagementService channelGroupCommandService;
|
||||
|
||||
@Mock
|
||||
private ChannelManagementService channelManagementService;
|
||||
|
||||
@Mock
|
||||
private ACommand command;
|
||||
|
||||
@Mock
|
||||
private AChannel channel;
|
||||
|
||||
@Mock
|
||||
private AChannel secondChannel;
|
||||
|
||||
@Mock
|
||||
private AChannelGroupCommand channelGroupCommand;
|
||||
|
||||
@Mock
|
||||
private AChannelGroup channelGroup;
|
||||
|
||||
private static final Long CHANNEL_ID = 4L;
|
||||
private static final Long CHANNEL_ID_2 = 2L;
|
||||
|
||||
@Test
|
||||
public void testNoChannelGroup() {
|
||||
when(channelGroupCommandService.getAllGroupCommandsForCommand(command)).thenReturn(new ArrayList<>());
|
||||
Assert.assertTrue(testUnit.isCommandEnabled(command, channel));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneDisabledChannelGroup() {
|
||||
when(channelGroupCommandService.getAllGroupCommandsForCommand(command)).thenReturn(Arrays.asList(channelGroupCommand));
|
||||
when(channelGroupCommand.getGroup()).thenReturn(channelGroup);
|
||||
when(channelGroup.getChannels()).thenReturn(Arrays.asList(channel));
|
||||
when(channelGroupCommand.getEnabled()).thenReturn(false);
|
||||
Assert.assertFalse(testUnit.isCommandEnabled(command, channel));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneEnabledChannelGroup() {
|
||||
when(channelGroupCommandService.getAllGroupCommandsForCommand(command)).thenReturn(Arrays.asList(channelGroupCommand));
|
||||
when(channelGroupCommand.getGroup()).thenReturn(channelGroup);
|
||||
when(channelGroup.getChannels()).thenReturn(Arrays.asList(channel));
|
||||
when(channelGroupCommand.getEnabled()).thenReturn(true);
|
||||
Assert.assertTrue(testUnit.isCommandEnabled(command, channel));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisabledInOneGroupChannelIsNotPartOf() {
|
||||
when(channelGroupCommandService.getAllGroupCommandsForCommand(command)).thenReturn(Arrays.asList(channelGroupCommand));
|
||||
when(channelGroupCommand.getGroup()).thenReturn(channelGroup);
|
||||
when(channelGroup.getChannels()).thenReturn(Arrays.asList(secondChannel));
|
||||
when(channel.getId()).thenReturn(CHANNEL_ID);
|
||||
when(secondChannel.getId()).thenReturn(CHANNEL_ID_2);
|
||||
Assert.assertTrue(testUnit.isCommandEnabled(command, channel));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.sheldan.abstracto.core.command.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.exception.ChannelGroupIncorrectTypeExceptionModel;
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
|
||||
public class ChannelGroupIncorrectTypeException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private final ChannelGroupIncorrectTypeExceptionModel model;
|
||||
|
||||
public ChannelGroupIncorrectTypeException(String key, String correctType) {
|
||||
super("Channel group has the incorrect type.");
|
||||
this.model = ChannelGroupIncorrectTypeExceptionModel.builder().name(key).correctType(correctType).build();
|
||||
}
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "channel_group_not_found_exception";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.core.command.models.exception;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ChannelGroupIncorrectTypeExceptionModel implements Serializable {
|
||||
private String name;
|
||||
private String correctType;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>core</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>coverage</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@ RUN apt-get update \
|
||||
|
||||
# Install liquibase
|
||||
RUN mkdir -p /liqiubase \
|
||||
&& wget https://github.com/liquibase/liquibase/releases/download/v${liquibase_version}/liquibase-${liquibase_version}.zip -O /tmp/liquibase.zip \
|
||||
&& wget -nv https://github.com/liquibase/liquibase/releases/download/v${liquibase_version}/liquibase-${liquibase_version}.zip -O /tmp/liquibase.zip \
|
||||
&& unzip /tmp/liquibase.zip -d /liquibase
|
||||
|
||||
RUN mkdir -p /java \
|
||||
&& wget https://corretto.aws/downloads/latest/amazon-corretto-8-x64-linux-jdk.tar.gz -O /tmp/java.tar.gz \
|
||||
&& wget -nv https://corretto.aws/downloads/latest/amazon-corretto-8-x64-linux-jdk.tar.gz -O /tmp/java.tar.gz \
|
||||
&& tar -xf /tmp/java.tar.gz --strip-components=1 -C /java
|
||||
|
||||
# Install postgres driver
|
||||
RUN mkdir -p /postgres \
|
||||
&& wget https://jdbc.postgresql.org/download/postgresql-${postgres_driver_version}.jar -O /postgres/driver.jar
|
||||
&& wget -nv https://jdbc.postgresql.org/download/postgresql-${postgres_driver_version}.jar -O /postgres/driver.jar
|
||||
|
||||
# Install ansible and required libraries
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from sqlalchemy.sql import text
|
||||
|
||||
|
||||
def deploy_template_folder(db_config, folder):
|
||||
engine = db.create_engine('postgres://%s:%s@%s:%s/%s' % (db_config.user, db_config.password, db_config.host, db_config.port, db_config.database))
|
||||
engine = db.create_engine('postgresql://%s:%s@%s:%s/%s' % (db_config.user, db_config.password, db_config.host, db_config.port, db_config.database))
|
||||
|
||||
if not os.path.isdir(folder):
|
||||
print("Given path was not a folder. Exiting.")
|
||||
|
||||
@@ -12,7 +12,7 @@ fi
|
||||
if [ "x$EXECUTE_TEMPLATES" = 'xtrue' ]; then
|
||||
DEPLOY_TEMPLATES=yes
|
||||
fi
|
||||
exit_code = 0
|
||||
exit_code=0
|
||||
if [ "x$EXECUTE_DEPLOYMENT" = 'xtrue' ]; then
|
||||
python3 -u python/main.py $DEPLOY_TEMPLATES $DEPLOY_LIQUIBASE
|
||||
exit_code=$?
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
@@ -35,7 +35,7 @@
|
||||
<scm>
|
||||
<url>https://maven.pkg.github.com/Sheldan/abstracto</url>
|
||||
<developerConnection>scm:git:git@github.com:Sheldan/abstracto.git</developerConnection>
|
||||
<tag>abstracto-application-1.1</tag>
|
||||
<tag>abstracto-application-1.2.3</tag>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto</groupId>
|
||||
<artifactId>abstracto-application</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||
<artifactId>scheduling</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
Reference in New Issue
Block a user