mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-22 17:45:48 +00:00
Compare commits
23 Commits
abstracto-
...
v1.5.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91e2bea2fc | ||
|
|
f03bee8b1e | ||
|
|
f3144eb094 | ||
|
|
2396bf300b | ||
|
|
06ebf4c882 | ||
|
|
ff534c03ac | ||
|
|
67c76487e2 | ||
|
|
9a2f47e244 | ||
|
|
2f33d19171 | ||
|
|
f6fc02e758 | ||
|
|
007929cfa5 | ||
|
|
77e2eec3d1 | ||
|
|
74c8cf7b6b | ||
|
|
c8739b90ec | ||
|
|
d39a303207 | ||
|
|
3e326fe47e | ||
|
|
a1d460973c | ||
|
|
d2475179e6 | ||
|
|
5adc304e77 | ||
|
|
4940577383 | ||
|
|
bba0a2ace6 | ||
|
|
b7c427026d | ||
|
|
cee10de915 |
21
.github/workflows/release.yml
vendored
21
.github/workflows/release.yml
vendored
@@ -37,15 +37,20 @@ jobs:
|
|||||||
branch: master
|
branch: master
|
||||||
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
folder: abstracto-application/documentation/target/generated-docs
|
folder: abstracto-application/documentation/target/generated-docs
|
||||||
- name: Login to GitHub Packages Docker Registry
|
- name: Login to Harbor
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: docker.pkg.github.com
|
registry: harbor.sheldan.dev
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ secrets.HARBOR_USERNAME }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.HARBOR_TOKEN }}
|
||||||
- name: Push deployment container
|
- name: Load env files
|
||||||
working-directory: ./abstracto-application/installer/src/main/docker/deployment
|
id: dotenv
|
||||||
|
uses: falti/dotenv-action@v1.0.4
|
||||||
|
with:
|
||||||
|
path: ./deployment/installer/.env
|
||||||
|
- name: Push container
|
||||||
run: docker-compose build && docker-compose push
|
run: docker-compose build && docker-compose push
|
||||||
|
working-directory: ./deployment/installer/
|
||||||
env:
|
env:
|
||||||
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto/
|
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
|
||||||
VERSION: ${{ env.version }}
|
VERSION: ${{ steps.dotenv.outputs.version }}
|
||||||
@@ -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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -371,21 +371,30 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
|
|||||||
userExperienceManagementService.saveUser(aUserExperience);
|
userExperienceManagementService.saveUser(aUserExperience);
|
||||||
}
|
}
|
||||||
if(!Objects.equals(result.getOldRoleId(), result.getNewRoleId())) {
|
if(!Objects.equals(result.getOldRoleId(), result.getNewRoleId())) {
|
||||||
if(result.getOldRoleId() != null) {
|
if(result.getOldRoleId() != null && result.getNewRoleId() != null) {
|
||||||
roleService.removeRoleFromMemberAsync(member, result.getOldRoleId()).thenAccept(unused -> {
|
roleService.updateRolesIds(member, Arrays.asList(result.getOldRoleId()), Arrays.asList(result.getNewRoleId())).thenAccept(unused -> {
|
||||||
log.debug("Removed role {} to member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
log.debug("Removed role {} from and added role {} to member {} in server {}.", result.getOldRoleId(), result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||||
}).exceptionally(throwable -> {
|
}).exceptionally(throwable -> {
|
||||||
log.warn("Failed to remove role {} from {} member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
log.warn("Failed to remove role {} from and add role {} to member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if(result.getNewRoleId() != null) {
|
|
||||||
roleService.addRoleToMemberAsync(member, result.getNewRoleId()).thenAccept(unused -> {
|
|
||||||
log.debug("Added role {} to member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
|
||||||
}).exceptionally(throwable -> {
|
|
||||||
log.warn("Failed to add role {} to {} member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if(result.getOldRoleId() != null) {
|
||||||
|
roleService.removeRoleFromMemberAsync(member, result.getOldRoleId()).thenAccept(unused -> {
|
||||||
|
log.debug("Removed role {} from member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.warn("Failed to remove role {} from {} member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(result.getNewRoleId() != null) {
|
||||||
|
roleService.addRoleToMemberAsync(member, result.getNewRoleId()).thenAccept(unused -> {
|
||||||
|
log.debug("Added role {} to member {} in server {}.", result.getNewRoleId(), member.getIdLong(), member.getGuild().getIdLong());
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.warn("Failed to add role {} to {} member {} in server {}.", result.getOldRoleId(), member.getIdLong(), member.getGuild().getIdLong(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package dev.sheldan.abstracto.moderation.model.template.command;
|
package dev.sheldan.abstracto.moderation.model.template.command;
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.models.context.SlimUserInitiatedServerContext;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
@@ -13,7 +12,7 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
public class WarningsModel extends SlimUserInitiatedServerContext {
|
public class WarningsModel {
|
||||||
/**
|
/**
|
||||||
* A collection of {@link dev.sheldan.abstracto.moderation.model.database.Warning}s being rendered, might be all warnings of the server, or only the warnings of a specific user
|
* A collection of {@link dev.sheldan.abstracto.moderation.model.database.Warning}s being rendered, might be all warnings of the server, or only the warnings of a specific user
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package dev.sheldan.abstracto.suggestion.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.ParameterValidator;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.validator.MinIntegerValueValidator;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.suggestion.config.SuggestionFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.suggestion.config.SuggestionSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.suggestion.model.template.PollInfoModel;
|
||||||
|
import dev.sheldan.abstracto.suggestion.service.PollService;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ShowPoll extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String COMMAND_NAME = "show";
|
||||||
|
private static final String SHOW_POLL_COMMAND_NAME = "showPoll";
|
||||||
|
private static final String POLL_ID_PARAMETER = "pollId";
|
||||||
|
private static final String SHOW_POLL_TEMPLATE_KEY = "showPoll_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PollService pollService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
Long suggestionId = slashCommandParameterService.getCommandOption(POLL_ID_PARAMETER, event, Long.class, Integer.class).longValue();
|
||||||
|
PollInfoModel pollInfoModel = pollService.getPollInfoModel(suggestionId, event.getGuild().getIdLong());
|
||||||
|
return interactionService.replyEmbed(SHOW_POLL_TEMPLATE_KEY, pollInfoModel, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
List<ParameterValidator> polldIdValidator = Arrays.asList(MinIntegerValueValidator.min(1L));
|
||||||
|
Parameter pollIdParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(POLL_ID_PARAMETER)
|
||||||
|
.validators(polldIdValidator)
|
||||||
|
.type(Long.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.hasExample(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(pollIdParameter);
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(SuggestionSlashCommandNames.POLL)
|
||||||
|
.commandName(COMMAND_NAME)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(SHOW_POLL_COMMAND_NAME)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.causesReaction(false)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return SuggestionFeatureDefinition.POLL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -335,7 +335,8 @@ public class PollServiceBean implements PollService {
|
|||||||
public CompletableFuture<Void> addOptionToServerPoll(Long pollId, Long serverId, Member adder, String label, String description) {
|
public CompletableFuture<Void> addOptionToServerPoll(Long pollId, Long serverId, Member adder, String label, String description) {
|
||||||
Poll poll = pollManagementService.getPollByPollId(pollId, serverId, PollType.STANDARD);
|
Poll poll = pollManagementService.getPollByPollId(pollId, serverId, PollType.STANDARD);
|
||||||
log.info("Adding option to server poll {} in server {}.", pollId, serverId);
|
log.info("Adding option to server poll {} in server {}.", pollId, serverId);
|
||||||
pollOptionManagementService.addOptionToPoll(poll, label, description);
|
AUserInAServer adderUser = userInServerManagementService.loadOrCreateUser(adder);
|
||||||
|
pollOptionManagementService.addOptionToPoll(poll, label, description, adderUser);
|
||||||
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
List<PollMessageOption> options = getOptionsOfPoll(poll);
|
||||||
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
ServerPollMessageModel model = ServerPollMessageModel.fromPoll(poll, options);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(SERVER_POLL_TEMPLATE_KEY, model);
|
||||||
@@ -487,6 +488,37 @@ public class PollServiceBean implements PollService {
|
|||||||
return messageService.deleteMessageInChannelInServer(serverId, poll.getChannel().getId(), poll.getMessageId());
|
return messageService.deleteMessageInChannelInServer(serverId, poll.getChannel().getId(), poll.getMessageId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PollInfoModel getPollInfoModel(Long pollId, Long serverId) {
|
||||||
|
Poll poll = pollManagementService.getPollByPollId(pollId, serverId, PollType.STANDARD);
|
||||||
|
Integer totalVotes = getTotalVotesOfPoll(poll);
|
||||||
|
List<PollOptionInfoModel> optionInfoModels = poll.getOptions().stream().map(pollOption -> {
|
||||||
|
Long voteCount = getVotesOfOption(poll, pollOption);
|
||||||
|
return PollOptionInfoModel
|
||||||
|
.builder()
|
||||||
|
.value(pollOption.getValue())
|
||||||
|
.description(pollOption.getDescription())
|
||||||
|
.label(pollOption.getLabel())
|
||||||
|
.votes(voteCount)
|
||||||
|
.percentage(totalVotes > 0 ? (voteCount / (float) totalVotes) * 100 : 0)
|
||||||
|
.adder(pollOption.getAdder() != null ? MemberDisplay.fromAUserInAServer(pollOption.getAdder()) : null)
|
||||||
|
.build();
|
||||||
|
}).toList();
|
||||||
|
return PollInfoModel
|
||||||
|
.builder()
|
||||||
|
.id(poll.getPollId())
|
||||||
|
.description(poll.getDescription())
|
||||||
|
.creationDate(poll.getCreated())
|
||||||
|
.targetDate(poll.getTargetDate())
|
||||||
|
.totalVotes(totalVotes)
|
||||||
|
.allowAdditions(poll.getAllowAddition())
|
||||||
|
.allowMultiple(poll.getAllowMultiple())
|
||||||
|
.options(optionInfoModels)
|
||||||
|
.showDecisions(poll.getShowDecisions())
|
||||||
|
.pollDuration(Duration.between(poll.getCreated(), poll.getTargetDate()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public CompletableFuture<Void> updateFinalPollMessage(Long pollId, Guild guild) {
|
public CompletableFuture<Void> updateFinalPollMessage(Long pollId, Guild guild) {
|
||||||
Poll poll = pollManagementService.getPollByPollId(pollId, guild.getIdLong(), PollType.STANDARD);
|
Poll poll = pollManagementService.getPollByPollId(pollId, guild.getIdLong(), PollType.STANDARD);
|
||||||
@@ -543,22 +575,13 @@ public class PollServiceBean implements PollService {
|
|||||||
.percentage(0f)
|
.percentage(0f)
|
||||||
.description(description)
|
.description(description)
|
||||||
.build();
|
.build();
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PollMessageOption> getOptionsOfPoll(Poll poll) {
|
private List<PollMessageOption> getOptionsOfPoll(Poll poll) {
|
||||||
Integer totalVotes = poll
|
Integer totalVotes = getTotalVotesOfPoll(poll);
|
||||||
.getDecisions()
|
|
||||||
.stream()
|
|
||||||
.map(userDecision -> userDecision.getOptions().size())
|
|
||||||
.mapToInt(Integer::intValue)
|
|
||||||
.sum();
|
|
||||||
return poll.getOptions().stream().map(option -> {
|
return poll.getOptions().stream().map(option -> {
|
||||||
Long voteCount = poll
|
Long voteCount = getVotesOfOption(poll, option);
|
||||||
.getDecisions()
|
|
||||||
.stream()
|
|
||||||
.filter(decision -> decision.getOptions().stream().anyMatch(pollUserDecisionOption -> pollUserDecisionOption.getPollOption().equals(option)))
|
|
||||||
.count();
|
|
||||||
return PollMessageOption
|
return PollMessageOption
|
||||||
.builder()
|
.builder()
|
||||||
.value(option.getValue())
|
.value(option.getValue())
|
||||||
@@ -567,7 +590,24 @@ public class PollServiceBean implements PollService {
|
|||||||
.percentage(totalVotes > 0 ? (voteCount / (float) totalVotes) * 100 : 0)
|
.percentage(totalVotes > 0 ? (voteCount / (float) totalVotes) * 100 : 0)
|
||||||
.description(option.getDescription())
|
.description(option.getDescription())
|
||||||
.build();
|
.build();
|
||||||
}).collect(Collectors.toList());
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long getVotesOfOption(Poll poll, PollOption option) {
|
||||||
|
return poll
|
||||||
|
.getDecisions()
|
||||||
|
.stream()
|
||||||
|
.filter(decision -> decision.getOptions().stream().anyMatch(pollUserDecisionOption -> pollUserDecisionOption.getPollOption().equals(option)))
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getTotalVotesOfPoll(Poll poll) {
|
||||||
|
return poll
|
||||||
|
.getDecisions()
|
||||||
|
.stream()
|
||||||
|
.map(userDecision -> userDecision.getOptions().size())
|
||||||
|
.mapToInt(Integer::intValue)
|
||||||
|
.sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.sheldan.abstracto.suggestion.service.management;
|
package dev.sheldan.abstracto.suggestion.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
import dev.sheldan.abstracto.suggestion.model.PollCreationRequest;
|
import dev.sheldan.abstracto.suggestion.model.PollCreationRequest;
|
||||||
import dev.sheldan.abstracto.suggestion.model.database.Poll;
|
import dev.sheldan.abstracto.suggestion.model.database.Poll;
|
||||||
import dev.sheldan.abstracto.suggestion.model.database.PollOption;
|
import dev.sheldan.abstracto.suggestion.model.database.PollOption;
|
||||||
@@ -32,12 +33,18 @@ public class PollOptionManagementServiceBean implements PollOptionManagementServ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addOptionToPoll(Poll poll, String label, String description) {
|
public void addOptionToPoll(Poll poll, String label, String description) {
|
||||||
|
addOptionToPoll(poll, label, description, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOptionToPoll(Poll poll, String label, String description, AUserInAServer adder) {
|
||||||
PollOption option = PollOption
|
PollOption option = PollOption
|
||||||
.builder()
|
.builder()
|
||||||
.poll(poll)
|
.poll(poll)
|
||||||
.label(label)
|
.label(label)
|
||||||
.value(label)
|
.value(label)
|
||||||
.server(poll.getServer())
|
.server(poll.getServer())
|
||||||
|
.adder(adder)
|
||||||
.description(description)
|
.description(description)
|
||||||
.build();
|
.build();
|
||||||
pollOptionRepository.save(option);
|
pollOptionRepository.save(option);
|
||||||
|
|||||||
@@ -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.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?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.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
|
||||||
|
<property name="pollFeature" value="(SELECT id FROM feature WHERE key = 'poll')"/>
|
||||||
|
|
||||||
|
<changeSet author="Sheldan" id="showPoll-command">
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="showPoll"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${pollFeature}"/>
|
||||||
|
</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.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||||
|
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||||
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -13,4 +13,5 @@
|
|||||||
<include file="1.4.0/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.0/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.4.8/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.8/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.4.26/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.26/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="1.5.6/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package dev.sheldan.abstracto.suggestion.model.template;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
public class PollInfoModel {
|
||||||
|
private Long id;
|
||||||
|
private String description;
|
||||||
|
private Boolean allowMultiple;
|
||||||
|
private Boolean showDecisions;
|
||||||
|
private Boolean allowAdditions;
|
||||||
|
private Instant creationDate;
|
||||||
|
private Integer totalVotes;
|
||||||
|
private Instant targetDate;
|
||||||
|
private Duration pollDuration;
|
||||||
|
private List<PollOptionInfoModel> options;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package dev.sheldan.abstracto.suggestion.model.template;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Builder
|
||||||
|
public class PollOptionInfoModel {
|
||||||
|
private String value;
|
||||||
|
private String label;
|
||||||
|
private String description;
|
||||||
|
private Long votes;
|
||||||
|
private Float percentage;
|
||||||
|
private MemberDisplay adder;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.sheldan.abstracto.suggestion.service;
|
package dev.sheldan.abstracto.suggestion.service;
|
||||||
|
|
||||||
import dev.sheldan.abstracto.suggestion.model.database.PollType;
|
import dev.sheldan.abstracto.suggestion.model.database.PollType;
|
||||||
|
import dev.sheldan.abstracto.suggestion.model.template.PollInfoModel;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||||
|
|
||||||
@@ -26,4 +27,5 @@ public interface PollService {
|
|||||||
CompletableFuture<Void> evaluateQuickPoll(Long pollId, Long serverId);
|
CompletableFuture<Void> evaluateQuickPoll(Long pollId, Long serverId);
|
||||||
CompletableFuture<Void> closePoll(Long pollId, Long serverId, String text, Member cause);
|
CompletableFuture<Void> closePoll(Long pollId, Long serverId, String text, Member cause);
|
||||||
CompletableFuture<Void> cancelPoll(Long pollId, Long serverId, Member cause);
|
CompletableFuture<Void> cancelPoll(Long pollId, Long serverId, Member cause);
|
||||||
|
PollInfoModel getPollInfoModel(Long pollId, Long serverId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package dev.sheldan.abstracto.suggestion.service.management;
|
package dev.sheldan.abstracto.suggestion.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
import dev.sheldan.abstracto.suggestion.model.PollCreationRequest;
|
import dev.sheldan.abstracto.suggestion.model.PollCreationRequest;
|
||||||
import dev.sheldan.abstracto.suggestion.model.database.Poll;
|
import dev.sheldan.abstracto.suggestion.model.database.Poll;
|
||||||
import dev.sheldan.abstracto.suggestion.model.database.PollOption;
|
import dev.sheldan.abstracto.suggestion.model.database.PollOption;
|
||||||
@@ -9,5 +10,6 @@ import java.util.Optional;
|
|||||||
public interface PollOptionManagementService {
|
public interface PollOptionManagementService {
|
||||||
void addOptionsToPoll(Poll poll, PollCreationRequest pollCreationRequest);
|
void addOptionsToPoll(Poll poll, PollCreationRequest pollCreationRequest);
|
||||||
void addOptionToPoll(Poll poll, String label, String description);
|
void addOptionToPoll(Poll poll, String label, String description);
|
||||||
|
void addOptionToPoll(Poll poll, String label, String description, AUserInAServer adder);
|
||||||
Optional<PollOption> getPollOptionByName(Poll poll, String key);
|
Optional<PollOption> getPollOptionByName(Poll poll, String key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import net.dv8tion.jda.api.entities.Guild;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||||
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -138,6 +139,7 @@ public class StreamerServiceBean implements StreamerService {
|
|||||||
.mature(stream.isMature())
|
.mature(stream.isMature())
|
||||||
.currentSection(StreamSectionDisplay.fromStream(stream))
|
.currentSection(StreamSectionDisplay.fromStream(stream))
|
||||||
.streamerAvatarURL(streamerUser.getProfileImageUrl())
|
.streamerAvatarURL(streamerUser.getProfileImageUrl())
|
||||||
|
.randomString(RandomStringUtils.randomAlphabetic(15))
|
||||||
.streamURL(formatStreamUrl(stream.getUserName()))
|
.streamURL(formatStreamUrl(stream.getUserName()))
|
||||||
.build();
|
.build();
|
||||||
MessageToSend messagetoSend;
|
MessageToSend messagetoSend;
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ public class GoLiveNotificationModel {
|
|||||||
private List<StreamSectionDisplay> pastSections;
|
private List<StreamSectionDisplay> pastSections;
|
||||||
private Boolean mature;
|
private Boolean mature;
|
||||||
private String streamURL;
|
private String streamURL;
|
||||||
|
private String randomString;
|
||||||
private String streamerAvatarURL;
|
private String streamerAvatarURL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -11,9 +11,13 @@ import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
|||||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
import dev.sheldan.abstracto.core.models.template.commands.EchoModel;
|
import dev.sheldan.abstracto.core.models.template.commands.EchoModel;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.commands.EchoRedirectResponseModel;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.ChannelDisplay;
|
||||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -26,7 +30,10 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class Echo extends AbstractConditionableCommand {
|
public class Echo extends AbstractConditionableCommand {
|
||||||
|
|
||||||
private static final String TEMPLATE_NAME = "echo_response";
|
private static final String TEMPLATE_NAME = "echo_response";
|
||||||
|
private static final String REDIRECT_TEMPLATE_NAME = "echo_redirect_response";
|
||||||
public static final String ECHO_COMMAND = "echo";
|
public static final String ECHO_COMMAND = "echo";
|
||||||
|
public static final String INPUT_PARAMETER = "input";
|
||||||
|
public static final String TARGET_CHANNEL_PARAMETER = "targetChannel";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplateService templateService;
|
private TemplateService templateService;
|
||||||
@@ -37,11 +44,14 @@ public class Echo extends AbstractConditionableCommand {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private InteractionService interactionService;
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandContext commandContext) {
|
public CommandResult execute(CommandContext commandContext) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
commandContext.getParameters().getParameters().forEach(o ->
|
commandContext.getParameters().getParameters().forEach(o ->
|
||||||
sb.append(o.toString())
|
sb.append(o.toString())
|
||||||
);
|
);
|
||||||
EchoModel model = EchoModel
|
EchoModel model = EchoModel
|
||||||
.builder()
|
.builder()
|
||||||
@@ -54,12 +64,33 @@ public class Echo extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
|
||||||
|
String message = slashCommandParameterService.getCommandOption(INPUT_PARAMETER, event, String.class);
|
||||||
|
GuildMessageChannel messageChannel;
|
||||||
|
if (slashCommandParameterService.hasCommandOption(TARGET_CHANNEL_PARAMETER, event)) {
|
||||||
|
messageChannel = slashCommandParameterService.getCommandOption(TARGET_CHANNEL_PARAMETER, event, GuildMessageChannel.class);
|
||||||
|
} else {
|
||||||
|
messageChannel = event.getGuildChannel();
|
||||||
|
}
|
||||||
|
|
||||||
EchoModel model = EchoModel
|
EchoModel model = EchoModel
|
||||||
.builder()
|
.builder()
|
||||||
.text(event.getOption("input").getAsString())
|
.text(message)
|
||||||
.build();
|
.build();
|
||||||
return interactionService.replyMessage(TEMPLATE_NAME, model, event)
|
|
||||||
.thenApply(unused -> CommandResult.fromSuccess());
|
if (messageChannel.equals(event.getMessageChannel())) {
|
||||||
|
return interactionService.replyMessage(TEMPLATE_NAME, model, event)
|
||||||
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
EchoRedirectResponseModel redirectResponseModel = EchoRedirectResponseModel
|
||||||
|
.builder()
|
||||||
|
.channel(ChannelDisplay.fromChannel(messageChannel))
|
||||||
|
.build();
|
||||||
|
return interactionService.replyEmbed(REDIRECT_TEMPLATE_NAME, redirectResponseModel, event)
|
||||||
|
.thenCompose(interactionHook -> channelService.sendTextTemplateInMessageChannel(TEMPLATE_NAME, model, messageChannel))
|
||||||
|
.thenApply(createdMessage -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,11 +98,22 @@ public class Echo extends AbstractConditionableCommand {
|
|||||||
List<Parameter> parameters = new ArrayList<>();
|
List<Parameter> parameters = new ArrayList<>();
|
||||||
parameters.add(Parameter
|
parameters.add(Parameter
|
||||||
.builder()
|
.builder()
|
||||||
.name("input")
|
.name(INPUT_PARAMETER)
|
||||||
.type(String.class)
|
.type(String.class)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.remainder(true)
|
.remainder(true)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
parameters.add(Parameter
|
||||||
|
.builder()
|
||||||
|
.name(TARGET_CHANNEL_PARAMETER)
|
||||||
|
.type(GuildMessageChannel.class)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.optional(true)
|
||||||
|
.templated(true)
|
||||||
|
.remainder(true)
|
||||||
|
.build());
|
||||||
|
|
||||||
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
.builder()
|
.builder()
|
||||||
.enabled(true)
|
.enabled(true)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class CoreConfig {
|
|||||||
public Gson gson() {
|
public Gson gson() {
|
||||||
GsonBuilder builder = new GsonBuilder()
|
GsonBuilder builder = new GsonBuilder()
|
||||||
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter())
|
.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeAdapter())
|
||||||
.registerTypeAdapter(Instant.class, new InstantTimeAdapter())
|
.registerTypeAdapter(Instant.class, new InstantAdapter())
|
||||||
.setPrettyPrinting();
|
.setPrettyPrinting();
|
||||||
if(customJsonDeSerializers != null) {
|
if(customJsonDeSerializers != null) {
|
||||||
customJsonDeSerializers.forEach(customJsonSerializer ->
|
customJsonDeSerializers.forEach(customJsonSerializer ->
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package dev.sheldan.abstracto.core.config;
|
||||||
|
|
||||||
|
import com.google.gson.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
|
||||||
|
public class InstantAdapter implements JsonDeserializer<Instant>, JsonSerializer<Instant> {
|
||||||
|
|
||||||
|
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Instant deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
|
||||||
|
TemporalAccessor ta = FORMATTER.parse(jsonElement.getAsString());
|
||||||
|
return Instant.from(ta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(Instant instant, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||||
|
return new JsonPrimitive(FORMATTER.format(instant));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package dev.sheldan.abstracto.core.config;
|
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
|
|
||||||
public class InstantTimeAdapter implements JsonDeserializer<Instant> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Instant deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
|
|
||||||
TemporalAccessor ta = DateTimeFormatter.ISO_INSTANT.parse(jsonElement.getAsString());
|
|
||||||
return Instant.from(ta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package dev.sheldan.abstracto.core.config;
|
package dev.sheldan.abstracto.core.config;
|
||||||
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.*;
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@@ -11,12 +9,19 @@ import java.time.ZoneId;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.TemporalAccessor;
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
|
||||||
public class OffsetDateTimeAdapter implements JsonDeserializer<OffsetDateTime> {
|
public class OffsetDateTimeAdapter implements JsonDeserializer<OffsetDateTime>, JsonSerializer<OffsetDateTime> {
|
||||||
|
|
||||||
|
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_INSTANT;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OffsetDateTime deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
|
public OffsetDateTime deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
|
||||||
TemporalAccessor ta = DateTimeFormatter.ISO_INSTANT.parse(jsonElement.getAsString());
|
TemporalAccessor ta = FORMATTER.parse(jsonElement.getAsString());
|
||||||
Instant i = Instant.from(ta);
|
Instant i = Instant.from(ta);
|
||||||
return OffsetDateTime.ofInstant(i, ZoneId.systemDefault());
|
return OffsetDateTime.ofInstant(i, ZoneId.systemDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(OffsetDateTime offsetDateTime, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||||
|
return new JsonPrimitive(FORMATTER.format(offsetDateTime));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,23 @@ public class RoleServiceBean implements RoleService {
|
|||||||
return addRoleToMemberAsync(member.getGuild(), member.getIdLong(), role);
|
return addRoleToMemberAsync(member.getGuild(), member.getIdLong(), role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> updateRolesIds(Member member, List<Long> rolesToRemove, List<Long> rolesToAdd) {
|
||||||
|
List<Role> rolesObjToRemove = rolesToRemove
|
||||||
|
.stream().map(aLong -> member.getGuild().getRoleById(aLong))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
List<Role> rolesObjToAdd = rolesToAdd
|
||||||
|
.stream().map(aLong -> member.getGuild().getRoleById(aLong))
|
||||||
|
.toList();
|
||||||
|
return updateRolesObj(member, rolesObjToRemove, rolesObjToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> updateRolesObj(Member member, List<Role> rolesToRemove, List<Role> rolesToAdd) {
|
||||||
|
return member.getGuild().modifyMemberRoles(member, rolesToAdd, rolesToRemove).submit();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<Void> addRoleToMemberAsync(Member member, Role role) {
|
public CompletableFuture<Void> addRoleToMemberAsync(Member member, Role role) {
|
||||||
return addRoleToMemberAsync(member.getGuild(), member.getIdLong(), role);
|
return addRoleToMemberAsync(member.getGuild(), member.getIdLong(), role);
|
||||||
|
|||||||
@@ -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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package dev.sheldan.abstracto.core.models.template.commands;
|
||||||
|
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.context.UserInitiatedServerContext;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.ChannelDisplay;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
public class EchoRedirectResponseModel extends UserInitiatedServerContext {
|
||||||
|
private ChannelDisplay channel;
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ public interface RoleService {
|
|||||||
void addRoleToMember(AUserInAServer aUserInAServer, ARole role);
|
void addRoleToMember(AUserInAServer aUserInAServer, ARole role);
|
||||||
CompletableFuture<Void> addRoleToUserAsync(AUserInAServer aUserInAServer, ARole role);
|
CompletableFuture<Void> addRoleToUserAsync(AUserInAServer aUserInAServer, ARole role);
|
||||||
CompletableFuture<Void> addRoleToMemberAsync(Member member, Long roleId);
|
CompletableFuture<Void> addRoleToMemberAsync(Member member, Long roleId);
|
||||||
|
CompletableFuture<Void> updateRolesIds(Member member, List<Long> rolesToRemove, List<Long> rolesToAdd);
|
||||||
|
CompletableFuture<Void> updateRolesObj(Member member, List<Role> rolesToRemove, List<Role> rolesToAdd);
|
||||||
CompletableFuture<Void> addRoleToMemberAsync(Member member, Role role);
|
CompletableFuture<Void> addRoleToMemberAsync(Member member, Role role);
|
||||||
void addRoleToMember(Member member, ARole role);
|
void addRoleToMember(Member member, ARole role);
|
||||||
CompletableFuture<Void> addRoleToMemberAsync(Member member, ARole role);
|
CompletableFuture<Void> addRoleToMemberAsync(Member member, ARole role);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||||
<version>1.5.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.core</groupId>
|
<groupId>dev.sheldan.abstracto.core</groupId>
|
||||||
<version>1.5.1</version>
|
<version>1.5.6</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.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-application</artifactId>
|
<artifactId>abstracto-application</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto</groupId>
|
<groupId>dev.sheldan.abstracto</groupId>
|
||||||
<version>1.5.1</version>
|
<version>1.5.6</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>dev.sheldan.abstracto</groupId>
|
|
||||||
<artifactId>abstracto-application</artifactId>
|
|
||||||
<version>1.5.1</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>installer</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def deploy_liquibase(folder, change_log_file, liquibase_path):
|
|
||||||
print("Deploying liquibase of %s in folder %s" % (change_log_file, folder))
|
|
||||||
process = subprocess.Popen(['%s/liquibase' % (liquibase_path), '--defaultsFile=%s' % (change_log_file), '--liquibaseSchemaName=abstracto', '--liquibaseCatalogName=abstracto', '--logLevel=info', 'update'],
|
|
||||||
cwd='liquibase-zips/%s' % (folder),
|
|
||||||
stderr=sys.stderr,
|
|
||||||
stdout=sys.stdout)
|
|
||||||
|
|
||||||
process.communicate()
|
|
||||||
code = process.returncode
|
|
||||||
if code != 0:
|
|
||||||
print("Liquibased deployment failed.")
|
|
||||||
sys.exit(code)
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
import jinja2
|
|
||||||
import json
|
|
||||||
import liquibase_deploy
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import templates_deploy
|
|
||||||
from zipfile import ZipFile
|
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
|
||||||
sys.exit('Wrong amount of parameters.')
|
|
||||||
|
|
||||||
use_folder = False
|
|
||||||
local_folder = None
|
|
||||||
if len(sys.argv) == 4:
|
|
||||||
use_folder = True
|
|
||||||
local_folder = sys.argv[3]
|
|
||||||
|
|
||||||
deploy_templates = sys.argv[1] == 'yes'
|
|
||||||
deploy_liquibase = sys.argv[2] == 'yes'
|
|
||||||
|
|
||||||
class DbConfig:
|
|
||||||
def __init__(self):
|
|
||||||
self.host = os.getenv('DB_HOST')
|
|
||||||
self.port = os.getenv('DB_PORT')
|
|
||||||
self.database = os.getenv('DB_NAME')
|
|
||||||
self.user = os.getenv('DB_USER')
|
|
||||||
self.password = os.getenv('DB_PASS')
|
|
||||||
|
|
||||||
db_config = DbConfig()
|
|
||||||
if not use_folder:
|
|
||||||
print("Not deploying with folder.")
|
|
||||||
postgres_driver_path = os.getenv('POSTGRES_DRIVER')
|
|
||||||
liquibase_path = os.getenv('LIQUIBASE_PATH')
|
|
||||||
print("Loading versions.")
|
|
||||||
with open('artifact_versions.json') as artifact_config_file:
|
|
||||||
artifact_config = json.load(artifact_config_file)
|
|
||||||
|
|
||||||
|
|
||||||
print("Loading templates")
|
|
||||||
templateLoader = jinja2.FileSystemLoader(searchpath="/python/templates")
|
|
||||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
|
||||||
variable_prefix_pattern = re.compile(r'ABSTRACTO_\w+')
|
|
||||||
variables = {}
|
|
||||||
for key, val in os.environ.items():
|
|
||||||
if variable_prefix_pattern.match(key):
|
|
||||||
variables[key.lower().replace('_', '')] = val
|
|
||||||
|
|
||||||
template = templateEnv.get_template("liquibase.properties.j2")
|
|
||||||
|
|
||||||
if deploy_liquibase:
|
|
||||||
print("Starting liquibase deployment")
|
|
||||||
for liquibase_artifact in artifact_config['liquibase_artifacts']:
|
|
||||||
zip_file = liquibase_artifact['zip']
|
|
||||||
target_folder = '/liquibase-zips/' + zip_file
|
|
||||||
with ZipFile('liquibase-zips/' + zip_file + '.zip', 'r') as liquibase_zip:
|
|
||||||
liquibase_zip.extractall(target_folder)
|
|
||||||
change_log_file = liquibase_artifact['file']
|
|
||||||
liquibase_config_text = template.render(change_log_file=change_log_file, db_host=db_config.host, db_port=db_config.port,
|
|
||||||
db_database=db_config.database, db_user=db_config.user, db_password=db_config.password,
|
|
||||||
postgres_driver_path=postgres_driver_path, variables=variables)
|
|
||||||
property_path = target_folder + '/liquibase.properties'
|
|
||||||
with open(property_path, 'w') as liquibase_target_properties:
|
|
||||||
liquibase_target_properties.write(liquibase_config_text)
|
|
||||||
liquibase_deploy.deploy_liquibase(zip_file, property_path, liquibase_path)
|
|
||||||
|
|
||||||
if deploy_templates:
|
|
||||||
print("Deploying templates.")
|
|
||||||
for template_artifact in artifact_config['template_artifacts']:
|
|
||||||
folder_name = template_artifact + "-templates"
|
|
||||||
os.mkdir(folder_name)
|
|
||||||
with ZipFile('templates/' + template_artifact + '.zip', 'r') as template_zip:
|
|
||||||
template_zip.extractall(folder_name)
|
|
||||||
templates_deploy.deploy_template_folder(db_config, folder_name)
|
|
||||||
|
|
||||||
print("Deploying translation templates")
|
|
||||||
for template_artifact in artifact_config['translation_artifacts']:
|
|
||||||
folder_name = template_artifact + "-translations"
|
|
||||||
with ZipFile('translations/' + template_artifact + '.zip', 'r') as template_zip:
|
|
||||||
template_zip.extractall(folder_name)
|
|
||||||
templates_deploy.deploy_template_folder(db_config, folder_name)
|
|
||||||
|
|
||||||
if use_folder:
|
|
||||||
print("Only deploying folder.")
|
|
||||||
templates_deploy.deploy_template_folder(db_config, local_folder)
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
DEPLOY_LIQUIBASE=no
|
|
||||||
DEPLOY_TEMPLATES=no
|
|
||||||
|
|
||||||
echo "Starting deployment."
|
|
||||||
|
|
||||||
if [ "x$EXECUTE_LIQUIBASE" = 'xtrue' ]; then
|
|
||||||
DEPLOY_LIQUIBASE=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "x$EXECUTE_TEMPLATES" = 'xtrue' ]; then
|
|
||||||
DEPLOY_TEMPLATES=yes
|
|
||||||
fi
|
|
||||||
exit_code=0
|
|
||||||
if [ "x$EXECUTE_DEPLOYMENT" = 'xtrue' ]; then
|
|
||||||
python3 -u python/main.py $DEPLOY_TEMPLATES $DEPLOY_LIQUIBASE
|
|
||||||
exit_code=$?
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Finished deployment."
|
|
||||||
exit $exit_code
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
|
||||||
bot:
|
|
||||||
build: deployment
|
|
||||||
image: ${REGISTRY_PREFIX}abstracto_deployment:${VERSION:-latest}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user