Compare commits

...

103 Commits

Author SHA1 Message Date
release-bot
9a5e6e1df2 [maven-release-plugin] prepare release sissi-1.4.67 2024-12-01 12:51:44 +00:00
Sheldan
423bf33402 [SIS-xxx] updating debra texts and handling to 2024 2024-12-01 13:48:40 +01:00
release-bot
f9b193a95b Commit from GitHub Actions (Publishes a new version of Sissi) 2024-11-26 23:34:37 +00:00
release-bot
b46c8a1348 [maven-release-plugin] prepare for next development iteration 2024-11-26 23:30:10 +00:00
release-bot
109a770524 [maven-release-plugin] prepare release sissi-1.4.66 2024-11-26 23:30:09 +00:00
Sheldan
3001b14782 [SIS-xxx] updating abstracto version 2024-11-27 00:27:02 +01:00
release-bot
49932641b3 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-11-26 23:00:20 +00:00
release-bot
829d6cc136 [maven-release-plugin] prepare for next development iteration 2024-11-26 22:55:43 +00:00
release-bot
c28a864a47 [maven-release-plugin] prepare release sissi-1.4.65 2024-11-26 22:55:42 +00:00
Sheldan
fae50c2914 [SIS-xxx] updating abstracto version 2024-11-26 23:52:26 +01:00
Sheldan
8f80df1484 [SIS-xxx] updating abstracto version 2024-11-26 23:24:24 +01:00
release-bot
1b5ed0d70d Commit from GitHub Actions (Publishes a new version of Sissi) 2024-11-22 22:18:06 +00:00
release-bot
098d748b96 [maven-release-plugin] prepare for next development iteration 2024-11-22 22:13:04 +00:00
release-bot
075f3b3201 [maven-release-plugin] prepare release sissi-1.4.64 2024-11-22 22:13:03 +00:00
Sheldan
d5e996e1d0 [SIS-xxx] properly updating abstracto version 2024-11-22 23:08:51 +01:00
release-bot
198054ecfe Commit from GitHub Actions (Publishes a new version of Sissi) 2024-11-22 22:05:56 +00:00
release-bot
efcf93492b [maven-release-plugin] prepare for next development iteration 2024-11-22 22:01:30 +00:00
release-bot
564e22d948 [maven-release-plugin] prepare release sissi-1.4.63 2024-11-22 22:01:29 +00:00
Sheldan
29a1473073 [SIS-xxx] adaption to new abstracto version
removing not needed template
adding suffix to template for level action
2024-11-22 22:58:17 +01:00
Sheldan
208dd8c893 [SIS-xxx] updating abstracto version to 1.5.51
adjusting template names to not use a locale
2024-11-22 22:30:34 +01:00
release-bot
752be470e8 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-11-05 22:35:57 +00:00
release-bot
b9cee83afd [maven-release-plugin] prepare for next development iteration 2024-11-05 22:31:48 +00:00
release-bot
ed9bf49e19 [maven-release-plugin] prepare release sissi-1.4.62 2024-11-05 22:31:46 +00:00
Sheldan
8fe46f6172 [SIS-xxx] updating abstracto version to 1.5.50 2024-11-05 23:28:38 +01:00
release-bot
1bc47d962e Commit from GitHub Actions (Publishes a new version of Sissi) 2024-10-29 22:07:11 +00:00
release-bot
b9ce6f22a7 [maven-release-plugin] prepare for next development iteration 2024-10-29 22:03:06 +00:00
release-bot
45b8c3c588 [maven-release-plugin] prepare release sissi-1.4.61 2024-10-29 22:03:05 +00:00
Sheldan
ba5f34d667 [SIS-xxx] updating abstracto version to 1.5.48 2024-10-29 22:59:22 +01:00
Sheldan
1f5ed1b623 [SIS-xxx] updating abstracto version to 1.5.48 2024-10-29 22:57:32 +01:00
Sheldan
170588d638 [SIS-xxx] adding weekly text feature specific to miepscord server 2024-10-29 22:20:57 +01:00
release-bot
4d69a90d5d Commit from GitHub Actions (Publishes a new version of Sissi) 2024-09-29 20:09:45 +00:00
release-bot
19ed221329 [maven-release-plugin] prepare for next development iteration 2024-09-29 20:05:51 +00:00
release-bot
5ba3036e1d [maven-release-plugin] prepare release sissi-1.4.60 2024-09-29 20:05:50 +00:00
Sheldan
25a4d47dc0 [SIS-xxx] upgrading abstracto version 1.5.47 2024-09-29 22:02:52 +02:00
release-bot
3347fdd8f1 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-09-29 19:32:27 +00:00
release-bot
47eef33850 [maven-release-plugin] prepare for next development iteration 2024-09-29 19:28:19 +00:00
release-bot
583a49df5b [maven-release-plugin] prepare release sissi-1.4.59 2024-09-29 19:28:18 +00:00
Sheldan
ca938a0164 [SIS-xxx] upgrading abstracto version 1.5.46 2024-09-29 21:25:25 +02:00
Sheldan
e22f94ff1e [SIS-xxx] adding text to meetup topic parameter about optionally adding a city 2024-08-19 21:40:49 +02:00
release-bot
307c9eac67 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-08-06 21:10:39 +00:00
release-bot
6002c979d9 [maven-release-plugin] prepare for next development iteration 2024-08-06 21:06:11 +00:00
release-bot
df49c313a4 [maven-release-plugin] prepare release sissi-1.4.58 2024-08-06 21:06:09 +00:00
Sheldan
68bf6b5062 [SIS-xxx] upgrading to abstracto 1.5.44 2024-08-06 23:03:07 +02:00
Sheldan
29eb743c35 [SIS-xxx] upgrading to abstracto 1.5.41 2024-08-02 22:47:52 +02:00
Sheldan
03f9b64db2 [SIS-xxx] changing github actions image version to a concrete version and upgrading to docker compose 2024-08-02 22:37:04 +02:00
Sheldan
212bc09d90 [SIS-xxx] upgrading to abstracto snapshot version
adding template for sending message level action
2024-07-27 19:53:27 +02:00
release-bot
e1f327a687 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-07-12 22:58:34 +00:00
release-bot
7af0d2db1c [maven-release-plugin] prepare for next development iteration 2024-07-12 22:54:33 +00:00
release-bot
b4f740fcf6 [maven-release-plugin] prepare release sissi-1.4.57 2024-07-12 22:54:31 +00:00
Sheldan
dda7ed7db8 [SIS-xxx] making quote attachment URL column larger
changing migration script for starboard/quotes
2024-07-13 00:51:41 +02:00
Sheldan
af006ee880 [SIS-xxx] adding missed starboard sync feature template 2024-07-12 23:05:32 +02:00
release-bot
125febc02a Commit from GitHub Actions (Publishes a new version of Sissi) 2024-07-12 20:55:49 +00:00
release-bot
13f92247cf [maven-release-plugin] prepare for next development iteration 2024-07-12 20:50:49 +00:00
release-bot
79ed55d988 [maven-release-plugin] prepare release sissi-1.4.56 2024-07-12 20:50:47 +00:00
Sheldan
7bc04a7906 [SIS-xxx] adding sync of starboard posts and quotes, including migration script 2024-07-12 22:45:17 +02:00
Sheldan
89d743987d [SIS-xxx] fixing not escaping notification message for meetup participant notification 2024-07-03 19:19:27 +02:00
release-bot
32ddd4e6f0 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-06-13 16:42:12 +00:00
release-bot
68afc31b2e [maven-release-plugin] prepare for next development iteration 2024-06-13 16:37:16 +00:00
release-bot
d0ba46c440 [maven-release-plugin] prepare release sissi-1.4.55 2024-06-13 16:37:14 +00:00
Sheldan
554d197ca4 [SIS-xxx] upgrading to new abstracto version 2024-06-13 18:23:36 +02:00
Sheldan
8826796fcb [SIS-xxx] changing text for ban notification to contain translation 2024-06-02 23:11:07 +02:00
Sheldan
c8ed0e2195 [SIS-xxx] changing text for ban notification to contain the new invite link 2024-05-31 09:32:48 +02:00
release-bot
25d19bfa26 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-05-31 07:18:27 +00:00
release-bot
f7e19b580e [maven-release-plugin] prepare for next development iteration 2024-05-31 07:14:21 +00:00
release-bot
5f6bd0d88e [maven-release-plugin] prepare release sissi-1.4.54 2024-05-31 07:14:20 +00:00
Sheldan
a110c54411 [SIS-xxx] upgrading abstracto version 2024-05-31 09:11:12 +02:00
release-bot
a4a729dfc2 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-05-05 22:32:21 +00:00
release-bot
85eee4835f [maven-release-plugin] prepare for next development iteration 2024-05-05 22:28:20 +00:00
release-bot
cab11140fa [maven-release-plugin] prepare release sissi-1.4.53 2024-05-05 22:28:19 +00:00
Sheldan
5854ca2ba7 [SIS-xxx] upgrading abstracto version 2024-05-06 00:23:34 +02:00
release-bot
3f613eeddf Commit from GitHub Actions (Publishes a new version of Sissi) 2024-04-05 13:34:58 +00:00
release-bot
5fda777a62 [maven-release-plugin] prepare for next development iteration 2024-04-05 13:30:23 +00:00
release-bot
e447eca9dd [maven-release-plugin] prepare release sissi-1.4.52 2024-04-05 13:30:20 +00:00
Sheldan
17e2e09541 [SIS-xxx] upgrading abstracto version 2024-04-05 15:24:39 +02:00
Sheldan
1ea2cc02c8 [SIS-xxx] renaming frontend environment variable 2024-04-05 01:59:12 +02:00
Sheldan
3a1071b65e [SIS-xxx] adding variable to make frontend host available 2024-04-05 01:48:47 +02:00
release-bot
32274561e9 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-27 21:46:01 +00:00
release-bot
b3550549de [maven-release-plugin] prepare for next development iteration 2024-03-27 21:41:57 +00:00
release-bot
eef245ede0 [maven-release-plugin] prepare release sissi-1.4.51 2024-03-27 21:41:55 +00:00
Sheldan
6ac950358f [SIS-xxx] upgrading abstracto version 2024-03-27 22:26:42 +01:00
release-bot
01c59f5059 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-26 23:19:10 +00:00
release-bot
be0325deb9 [maven-release-plugin] prepare for next development iteration 2024-03-26 23:13:55 +00:00
release-bot
f8d84ff943 [maven-release-plugin] prepare release sissi-1.4.50 2024-03-26 23:13:53 +00:00
Sheldan
5ec3b3a1f4 [SIS-xxx] upgrading abstracto version 2024-03-27 00:10:17 +01:00
release-bot
fef1a5f0ae Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-26 21:59:12 +00:00
release-bot
db89b59600 [maven-release-plugin] prepare for next development iteration 2024-03-26 21:54:04 +00:00
release-bot
3ca37c448d [maven-release-plugin] prepare release sissi-1.4.49 2024-03-26 21:54:01 +00:00
Sheldan
b6a416135a [SIS-xxx] upgrading abstracto version 2024-03-26 22:49:11 +01:00
release-bot
ed181a2bc3 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-26 01:29:46 +00:00
release-bot
2ee2cb18f5 [maven-release-plugin] prepare for next development iteration 2024-03-26 01:23:50 +00:00
release-bot
d0908e7315 [maven-release-plugin] prepare release sissi-1.4.48 2024-03-26 01:23:48 +00:00
Sheldan
7c6809500a [SIS-xxx] upgrading abstracto version 2024-03-26 02:09:17 +01:00
release-bot
a6e3f2df17 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-26 00:56:10 +00:00
release-bot
6b35a75539 [maven-release-plugin] prepare for next development iteration 2024-03-26 00:52:03 +00:00
release-bot
32ed3bff5d [maven-release-plugin] prepare release sissi-1.4.47 2024-03-26 00:52:01 +00:00
Sheldan
30765ee80a [SIS-xxx] upgrading abstracto version
adapting to new python rest api structure
2024-03-26 01:33:40 +01:00
release-bot
91a1807abe Commit from GitHub Actions (Publishes a new version of Sissi) 2024-03-17 12:29:30 +00:00
release-bot
2567c139ae [maven-release-plugin] prepare for next development iteration 2024-03-17 12:25:26 +00:00
release-bot
1f141d53de [maven-release-plugin] prepare release sissi-1.4.46 2024-03-17 12:25:24 +00:00
Sheldan
0bd1e7d120 [SIS-xxx] updating abstracto version
adding moderation actions to reaction report embed
fixing syntax in reaction report embed
removing deprecated flag vom tilt file
2024-03-17 13:19:28 +01:00
Sheldan
927f0f8ab2 [SIS-xxx] adding additional reaction report emote 2024-03-11 22:33:14 +01:00
release-bot
c2df483301 Commit from GitHub Actions (Publishes a new version of Sissi) 2024-02-28 20:54:02 +00:00
release-bot
90c36cc506 [maven-release-plugin] prepare for next development iteration 2024-02-28 20:49:55 +00:00
366 changed files with 1651 additions and 157 deletions

4
.env
View File

@@ -1,4 +1,4 @@
REGISTRY_PREFIX=harbor.sheldan.dev/sissi/
ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.4.44
ABSTRACTO_VERSION=1.5.26
VERSION=1.4.66
ABSTRACTO_VERSION=1.5.54

View File

@@ -14,7 +14,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3

View File

@@ -5,7 +5,7 @@ permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
@@ -72,7 +72,7 @@ jobs:
with:
path: .env
- name: Build and push Docker containers
run: docker-compose build && docker-compose push
run: docker compose build && docker compose push
env:
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
VERSION: ${{ steps.dotenv.outputs.version }}

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Sheldan
Copyright (c) 2024 Sheldan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -18,7 +18,7 @@ local_resource(
docker_build_with_restart(
registry + 'sissi-bot',
'./application/executable/target/jar',
entrypoint=['java', '-noverify', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005', '-cp', '.:./lib/*', 'dev.sheldan.sissi.executable.Application'],
entrypoint=['java', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005', '-cp', '.:./lib/*', 'dev.sheldan.sissi.executable.Application'],
dockerfile='./application/executable/Dockerfile',
live_update=[
sync('./application/executable/target/jar/BOOT-INF/lib', '/app/lib'),

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.application</groupId>
<artifactId>application</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>executable</artifactId>
@@ -55,12 +55,13 @@
<artifactId>metrics-impl</artifactId>
</dependency>
<!-- modules containing commands -->
<dependency>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-impl</artifactId>
</dependency>
<!-- modules containing commands -->
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>link-embed-impl</artifactId>
@@ -165,6 +166,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>miepscord</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>rss-news</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi</groupId>
<artifactId>sissi</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>dev.sheldan.sissi.application.module.custom</groupId>
<artifactId>sissi-customizations</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<artifactId>image-generation-custom</artifactId>

View File

@@ -61,7 +61,7 @@ public class OrangeSunDogeCommandAlternative implements CommandAlternative {
List<String> parameters = Arrays.asList(contentStripped.split(" "));
String inputText = commandRegistry.getCommandName(parameters.get(0), message.getGuild().getIdLong());
File triggeredGifFile = imageGenerationService.getOrangeSunDogeImage(inputText);
MessageToSend messageToSend = templateService.renderEmbedTemplate(DOGE_ORANGE_SUN_RESPONSE_TEMPLATE_KEY, new Object());
MessageToSend messageToSend = templateService.renderEmbedTemplate(DOGE_ORANGE_SUN_RESPONSE_TEMPLATE_KEY, new Object(), message.getGuildIdLong());
// template support does not support binary files
AttachedFile file = AttachedFile
.builder()

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.application.module.custom</groupId>
<artifactId>sissi-customizations</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="default_emote.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,11 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="moderation_custom_reaction_message_question_mark_emote-insert">
<insert tableName="default_emote">
<column name="emote_key" value="reactionReport6"/>
<column name="name" value="❓"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -1,7 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd">
<include file="1.1.0/collection.xml" relativeToChangelogFile="true"/>
<include file="1.2.1/collection.xml" relativeToChangelogFile="true"/>
<include file="1.4.45/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -2,7 +2,7 @@ abstracto.featureFlags.moderationCustom.featureName=moderationCustom
abstracto.featureFlags.moderationCustom.enabled=false
abstracto.systemConfigs.reportReactionAmount.name=reportReactionAmount
abstracto.systemConfigs.reportReactionAmount.longValue=5
abstracto.systemConfigs.reportReactionAmount.longValue=7
abstracto.systemConfigs.modModeRoleId.name=modModeRoleId
abstracto.systemConfigs.modModeRoleId.longValue=0

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>application</artifactId>
<groupId>dev.sheldan.sissi.application</groupId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.application</groupId>
<artifactId>sissi-modules</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -124,7 +124,7 @@ public class Donations extends AbstractConditionableCommand {
} else {
donationModel.setDonations(new ArrayList<>());
}
return templateService.renderEmbedTemplate(DONATIONS_RESPONSE_TEMPLATE_KEY, donationModel);
return templateService.renderEmbedTemplate(DONATIONS_RESPONSE_TEMPLATE_KEY, donationModel, serverId);
}
@Override

View File

@@ -182,7 +182,7 @@ public class DonationService {
.donation(donation)
.totalDonationAmount(donationInfoModel.getTotalAmount())
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(DEBRA_DONATION_NOTIFICATION_TEMPLATE_KEY, model);
MessageToSend messageToSend = templateService.renderEmbedTemplate(DEBRA_DONATION_NOTIFICATION_TEMPLATE_KEY, model, targetServerId);
List<CompletableFuture<Message>> firstMessage = postTargetService.sendEmbedInPostTarget(messageToSend, DebraPostTarget.DEBRA_DONATION_NOTIFICATION, targetServerId);
List<CompletableFuture<Message>> secondMessage = postTargetService.sendEmbedInPostTarget(messageToSend, DebraPostTarget.DEBRA_DONATION_NOTIFICATION2, targetServerId);
firstMessage.addAll(secondMessage);

View File

@@ -5,7 +5,7 @@ abstracto.postTargets.debraDonationNotification.name=debraDonationNotification
abstracto.postTargets.debraDonationNotification2.name=debraDonationNotification2
sissi.debra.websocketURL=ws://spenden.baba.fm:8765/
sissi.debra.donationAPIUrl=https://www.altruja.de/api/page/discord-gg-austria-fuer-debra-2023?details=1&num=%s&ort=0
sissi.debra.donationAPIUrl=https://www.altruja.de/api/page/discord-schmetterlingsaktion-2024?details=1&num=%s&ort=0
abstracto.systemConfigs.debraDonationNotificationDelayMillis.name=debraDonationNotificationDelayMillis
abstracto.systemConfigs.debraDonationNotificationDelayMillis.longValue=60000

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.application</groupId>
<artifactId>sissi-modules</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -115,7 +115,7 @@ public class MeetupConfirmationListener implements ButtonClickedListener {
messageModel.setCancelled(false);
Long meetupId = payload.getMeetupId();
Long serverId = payload.getGuildId();
MessageToSend messageToSend = meetupServiceBean.getMeetupMessage(messageModel);
MessageToSend messageToSend = meetupServiceBean.getMeetupMessage(messageModel, model.getServerId());
List<CompletableFuture<Message>> messageFutures = channelService.sendMessageToSendToChannel(messageToSend, model.getEvent().getMessageChannel());
FutureUtils.toSingleFutureGeneric(messageFutures).thenAccept(unused -> {
messageService.deleteMessage(model.getEvent().getMessage());

View File

@@ -59,7 +59,7 @@ public class MeetupDecisionListener implements ButtonClickedListener {
}
MeetupMessageModel meetupMessageModel = meetupServiceBean.getMeetupMessageModel(meetup);
addParticipationToModel(meetupMessageModel, userInAServer, payload.getMeetupDecision());
MessageToSend messageToSend = meetupServiceBean.getMeetupMessage(meetupMessageModel);
MessageToSend messageToSend = meetupServiceBean.getMeetupMessage(meetupMessageModel, model.getServerId());
channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), model.getEvent().getChannel(), meetup.getMessageId())
.thenAccept(message -> log.info("Updated message of meetup {} in channel {} in server {}.", meetup.getId().getId(), meetup.getMeetupChannel().getId(), meetup.getServer().getId()))
.exceptionally(throwable -> {

View File

@@ -206,8 +206,8 @@ public class MeetupServiceBean {
.collect(Collectors.toList());
}
public MessageToSend getMeetupMessage(MeetupMessageModel model) {
return templateService.renderEmbedTemplate(MEETUP_DISPLAY_TEMPLATE, model);
public MessageToSend getMeetupMessage(MeetupMessageModel model, Long serverId) {
return templateService.renderEmbedTemplate(MEETUP_DISPLAY_TEMPLATE, model, serverId);
}
public CompletableFuture<Void> cancelMeetup(Meetup meetup) {
@@ -221,7 +221,7 @@ public class MeetupServiceBean {
.map(meetupComponent -> meetupComponent.getId().getComponentId())
.collect(Collectors.toList());
model.setCancelled(true);
MessageToSend meetupMessage = getMeetupMessage(model);
MessageToSend meetupMessage = getMeetupMessage(model, serverId);
return messageService.editMessageInChannel(channel, meetupMessage, meetup.getMessageId())
.thenAccept(unused -> self.notifyParticipants(meetupId, serverId))
.thenAccept(unused -> self.cleanupMeetup(meetupId, serverId, componentPayloads));
@@ -231,7 +231,7 @@ public class MeetupServiceBean {
public void notifyParticipants(Long meetupId, Long serverId) {
Meetup meetup = meetupManagementServiceBean.getMeetup(meetupId, serverId);
MeetupMessageModel model = getMeetupMessageModel(meetup);
MessageToSend messageToSend = templateService.renderEmbedTemplate(MEETUP_CANCELLATION_TEMPLATE, model);
MessageToSend messageToSend = templateService.renderEmbedTemplate(MEETUP_CANCELLATION_TEMPLATE, model, serverId);
meetup
.getParticipants()
.stream()
@@ -319,7 +319,7 @@ public class MeetupServiceBean {
public void remindParticipants(Long meetupId, Long serverId) {
Meetup meetup = meetupManagementServiceBean.getMeetup(meetupId, serverId);
MeetupMessageModel model = getMeetupMessageModel(meetup);
MessageToSend messageToSend = templateService.renderEmbedTemplate(MEETUP_REMINDER_TEMPLATE, model);
MessageToSend messageToSend = templateService.renderEmbedTemplate(MEETUP_REMINDER_TEMPLATE, model, serverId);
meetup
.getParticipants()
.stream()
@@ -423,7 +423,7 @@ public class MeetupServiceBean {
meetupMessageModel.setMaybeParticipants(new ArrayList<>());
meetupMessageModel.setNoTimeParticipants(new ArrayList<>());
MessageToSend updatedMeetupMessage = getMeetupMessage(meetupMessageModel);
MessageToSend updatedMeetupMessage = getMeetupMessage(meetupMessageModel, serverId);
GuildMessageChannel meetupChannel = channelService.getMessageChannelFromServer(serverId, meetup.getMeetupChannel().getId());
return channelService.editMessageInAChannelFuture(updatedMeetupMessage, meetupChannel, meetup.getMessageId())
.thenAccept(message -> log.info("Updated message of meetup {} in channel {} in server {}.", meetupId, meetup.getMeetupChannel().getId(), serverId))
@@ -457,7 +457,7 @@ public class MeetupServiceBean {
Long meetupId = meetup.getId().getId();
Long serverId = meetup.getId().getServerId();
MeetupMessageModel meetupMessageModel = getMeetupMessageModel(meetup);
MessageToSend updatedMeetupMessage = getMeetupMessage(meetupMessageModel);
MessageToSend updatedMeetupMessage = getMeetupMessage(meetupMessageModel, serverId);
GuildMessageChannel meetupChannel = channelService.getMessageChannelFromServer(serverId, meetup.getMeetupChannel().getId());
return channelService.editMessageInAChannelFuture(updatedMeetupMessage, meetupChannel, meetup.getMessageId())
.thenAccept(message -> log.info("Updated message of meetup {} in channel {} in server {}.", meetupId, meetup.getMeetupChannel().getId(), serverId))

View File

@@ -0,0 +1,43 @@
<?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>
<artifactId>sissi-modules</artifactId>
<groupId>dev.sheldan.sissi.application</groupId>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>miepscord</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/liquibase.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-int</artifactId>
<version>${abstracto.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>liquibase</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>.</outputDirectory>
<directory>${project.basedir}/src/main/resources/migrations</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,15 @@
package dev.sheldan.sissi.module.miepscord;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import lombok.Getter;
@Getter
public enum MiepscordFeatureDefinition implements FeatureDefinition {
WEEKLY_TEXT("weeklyText");
private String key;
MiepscordFeatureDefinition(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,9 @@
package dev.sheldan.sissi.module.miepscord;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:miepscord.properties")
public class MiepscordProperties {
}

View File

@@ -0,0 +1,6 @@
package dev.sheldan.sissi.module.miepscord;
public class MiepscordSlashCommandNames {
public static final String MIEPSCORD_ROOT_NAME = "miepscord";
public static final String MIEPSCORD_ROOT_NAME_CONFIG = "miepscordManage";
}

View File

@@ -0,0 +1,90 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
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.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.sissi.module.miepscord.MiepscordFeatureDefinition;
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
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 AddTextItem extends AbstractConditionableCommand {
private static final String ADD_WEEKLY_TEXT_TEXT_PARAMETER = "text";
private static final String ADD_WEEKLY_TEXT_COMMAND_NAME = "addWeeklyText";
private static final String ADD_WEEKLY_TEXT_RESPONSE = "addWeeklyText_response";
@Autowired
private SlashCommandParameterService slashCommandParameterService;
@Autowired
private TextItemServiceBean textItemServiceBean;
@Autowired
private InteractionService interactionService;
@Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
String weeklyText = slashCommandParameterService.getCommandOption(ADD_WEEKLY_TEXT_TEXT_PARAMETER, event, String.class);
textItemServiceBean.createTextItem(weeklyText, event.getMember());
return interactionService.replyEmbed(ADD_WEEKLY_TEXT_RESPONSE, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter textitemTextParameter = Parameter
.builder()
.templated(true)
.name(ADD_WEEKLY_TEXT_TEXT_PARAMETER)
.type(String.class)
.build();
List<Parameter> parameters = Arrays.asList(textitemTextParameter);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
SlashCommandConfig slashCommandConfig = SlashCommandConfig
.builder()
.enabled(true)
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME_CONFIG)
.groupName("weeklytexts")
.commandName("add")
.build();
return CommandConfiguration.builder()
.name(ADD_WEEKLY_TEXT_COMMAND_NAME)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.slashCommandConfig(slashCommandConfig)
.async(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return MiepscordFeatureDefinition.WEEKLY_TEXT;
}
}

View File

@@ -0,0 +1,91 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
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.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.sissi.module.miepscord.MiepscordFeatureDefinition;
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
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 RemoveTextItem extends AbstractConditionableCommand {
private static final String REMOVE_WEEKLY_TEXT_ID_PARAMETER = "id";
private static final String REMOVE_WEEKLY_TEXT_COMMAND_NAME = "removeWeeklyText";
private static final String REMOVE_WEEKLY_TEXT_RESPONSE = "removeWeeklyText_response";
@Autowired
private SlashCommandParameterService slashCommandParameterService;
@Autowired
private TextItemServiceBean textItemServiceBean;
@Autowired
private InteractionService interactionService;
@Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
Long itemId = slashCommandParameterService.getCommandOption(REMOVE_WEEKLY_TEXT_ID_PARAMETER, event, Integer.class).longValue();
textItemServiceBean.removeTextItem(itemId);
return interactionService.replyEmbed(REMOVE_WEEKLY_TEXT_RESPONSE, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter textItemId = Parameter
.builder()
.templated(true)
.name(REMOVE_WEEKLY_TEXT_ID_PARAMETER)
.type(Long.class)
.build();
List<Parameter> parameters = Arrays.asList(textItemId);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
SlashCommandConfig slashCommandConfig = SlashCommandConfig
.builder()
.enabled(true)
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME_CONFIG)
.groupName("weeklytexts")
.commandName("remove")
.build();
return CommandConfiguration.builder()
.name(REMOVE_WEEKLY_TEXT_COMMAND_NAME)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.slashCommandConfig(slashCommandConfig)
.async(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return MiepscordFeatureDefinition.WEEKLY_TEXT;
}
}

View File

@@ -0,0 +1,137 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.commands;
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.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.core.service.PaginatorService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
import dev.sheldan.sissi.module.miepscord.MiepscordSlashCommandNames;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.ShowTextItemModel;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.ShowTextItemsModel;
import dev.sheldan.sissi.module.miepscord.weeklytext.service.management.TextItemServiceManagementBean;
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.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@Component
public class ShowTextItems extends AbstractConditionableCommand {
private static final String SHOW_WEEKLY_TEXTS_COMMAND_NAME = "showWeeklyTexts";
private static final String SHOW_WEEKLY_TEXTS_RESPONSE_TEMPLATE = "showWeeklyTexts";
public static final String NO_ITEMS_TEMPLATE_KEY = "showWeeklyTexts_no_items_found";
private static final String SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER = "showAll";
@Autowired
private TextItemServiceManagementBean textItemServiceManagementBean;
@Autowired
private PaginatorService paginatorService;
@Autowired
private TemplateService templateService;
@Autowired
private InteractionService interactionService;
@Autowired
private SlashCommandParameterService slashCommandParameterService;
@Override
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
boolean showAll = false;
if(slashCommandParameterService.hasCommandOption(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER, event)) {
showAll = slashCommandParameterService.getCommandOption(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER, event, Boolean.class);
}
List<TextItem> textItems;
if(showAll) {
textItems = textItemServiceManagementBean.getAllTextItems();
} else {
textItems = textItemServiceManagementBean.getAllTextItemsWithDoneFlag(false);
}
textItems.sort(Comparator.comparing(TextItem::getCreated));
if(textItems.isEmpty()) {
MessageToSend messageToSend = templateService.renderEmbedTemplate(NO_ITEMS_TEMPLATE_KEY, new Object(), event.getGuild().getIdLong());
return interactionService.replyMessageToSend(messageToSend, event)
.thenApply(interactionHook -> CommandResult.fromSuccess());
}
List<ShowTextItemModel> convertedTextItems = textItems.stream().map(this::convertTextItem).toList();
ShowTextItemsModel items = ShowTextItemsModel
.builder()
.items(convertedTextItems)
.build();
return paginatorService.createPaginatorFromTemplate(SHOW_WEEKLY_TEXTS_RESPONSE_TEMPLATE, items, event)
.thenApply(unused -> CommandResult.fromIgnored());
}
private ShowTextItemModel convertTextItem(TextItem textItem) {
return ShowTextItemModel
.builder()
.text(textItem.getText())
.id(textItem.getId())
.done(textItem.getDone())
.created(textItem.getCreated())
.build();
}
@Override
public CommandConfiguration getConfiguration() {
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
Parameter showAllItems = Parameter
.builder()
.name(SHOW_WEEKLY_TEXT_SHOW_ALL_PARAMETER)
.type(Boolean.class)
.optional(true)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(showAllItems);
SlashCommandConfig slashCommandConfig = SlashCommandConfig
.builder()
.enabled(true)
.rootCommandName(MiepscordSlashCommandNames.MIEPSCORD_ROOT_NAME)
.groupName("weeklytexts")
.commandName("show")
.build();
return CommandConfiguration.builder()
.name(SHOW_WEEKLY_TEXTS_COMMAND_NAME)
.module(UtilityModuleDefinition.UTILITY)
.templated(true)
.slashCommandOnly(true)
.slashCommandConfig(slashCommandConfig)
.async(true)
.parameters(parameters)
.supportsEmbedException(true)
.causesReaction(true)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return MiepscordFeatureDefinition.WEEKLY_TEXT;
}
}

View File

@@ -0,0 +1,27 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.config;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import dev.sheldan.sissi.module.miepscord.MiepscordFeatureDefinition;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class WeeklyTextFeatureConfig implements FeatureConfig {
public static final String WEEKLY_TEXT_SERVER_ID = "WEEKLY_TEXT_SERVER_ID";
@Override
public FeatureDefinition getFeature() {
return MiepscordFeatureDefinition.WEEKLY_TEXT;
}
@Override
public List<PostTargetEnum> getRequiredPostTargets() {
return Arrays.asList(WeeklyTextPostTarget.TEXT_ITEM_TARGET);
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.config;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import lombok.Getter;
@Getter
public enum WeeklyTextPostTarget implements PostTargetEnum {
TEXT_ITEM_TARGET("textItemTarget");
private String key;
WeeklyTextPostTarget(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,31 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.job;
import dev.sheldan.sissi.module.miepscord.weeklytext.service.TextItemServiceBean;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
@Slf4j
@DisallowConcurrentExecution
@Component
@PersistJobDataAfterExecution
public class WeeklyTextJob extends QuartzJobBean {
@Autowired
private TextItemServiceBean textItemServiceBean;
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
try {
log.info("Executing text item job.");
textItemServiceBean.sendTexItem();
} catch (Exception e) {
log.error("Text item job failed.", e);
}
}
}

View File

@@ -0,0 +1,38 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.model.database;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import jakarta.persistence.*;
import lombok.*;
import java.time.Instant;
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "text_item")
@Getter
@Setter
@EqualsAndHashCode
public class TextItem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "text")
private String text;
@Column(name = "done")
private Boolean done;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "creator_id", nullable = false)
private AUserInAServer creator;
@Column(name = "created")
private Instant created;
@Column(name = "updated")
private Instant updated;
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
import lombok.Builder;
import lombok.Getter;
import java.time.Instant;
@Builder
@Getter
public class ShowTextItemModel {
private String text;
private Boolean done;
private Instant created;
private Long id;
}

View File

@@ -0,0 +1,12 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
import lombok.Builder;
import lombok.Getter;
import java.util.List;
@Builder
@Getter
public class ShowTextItemsModel {
private List<ShowTextItemModel> items;
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.model.template;
import lombok.Builder;
import lombok.Getter;
import java.time.Instant;
@Builder
@Getter
public class TextItemPostModel {
private String text;
private Long id;
private Instant created;
}

View File

@@ -0,0 +1,13 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.repository;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface TextItemRepository extends JpaRepository<TextItem, Long> {
List<TextItem> findByDoneFalseOrderByCreated();
List<TextItem> findByDone(Boolean done);
}

View File

@@ -0,0 +1,89 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.service;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.PostTargetService;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
import dev.sheldan.sissi.module.miepscord.weeklytext.config.WeeklyTextPostTarget;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.template.TextItemPostModel;
import dev.sheldan.sissi.module.miepscord.weeklytext.service.management.TextItemServiceManagementBean;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import static dev.sheldan.sissi.module.miepscord.weeklytext.config.WeeklyTextFeatureConfig.WEEKLY_TEXT_SERVER_ID;
@Component
@Slf4j
public class TextItemServiceBean {
public static final String WEEKLY_TEXT_ITEM_POST_TEMPLATE = "weekly_text_item_post";
@Autowired
private TextItemServiceManagementBean textItemServiceManagementBean;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Autowired
private PostTargetService postTargetService;
@Autowired
private TemplateService templateService;
@Autowired
private TextItemServiceBean self;
public TextItem createTextItem(String text, Member creator) {
log.info("Creating new text item in server {} from user {}.", creator.getGuild().getIdLong(), creator.getIdLong());
AUserInAServer creatorUser = userInServerManagementService.loadOrCreateUser(creator);
return textItemServiceManagementBean.createTextItem(text, creatorUser);
}
public CompletableFuture<Void> sendTexItem() {
Long serverId = Long.parseLong(System.getenv(WEEKLY_TEXT_SERVER_ID));
Optional<TextItem> nextTextItemOptional = textItemServiceManagementBean.getNextTextItem();
if(nextTextItemOptional.isEmpty()) {
log.info("No next text item found.");
return CompletableFuture.completedFuture(null);
}
TextItem textItem = nextTextItemOptional.get();
log.info("Sending text item {}.", textItem.getId());
Long textItemId = textItem.getId();
TextItemPostModel model = TextItemPostModel
.builder()
.id(textItemId)
.created(textItem.getCreated())
.text(textItem.getText())
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(WEEKLY_TEXT_ITEM_POST_TEMPLATE, model, serverId);
List<CompletableFuture<Message>> futures = postTargetService.sendEmbedInPostTarget(messageToSend, WeeklyTextPostTarget.TEXT_ITEM_TARGET, serverId);
CompletableFutureList<Message> futureList = new CompletableFutureList<>(futures);
return futureList.getMainFuture().thenAccept(unused -> {
self.setTexItemToDone(textItemId);
});
}
@Transactional
public void setTexItemToDone(Long id) {
Optional<TextItem> textItemOptional = textItemServiceManagementBean.findTextItemById(id);
textItemOptional.ifPresentOrElse(textItem -> {
log.info("Setting textItem with ID {} to done.", id);
textItem.setDone(true);
}, () -> log.info("TextItem {} not found.", id));
}
public void removeTextItem(Long id) {
log.info("Deleting text item with ID {}.", id);
textItemServiceManagementBean.deleteById(id);
}
}

View File

@@ -0,0 +1,56 @@
package dev.sheldan.sissi.module.miepscord.weeklytext.service.management;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.sissi.module.miepscord.weeklytext.model.database.TextItem;
import dev.sheldan.sissi.module.miepscord.weeklytext.repository.TextItemRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.security.SecureRandom;
import java.util.List;
import java.util.Optional;
@Component
public class TextItemServiceManagementBean {
@Autowired
private TextItemRepository textItemRepository;
@Autowired
private SecureRandom secureRandom;
public TextItem createTextItem(String text, AUserInAServer aUserInAServer) {
TextItem textItem = TextItem
.builder()
.text(text)
.creator(aUserInAServer)
.done(false)
.build();
return textItemRepository.save(textItem);
}
public Optional<TextItem> getNextTextItem() {
List<TextItem> allItems = textItemRepository.findByDoneFalseOrderByCreated();
if(allItems.isEmpty()) {
return Optional.empty();
} else {
return Optional.of(allItems.get(secureRandom.nextInt(allItems.size())));
}
}
public Optional<TextItem> findTextItemById(Long id) {
return textItemRepository.findById(id);
}
public void deleteById(Long id) {
textItemRepository.deleteById(id);
}
public List<TextItem> getAllTextItems() {
return textItemRepository.findAll();
}
public List<TextItem> getAllTextItemsWithDoneFlag(boolean done) {
return textItemRepository.findByDone(done);
}
}

View File

@@ -0,0 +1,4 @@
abstracto.featureFlags.weeklyText.featureName=weeklyText
abstracto.featureFlags.weeklyText.enabled=false
abstracto.postTargets.textItemTarget.name=textItemTarget

View File

@@ -0,0 +1,7 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,24 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
<property name="weeklyTextFeature" value="(SELECT id FROM feature WHERE key = 'weeklyText')"/>
<changeSet author="Sheldan" id="weeklyText-commands" >
<insert tableName="command">
<column name="name" value="addWeeklyText"/>
<column name="module_id" valueComputed="${utilityModule}"/>
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="removeWeeklyText"/>
<column name="module_id" valueComputed="${utilityModule}"/>
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="showWeeklyTexts"/>
<column name="module_id" valueComputed="${utilityModule}"/>
<column name="feature_id" valueComputed="${weeklyTextFeature}"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="feature.xml" relativeToChangelogFile="true"/>
<include file="command.xml" relativeToChangelogFile="true"/>
<include file="weekly_text_job.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="weeklyText_feature-insertion">
<insert tableName="feature">
<column name="key" value="weeklyText"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="weekly_text_job-insert">
<insert tableName="scheduler_job">
<column name="name" value="weeklyTextJob"/>
<column name="group_name" value="miepscord"/>
<column name="clazz" value="dev.sheldan.sissi.module.miepscord.weeklytext.job.WeeklyTextJob"/>
<column name="active" value="true"/>
<column name="cron_expression" value="0 0 14 ? * FRI *"/>
<column name="recovery" value="false"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="text_item.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,38 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="text_item-table">
<createTable tableName="text_item">
<column name="id" autoIncrement="true" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_text_item"/>
</column>
<column name="text" type="VARCHAR">
<constraints nullable="false"/>
</column>
<column name="done" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="creator_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="true"/>
</column>
<column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="creator_id" baseTableName="text_item" constraintName="fk_text_item_creator"
deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION"
referencedColumnNames="user_in_server_id" referencedTableName="user_in_server" validate="true"/>
<sql>
DROP TRIGGER IF EXISTS text_item_update_trigger ON text_item;
CREATE TRIGGER repost_check_channel_group_update_trigger BEFORE UPDATE ON text_item FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
</sql>
<sql>
DROP TRIGGER IF EXISTS text_item_insert_trigger ON text_item;
CREATE TRIGGER repost_check_channel_group_insert_trigger BEFORE INSERT ON text_item FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="1.4.61/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.application</groupId>
<artifactId>application</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,13 +3,21 @@
<parent>
<groupId>dev.sheldan.sissi.application</groupId>
<artifactId>sissi-modules</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>quotes</artifactId>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>starboard-int</artifactId>
<version>${abstracto.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>

View File

@@ -53,7 +53,7 @@ public class QuoteStats extends AbstractConditionableCommand {
targetMember = (Member) parameters.get(0);
}
QuoteStatsModel model = quoteServiceBean.getQuoteStats(targetMember);
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannelList(QUOTE_STATS_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInMessageChannel(QUOTE_STATS_RESPONSE_TEMPLATE_KEY, model, commandContext.getChannel()))
.thenApply(unused -> CommandResult.fromSuccess());
}

View File

@@ -5,7 +5,7 @@ import lombok.Getter;
@Getter
public enum QuotesFeatureDefinition implements FeatureDefinition {
QUOTES("quotes");
QUOTES("quotes"), STARBOARD_QUOTE_SYNC("starboardQuoteSync");
private String key;

View File

@@ -0,0 +1,13 @@
package dev.sheldan.sissi.module.quotes.config;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import org.springframework.stereotype.Component;
@Component
public class StarboardQuoteSyncFeatureConfig implements FeatureConfig {
@Override
public FeatureDefinition getFeature() {
return QuotesFeatureDefinition.STARBOARD_QUOTE_SYNC;
}
}

View File

@@ -0,0 +1,54 @@
package dev.sheldan.sissi.module.quotes.listener;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.core.service.MessageService;
import dev.sheldan.abstracto.starboard.listener.StarboardPostCreatedListener;
import dev.sheldan.abstracto.starboard.model.StarboardPostCreatedModel;
import dev.sheldan.sissi.module.quotes.config.QuotesFeatureDefinition;
import dev.sheldan.sissi.module.quotes.service.QuoteServiceBean;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Slf4j
@Component
public class StarboardPostCreatedListenerBean implements StarboardPostCreatedListener {
@Autowired
private MessageService messageService;
@Autowired
private QuoteServiceBean quoteServiceBean;
@Autowired
private StarboardPostCreatedListenerBean self;
@Override
public DefaultListenerResult execute(StarboardPostCreatedModel model) {
Long serverId = model.getServerId();
Long starboardPostId = model.getStarboardPostId();
messageService.loadMessage(serverId, model.getStarredMessage().getChannelId(), model.getStarredMessage().getMessageId())
.thenAccept(message -> self.storeQuote(message, model))
.exceptionally(throwable -> {
log.error("Failed to persist quote for starboard post {} in server {}.", starboardPostId, serverId, throwable);
return null;
});
return DefaultListenerResult.PROCESSED;
}
@Transactional
public void storeQuote(Message message, StarboardPostCreatedModel model) {
log.info("Creating quote from starboard post {} in server {} from user {} because of user {}.", model.getStarboardPostId(), model.getServerId(),
model.getStarredUser().getUserId(), model.getLastStarrer().getUserId());
quoteServiceBean.createQuote(model.getStarredUser(), model.getLastStarrer(), message);
}
@Override
public FeatureDefinition getFeature() {
return QuotesFeatureDefinition.STARBOARD_QUOTE_SYNC;
}
}

View File

@@ -0,0 +1,32 @@
package dev.sheldan.sissi.module.quotes.listener;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.starboard.listener.StarboardPostDeletedListener;
import dev.sheldan.abstracto.starboard.model.StarboardPostDeletedModel;
import dev.sheldan.sissi.module.quotes.config.QuotesFeatureDefinition;
import dev.sheldan.sissi.module.quotes.service.QuoteServiceBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class StarboardPostDeletedListenerBean implements StarboardPostDeletedListener {
@Autowired
private QuoteServiceBean quoteServiceBean;
@Override
public DefaultListenerResult execute(StarboardPostDeletedModel model) {
log.info("Handling delete of starboard post {}, causing the quote of message {} in server {} to be deleted.", model.getStarboardPostId(), model.getStarredMessage().getMessageId(), model.getServerId());
quoteServiceBean.deleteByMessageId(model.getStarredMessage().getMessageId());
return DefaultListenerResult.PROCESSED;
}
@Override
public FeatureDefinition getFeature() {
return QuotesFeatureDefinition.STARBOARD_QUOTE_SYNC;
}
}

View File

@@ -21,12 +21,12 @@ import java.util.List;
@EqualsAndHashCode
public class Quote {
@EmbeddedId
@Getter
private ServerSpecificId id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@MapsId("serverId")
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
@@ -58,9 +58,9 @@ public class Quote {
@Column(name = "text")
private String text;
@Column(name = "created")
@Column(name = "created", insertable = false, updatable = false)
private Instant created;
@Column(name = "updated")
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
}

View File

@@ -1,5 +1,6 @@
package dev.sheldan.sissi.module.quotes.model.database;
import dev.sheldan.abstracto.core.models.database.AServer;
import lombok.*;
import jakarta.persistence.*;
@@ -16,7 +17,7 @@ public class QuoteAttachment {
@Id
@Getter
@Setter
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@@ -25,8 +26,7 @@ public class QuoteAttachment {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns(
{
@JoinColumn(updatable = false, insertable = false, name = "quote_id", referencedColumnName = "id"),
@JoinColumn(updatable = false, insertable = false, name = "server_id", referencedColumnName = "server_id")
@JoinColumn(updatable = false, name = "quote_id", referencedColumnName = "id")
})
private Quote quote;
@@ -35,6 +35,10 @@ public class QuoteAttachment {
@Column(name = "url", nullable = false)
private String url;
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
@Getter
@Setter
@Column(name = "is_image", nullable = false)

View File

@@ -1,6 +1,5 @@
package dev.sheldan.sissi.module.quotes.repository;
import dev.sheldan.abstracto.core.models.ServerSpecificId;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.sissi.module.quotes.model.database.Quote;
@@ -8,13 +7,16 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface QuoteRepository extends JpaRepository<Quote, ServerSpecificId> {
public interface QuoteRepository extends JpaRepository<Quote, Long> {
List<Quote> findByTextContainingAndServer(String text, AServer server);
List<Quote> findByTextContainingAndServerAndAuthor(String text, AServer server, AUserInAServer author);
List<Quote> findByServer(AServer server);
List<Quote> findByAuthor(AUserInAServer author);
Long countByAuthor(AUserInAServer author);
Long countByAdder(AUserInAServer adder);
Optional<Quote> findByMessageId(Long messageId);
}

View File

@@ -1,7 +1,7 @@
package dev.sheldan.sissi.module.quotes.service;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import dev.sheldan.abstracto.core.models.ServerSpecificId;
import dev.sheldan.abstracto.core.models.ServerUser;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.ChannelService;
@@ -16,11 +16,12 @@ import dev.sheldan.sissi.module.quotes.model.command.QuoteResponseModel;
import dev.sheldan.sissi.module.quotes.model.command.QuoteStatsModel;
import dev.sheldan.sissi.module.quotes.model.database.Quote;
import dev.sheldan.sissi.module.quotes.model.database.QuoteAttachment;
import dev.sheldan.sissi.module.quotes.repository.QuoteRepository;
import dev.sheldan.sissi.module.quotes.service.management.QuoteManagementService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.Channel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -35,9 +36,6 @@ import java.util.stream.Collectors;
@Slf4j
public class QuoteServiceBean {
@Autowired
private QuoteRepository quoteRepository;
@Autowired
private MemberService memberService;
@@ -56,11 +54,14 @@ public class QuoteServiceBean {
@Autowired
private ChannelService channelService;
@Autowired
private QuoteManagementService quoteManagementService;
private static final String QUOTE_RESPONSE_TEMPLATE_KEY = "quote_response";
public Optional<Quote> getRandomQuoteForMember(AUserInAServer aUserInAServer) {
// not nice, but good enough for now
List<Quote> allQuotes = quoteRepository.findByAuthor(aUserInAServer);
List<Quote> allQuotes = quoteManagementService.getFromAuthor(aUserInAServer);
if(allQuotes.isEmpty()) {
return Optional.empty();
}
@@ -69,7 +70,7 @@ public class QuoteServiceBean {
public Optional<Quote> getRandomQuote(AServer server) {
// not nice, but good enough for now
List<Quote> allQuotes = quoteRepository.findByServer(server);
List<Quote> allQuotes = quoteManagementService.getFromServer(server);
if(allQuotes.isEmpty()) {
return Optional.empty();
}
@@ -79,7 +80,7 @@ public class QuoteServiceBean {
public void deleteQuote(Long quoteId, AServer server) {
Optional<Quote> existingQuote = getQuote(quoteId, server);
if(existingQuote.isPresent()) {
quoteRepository.delete(existingQuote.get());
quoteManagementService.deleteQuote(existingQuote.get());
log.info("Deleting quote with id {} in server {}.", quoteId, server.getId());
} else {
throw new QuoteNotFoundException();
@@ -87,9 +88,8 @@ public class QuoteServiceBean {
}
public Optional<Quote> getQuote(Long quoteId, AServer server) {
ServerSpecificId id = new ServerSpecificId(server.getId(), quoteId);
log.info("Loading quote with id {} in server {}.", quoteId, server.getId());
return quoteRepository.findById(id);
return quoteManagementService.getQuote(quoteId);
}
public CompletableFuture<MessageToSend> renderQuoteToMessageToSend(Quote quote) {
@@ -118,7 +118,7 @@ public class QuoteServiceBean {
.builder()
.quoteContent(quote.getText())
.imageAttachmentURLs(imageAttachments)
.quoteId(quote.getId().getId())
.quoteId(quote.getId())
.fileAttachmentURLs(fileAttachments)
.creationDate(quote.getCreated())
.quotedMessage(quotedMessage);
@@ -209,7 +209,7 @@ public class QuoteServiceBean {
}
public Optional<Quote> searchQuote(String query, AServer server) {
List<Quote> foundQuotes = quoteRepository.findByTextContainingAndServer(query, server);
List<Quote> foundQuotes = quoteManagementService.getQuotesWithTextInServer(query, server);
if(foundQuotes.isEmpty()) {
return Optional.empty();
}
@@ -224,7 +224,7 @@ public class QuoteServiceBean {
public Optional<Quote> searchQuote(String query, AServer server, Member targetMember) {
AUserInAServer author = userInServerManagementService.loadOrCreateUser(targetMember);
List<Quote> foundQuotes = quoteRepository.findByTextContainingAndServerAndAuthor(query, server, author);
List<Quote> foundQuotes = quoteManagementService.getQuotesWithTextInServerFromAuthor(query, server, author);
if(foundQuotes.isEmpty()) {
return Optional.empty();
}
@@ -242,8 +242,8 @@ public class QuoteServiceBean {
return getQuoteStats(user, member);
}
public QuoteStatsModel getQuoteStats(AUserInAServer user, Member member) {
Long authored = quoteRepository.countByAuthor(user);
Long added = quoteRepository.countByAdder(user);
Long authored = quoteManagementService.getAmountOfQuotesOfAuthor(user);
Long added = quoteManagementService.getAmountOfQuotesOfAdder(user);
return QuoteStatsModel
.builder()
.quoteCount(added)
@@ -253,4 +253,21 @@ public class QuoteServiceBean {
.serverId(user.getServerReference().getId())
.build();
}
public Quote createQuote(ServerUser authorUser, ServerUser adderUser, Message quoteMessage) {
AUserInAServer author = userInServerManagementService.loadOrCreateUser(authorUser);
AUserInAServer adder = userInServerManagementService.loadOrCreateUser(adderUser);
List<Pair<String, Boolean>> attachments = quoteMessage
.getAttachments()
.stream()
.map(attachment -> Pair.of(attachment.getProxyUrl(), attachment.isImage()))
.toList();
return quoteManagementService.createQuote(author, adder, quoteMessage.getContentDisplay(), ServerChannelMessage.fromMessage(quoteMessage), attachments);
}
public void deleteByMessageId(Long messageId) {
Quote quote = quoteManagementService.findByMessage(messageId).orElseThrow(QuoteNotFoundException::new);
log.info("Deleting quote {} in server {}.", quote.getId(), quote.getServer().getId());
quoteManagementService.deleteQuote(quote);
}
}

View File

@@ -0,0 +1,94 @@
package dev.sheldan.sissi.module.quotes.service.management;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
import dev.sheldan.sissi.module.quotes.model.database.Quote;
import dev.sheldan.sissi.module.quotes.model.database.QuoteAttachment;
import dev.sheldan.sissi.module.quotes.repository.QuoteRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
@Component
@Slf4j
public class QuoteManagementService {
@Autowired
private QuoteRepository quoteRepository;
@Autowired
private ChannelManagementService channelManagementService;
public Quote createQuote(AUserInAServer author, AUserInAServer adder, String messageText, ServerChannelMessage quotedMessage, List<Pair<String, Boolean>> attachments) {
AChannel channel = channelManagementService.loadChannel(quotedMessage.getChannelId());
Quote quote = Quote
.builder()
.adder(adder)
.author(author)
.text(messageText)
.messageId(quotedMessage.getMessageId())
.server(adder.getServerReference())
.sourceChannel(channel)
.build();
List<QuoteAttachment> quoteAttachments = attachments
.stream()
.map(stringBooleanPair -> QuoteAttachment
.builder()
.url(stringBooleanPair.getLeft())
.quote(quote)
.server(adder.getServerReference())
.isImage(stringBooleanPair.getRight())
.build())
.toList();
log.info("Creating quote from {} added by {} in server {}.", author.getUserReference().getId(), adder.getUserReference().getId(), author.getServerReference().getId());
quote.setAttachments(quoteAttachments);
return quoteRepository.save(quote);
}
public List<Quote> getFromAuthor(AUserInAServer author) {
return quoteRepository.findByAuthor(author);
}
public List<Quote> getFromServer(AServer aServer) {
return quoteRepository.findByServer(aServer);
}
public void deleteQuote(Quote quote) {
quoteRepository.delete(quote);
}
public Optional<Quote> getQuote(Long quoteId) {
return quoteRepository.findById(quoteId);
}
public List<Quote> getQuotesWithTextInServer(String text, AServer server) {
return quoteRepository.findByTextContainingAndServer(text, server);
}
public List<Quote> getQuotesWithTextInServerFromAuthor(String text, AServer server, AUserInAServer aUserInAServer) {
return quoteRepository.findByTextContainingAndServerAndAuthor(text, server, aUserInAServer);
}
public Long getAmountOfQuotesOfAuthor(AUserInAServer aUserInAServer) {
return quoteRepository.countByAuthor(aUserInAServer);
}
public Long getAmountOfQuotesOfAdder(AUserInAServer aUserInAServer) {
return quoteRepository.countByAdder(aUserInAServer);
}
public Optional<Quote> findByMessage(Long messageId) {
return quoteRepository.findByMessageId(messageId);
}
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="feature.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="starboard_quote_sync_feature-insertion">
<insert tableName="feature">
<column name="key" value="starboardQuoteSync"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,16 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="quote-add_tracking_columns">
<sql>
DROP TRIGGER IF EXISTS quote_update_trigger ON quote;
CREATE TRIGGER quote_update_trigger BEFORE UPDATE ON quote FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
</sql>
<sql>
DROP TRIGGER IF EXISTS quote_insert_trigger ON quote;
CREATE TRIGGER quote_insert_trigger BEFORE INSERT ON quote FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="quote.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,11 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<changeSet author="Sheldan" id="quote_attachment-longer_attachment_url">
<modifyDataType columnName="url"
newDataType="VARCHAR(4096)"
tableName="quote_attachment"/>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,6 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="quote_attachment.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -3,4 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
<include file="1.0.2/collection.xml" relativeToChangelogFile="true"/>
<include file="1.4.56/collection.xml" relativeToChangelogFile="true"/>
<include file="1.4.57/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -1,2 +1,5 @@
abstracto.featureFlags.quotes.featureName=quotes
abstracto.featureFlags.quotes.enabled=false
abstracto.featureFlags.starboardQuoteSync.featureName=starboardQuoteSync
abstracto.featureFlags.starboardQuoteSync.enabled=false

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>sissi-modules</artifactId>
<groupId>dev.sheldan.sissi.application</groupId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -2,4 +2,4 @@ apiVersion: v2
name: sissi
description: A Helm chart for Kubernetes
type: application
version: 1.4.44
version: 1.4.66

View File

@@ -61,6 +61,8 @@ spec:
value: {{ .Values.dbCredentials.schema }}
- name: DEBRA_DONATION_NOTIFICATION_SERVER_ID
value: "297910194841583616"
- name: WEEKLY_TEXT_SERVER_ID
value: "{{ .Values.bot.config.weeklyTextServerId }}"
- name: TOKEN
valueFrom:
secretKeyRef:
@@ -90,6 +92,8 @@ spec:
value: "{{ .Values.privateRestApi.service.name }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: PRIVATE_REST_API_PORT
value: "{{ .Values.privateRestApi.service.targetPort }}"
- name: FRONTEND_BASE
value: "https://{{ .Values.bot.host }}"
{{- range $key, $value := .Values.bot.propertyConfig }}
- name: {{ $key | quote }}
value: {{ $value | quote}}

View File

@@ -31,9 +31,9 @@ spec:
image: "{{ .Values.privateRestApi.repository }}/{{ .Values.privateRestApi.image }}:{{ .Values.privateRestApi.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.privateRestApi.pullPolicy }}
env:
- name: SISSI_HOST
- name: BACKEND_HOST
value: "{{ include "sissi.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: SISSI_PORT
- name: BACKEND_PORT
value: "{{ .Values.service.port }}"
ports:
- name: {{ .Values.privateRestApi.service.name }}

View File

@@ -31,9 +31,9 @@ spec:
image: "{{ .Values.restApi.repository }}/{{ .Values.restApi.image }}:{{ .Values.restApi.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.restApi.pullPolicy }}
env:
- name: SISSI_HOST
- name: BACKEND_HOST
value: "{{ include "sissi.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local"
- name: SISSI_PORT
- name: BACKEND_PORT
value: "{{ .Values.service.port }}"
ports:
- name: {{ .Values.restApi.service.name }}

View File

@@ -3,7 +3,7 @@ bot:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
image: sissi-bot
tag: 1.4.44
tag: 1.4.66
livenessProbe:
initialDelaySeconds: 60
periodSeconds: 5
@@ -14,12 +14,15 @@ bot:
failureThreshold: 3
propertyConfig:
hikariPoolSize: 10
host: null
config:
weeklyTextServerId: null
restApi:
enabled: true
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
image: sissi-rest-api
tag: 1.4.44
tag: 1.4.66
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
@@ -59,7 +62,7 @@ privateRestApi:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
image: sissi-private-rest-api
tag: 1.4.44
tag: 1.4.66
podAnnotations: {}
podSecurityContext: {}
securityContext: {}
@@ -90,23 +93,23 @@ templateDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-template-deployment
tag: 1.5.26
tag: 1.5.54
templateDeploymentData:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
image: sissi-template-data
tag: 1.4.44
tag: 1.4.66
dbConfigDeployment:
enabled: true
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-db-deployment
tag: 1.5.26
tag: 1.5.54
dbConfigDeploymentData:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
image: sissi-db-data
tag: 1.4.44
tag: 1.4.66
dbCredentials:
host: null
port: null

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi</groupId>
<artifactId>deployment</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -263,6 +263,17 @@
<destFileName>meetup.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.templates</groupId>
<artifactId>miepscord-templates</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/template-data/template-artifacts/</outputDirectory>
<destFileName>miepscord.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.templates</groupId>
<artifactId>debra-templates</artifactId>
@@ -519,6 +530,16 @@
<destFileName>meetup.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.templates.translations</groupId>
<artifactId>miepscord-translations</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/template-data/translation-artifacts/</outputDirectory>
<destFileName>miepscord.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.templates.translations</groupId>
<artifactId>debra-translations</artifactId>
@@ -631,17 +652,6 @@
<destFileName>assignable-roles.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>utility-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/db-data/liquibase-artifacts/</outputDirectory>
<destFileName>utility.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>modmail-impl</artifactId>
@@ -765,6 +775,17 @@
<destFileName>meetup.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>miepscord</artifactId>
<version>${project.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/db-data/liquibase-artifacts/</outputDirectory>
<destFileName>miepscord.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.sissi.application.module</groupId>
<artifactId>rss-news</artifactId>

View File

@@ -13,6 +13,7 @@
{ "zip": "meetup", "file": "meetup-changeLog.xml"},
{ "zip": "rss-news", "file": "rssNews-changeLog.xml"},
{ "zip": "debra", "file": "debra-changeLog.xml"},
{ "zip": "miepscord", "file": "miepscord-changeLog.xml"},
{ "zip": "moderation", "file": "moderation-changeLog.xml"},
{ "zip": "entertainment", "file": "entertainment-changeLog.xml"},
{ "zip": "custom-command", "file": "custom-command-changeLog.xml"},

View File

@@ -3,7 +3,11 @@ ARG SISSI_REGISTRY_PREFIX
ARG VERSION
ARG ABSTRACTO_VERSION
FROM ${SISSI_REGISTRY_PREFIX}sissi-debra-rest-api:${VERSION:-latest} AS debra-api
FROM ${REGISTRY_PREFIX}abstracto-rest-api-experience:${ABSTRACTO_VERSION:-latest} AS experience-api
FROM ${REGISTRY_PREFIX}abstracto-rest-api-core:${ABSTRACTO_VERSION:-latest} AS core-api
FROM ${REGISTRY_PREFIX}abstracto-rest-api:${ABSTRACTO_VERSION:-latest}
COPY --from=debra-api /python /python
COPY --from=debra-api /python /python
COPY --from=core-api /python /python
COPY --from=experience-api /python /python

View File

@@ -3,7 +3,7 @@
"core","starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices", "remind",
"suggestion", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
"image-generation",
"quotes", "meetup", "debra", "rss-news",
"quotes", "meetup", "debra", "rss-news", "miepscord",
"moderation-custom", "image-generation-custom",
"moderation-template-overrides", "experience-template-overrides", "logging-template-overrides"
],
@@ -12,7 +12,7 @@
"starboard", "link-embed", "moderation", "entertainment", "custom-command", "utility", "webservices",
"suggestion", "remind", "modmail", "assignable-roles", "experience-tracking", "logging", "statistic", "twitch", "giveaway", "sticky-roles",
"image-generation",
"quotes", "meetup", "debra", "rss-news",
"quotes", "meetup", "debra", "rss-news", "miepscord",
"moderation-custom",
"moderation-translation-overrides", "experience-translation-overrides", "logging-translation-overrides"
]

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi</groupId>
<artifactId>sissi</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -24,6 +24,8 @@ services:
VERSION: ${VERSION}
ABSTRACTO_VERSION: ${ABSTRACTO_VERSION}
image: ${REGISTRY_PREFIX}sissi-rest-api:${VERSION:-latest}
depends_on:
- debra-rest-api
private-rest-api-packaging:
build:
context: deployment/image-packaging/src/main/docker/private-rest-api
@@ -33,6 +35,8 @@ services:
ABSTRACTO_VERSION: ${ABSTRACTO_VERSION}
VERSION: ${VERSION}
image: ${REGISTRY_PREFIX}sissi-private-rest-api:${VERSION:-latest}
depends_on:
- image-gen-api
db-data:
build:
context: deployment/image-packaging/src/main/docker/db-data
@@ -40,4 +44,4 @@ services:
template-data:
build:
context: deployment/image-packaging/src/main/docker/template-data
image: ${REGISTRY_PREFIX}sissi-template-data:${VERSION:-latest}
image: ${REGISTRY_PREFIX}sissi-template-data:${VERSION:-latest}

View File

@@ -13,13 +13,13 @@
<groupId>dev.sheldan.sissi</groupId>
<artifactId>sissi</artifactId>
<name>Sissi</name>
<version>1.4.45</version>
<version>1.4.67</version>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<abstracto.version>1.5.26</abstracto.version>
<abstracto.templates.version>1.4.34</abstracto.templates.version>
<abstracto.version>1.5.54</abstracto.version>
<abstracto.templates.version>1.4.47</abstracto.templates.version>
<apache-jena.version>4.9.0</apache-jena.version>
<rssreader.version>3.5.0</rssreader.version>
</properties>
@@ -28,6 +28,7 @@
<module>application</module>
<module>templates</module>
<module>deployment</module>
<module>application/sissi-modules/miepscord</module>
</modules>
<repositories>
@@ -72,7 +73,7 @@
<connection>scm:git:${project.scm.url}</connection>
<developerConnection>scm:git:${project.scm.url}</developerConnection>
<url>https://github.com/Sheldan/Sissi.git</url>
<tag>sissi-1.4.45</tag>
<tag>sissi-1.4.67</tag>
</scm>
</project>

View File

@@ -11,12 +11,12 @@ from datetime import timezone, datetime
import pytz
sissi_host = os.getenv('SISSI_HOST')
sissi_port = os.getenv('SISSI_PORT')
latest_donations_url = f'http://{sissi_host}:{sissi_port}/debra/latestDonations'
highest_donations_url = f'http://{sissi_host}:{sissi_port}/debra/highestDonations'
campaign_info_url = f'http://{sissi_host}:{sissi_port}/debra/campaignInfo'
endless_stream_info_url = f'http://{sissi_host}:{sissi_port}/stream/endlessStream'
backend_host = os.getenv('BACKEND_HOST')
backend_port = os.getenv('BACKEND_PORT')
latest_donations_url = f'http://{backend_host}:{backend_port}/debra/latestDonations'
highest_donations_url = f'http://{backend_host}:{backend_port}/debra/highestDonations'
campaign_info_url = f'http://{backend_host}:{backend_port}/debra/campaignInfo'
endless_stream_info_url = f'http://{backend_host}:{backend_port}/stream/endlessStream'
class DonationImageGenerationParameters:

View File

@@ -0,0 +1,30 @@
import sqlalchemy as db
import os
from starboard_loader import load_all_starboard_posts
from post_loader import enrich_posts
from quote_importer import import_quotes, fix_quote_created
db_host = os.getenv('DB_HOST')
db_port = os.getenv('DB_PORT')
db_database = os.getenv('DB_NAME')
db_user = os.getenv('DB_USER')
db_password = os.getenv('DB_PASS')
engine = db.create_engine('postgresql://%s:%s@%s:%s/%s' % (db_user, db_password, db_host, db_port, db_database))
with engine.connect() as con:
posts = load_all_starboard_posts(con)
sub_posts = chunks = [posts[x:x+100] for x in range(0, len(posts), 100)]
print(f'Loaded {len(posts)} into {len(sub_posts)} partitions')
counter = 0
for sub_post in sub_posts:
print(f'Partition size {len(sub_post)}')
enriched_posts = enrich_posts(sub_post)
print(f'Enriched posts')
import_quotes(enriched_posts, con)
print(f'Done storing quotes')
con.commit()
fix_quote_created(enriched_posts, con)
con.commit()
counter += 1
print(f'Done. {counter}')

View File

@@ -0,0 +1,32 @@
import requests
import os
import json
import time
token = os.getenv('TOKEN')
image_extension = ["jpg", "jpeg", "png", "gif", "webp", "tiff", "svg", "apng"]
def enrich_posts(posts):
for post in posts:
print(f"Loading post {post['message_id']}")
url = f"https://discord.com/api/v10/channels/{post['channel_id']}/messages/{post['message_id']}"
message = requests.get(url, headers={'Authorization': token})
time.sleep(1)
if message.status_code == 200:
message_obj = json.loads(message.content)
post['content'] = message_obj['content']
attachments = []
attachment_objs = message_obj['attachments']
if len(attachment_objs) > 0:
for attachment in attachment_objs:
extension = attachment['filename'][attachment['filename'].rfind('.') + 1]
attachment = {
'url': attachment['proxy_url'],
'is_image': extension.lower() in image_extension
}
attachments.append(attachment)
post['attachments'] = attachments
else:
print(f"{post['message_id']}: Didnt find post {url}: {message.status_code}")
return posts

View File

@@ -0,0 +1,26 @@
from sqlalchemy.sql import text
def import_quotes(posts, con):
for post in posts:
if 'content' not in post:
print(f"Skipping {post['message_id']} because no content, did it fail?")
continue
print(f"Inserting {post['message_id']}")
statement = text("""INSERT INTO quote(author_user_in_server_id, adder_user_in_server_id, source_channel_id,
server_id, message_id, text, created)
VALUES(:author_id, :adder_id, :channel_id, :server_id, :message_id, :content, :created) returning id""")
quote_id = con.execute(statement, {'author_id': post['author_id'], 'adder_id': post['adder_id'], 'channel_id': post['channel_id'], 'server_id': post['server_id'],
'message_id': post['message_id'], 'content': post['content'], 'created': post['created']}).fetchone()[0]
print(f'Created quote {quote_id}')
for attachment in post['attachments']:
statement = text("""INSERT INTO quote_attachment(quote_id, server_id, url, is_image)
VALUES(:quote_id, :server_id, :url, :is_image)""")
con.execute(statement, {'quote_id': quote_id, 'server_id': post['server_id'], 'url': attachment['url'], 'is_image': attachment['is_image']})
post['quote_id'] = quote_id
# the insert trigger always updated created, we have to re-do it (will be changed, but not for now)
def fix_quote_created(posts, con):
for post in posts:
if 'quote_id' in post:
statement = text("""update quote set created = :created where id = :quote_id""")
con.execute(statement, {'created': post['created'], 'quote_id': post['quote_id']})

View File

@@ -0,0 +1,30 @@
from sqlalchemy.sql import text
def load_all_starboard_posts(conn):
squery = text("""select distinct sp.id, sp.author_user_in_server_id, sp.source_channel_id, sp.server_id, sp.post_message_id, spr.reactor_user_in_server_id, sp.created
from starboard_post sp
inner join starboard_post_reaction spr
on sp.id = spr.post_id
and spr.reactor_user_in_server_id = (
select reactor_user_in_server_id
from starboard_post_reaction spr2
where spr2.post_id = sp.id
order by created limit 1
)
where sp.ignored = false
and sp.post_message_id not in (select message_id from quote)
""")
rs = conn.execute(squery)
found_posts = []
for post in rs:
found_posts.append({
'post_id': post[0],
'channel_id': post[2],
'message_id': post[4],
'adder_id': post[5],
'author_id': post[1],
'server_id': post[3],
'created': post[6]
})
return found_posts

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi</groupId>
<artifactId>sissi</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,6 +13,7 @@
<modules>
<module>sissi-templates</module>
<module>sissi-translations</module>
<module>sissi-templates/module-templates/miepscord-templates</module>
</modules>

View File

@@ -4,7 +4,7 @@
<parent>
<artifactId>customization-templates</artifactId>
<groupId>dev.sheldan.sissi.templates</groupId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<artifactId>image-generation-customization-templates</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>dev.sheldan.sissi.templates</groupId>
<artifactId>customization-templates</artifactId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>sissi-templates</artifactId>
<groupId>dev.sheldan.sissi.templates</groupId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>module-templates</artifactId>
<groupId>dev.sheldan.sissi.templates</groupId>
<version>1.4.45</version>
<version>1.4.67</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Some files were not shown because too many files have changed in this diff Show More