[SIS-xxx] updating abstracto version to get capability to use multiple channels for a post target

updating donation notification to use two templates for the post target
removing separate donation notification post target in favor of multiple channels
removing attribution as the code was refactored and reworked
This commit is contained in:
Sheldan
2025-12-18 00:05:39 +01:00
parent abcd8e5c67
commit a2db56853b
10 changed files with 51 additions and 21 deletions

2
.env
View File

@@ -1,4 +1,4 @@
REGISTRY_PREFIX=harbor.sheldan.dev/sissi/
ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.5.18
ABSTRACTO_VERSION=1.6.17
ABSTRACTO_VERSION=1.6.18

3
README
View File

@@ -1,4 +1 @@
Attributions:
Code for debra module has been inspired with approval of zinnsoldat91 by: https://github.com/zinnsoldat91/spendenbot. The code has been adapted to fit into the structure.

View File

@@ -21,7 +21,7 @@ public class DebraFeatureConfig implements FeatureConfig {
@Override
public List<PostTargetEnum> getRequiredPostTargets() {
return Arrays.asList(DebraPostTarget.DEBRA_DONATION_NOTIFICATION, DebraPostTarget.DEBRA_DONATION_NOTIFICATION2);
return Arrays.asList(DebraPostTarget.DEBRA_DONATION_NOTIFICATION);
}
@Override

View File

@@ -5,7 +5,7 @@ import lombok.Getter;
@Getter
public enum DebraPostTarget implements PostTargetEnum {
DEBRA_DONATION_NOTIFICATION("debraDonationNotification"), DEBRA_DONATION_NOTIFICATION2("debraDonationNotification2");
DEBRA_DONATION_NOTIFICATION("debraDonationNotification");
private String key;

View File

@@ -87,6 +87,7 @@ public class DonationService {
private DonationService self;
private static final String DEBRA_DONATION_NOTIFICATION_TEMPLATE_KEY = "debra_donation_notification";
private static final String DEBRA_DONATION_PING_NOTIFICATION_TEMPLATE_KEY = "debra_donation_notification_ping_notification";
private static final String DEBRA_INFO_BUTTON_MESSAGE_TEMPLATE_KEY = "debraInfoButton";
public static final String DEBRA_INFO_BUTTON_ORIGIN = "DEBRA_INFO_BUTTON";
@@ -286,10 +287,9 @@ public class DonationService {
.totalDonationAmount(donationInfoModel.getTotalAmount())
.build();
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);
return FutureUtils.toSingleFutureGeneric(firstMessage);
MessageToSend pingMessageToSend = templateService.renderEmbedTemplate(DEBRA_DONATION_PING_NOTIFICATION_TEMPLATE_KEY, model, targetServerId);
return FutureUtils.toSingleFutureGenericList(postTargetService.sendEmbedInPostTarget(List.of(pingMessageToSend, messageToSend),
DebraPostTarget.DEBRA_DONATION_NOTIFICATION, targetServerId));
}
public CompletableFuture<Void> sendDebraInfoButtonMessage(GuildMessageChannel guildMessageChannel) {

View File

@@ -2,7 +2,6 @@ abstracto.featureFlags.debra.featureName=debra
abstracto.featureFlags.debra.enabled=false
abstracto.postTargets.debraDonationNotification.name=debraDonationNotification
abstracto.postTargets.debraDonationNotification2.name=debraDonationNotification2
sissi.debra.donationPageUrl=https://secure.sicherhelfen.org/campaigns/07a3baf6-5cdc-4300-854b-ea2b36b0b218/show

View File

@@ -5,19 +5,17 @@ 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.abstracto.core.utils.FutureUtils;
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;
@@ -66,9 +64,7 @@ public class TextItemServiceBean {
.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 -> {
return FutureUtils.toSingleFutureGenericList(postTargetService.sendEmbedInPostTarget(messageToSend, WeeklyTextPostTarget.TEXT_ITEM_TARGET, serverId)).thenAccept(unused -> {
self.setTexItemToDone(textItemId);
});
}

View File

@@ -94,7 +94,7 @@ templateDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-template-deployment
tag: 1.6.17
tag: 1.6.18
templateDeploymentData:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
@@ -105,7 +105,7 @@ dbConfigDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-db-deployment
tag: 1.6.17
tag: 1.6.18
dbConfigDeploymentData:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always

View File

@@ -18,8 +18,8 @@
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<abstracto.version>1.6.17</abstracto.version>
<abstracto.templates.version>1.4.63</abstracto.templates.version>
<abstracto.version>1.6.18</abstracto.version>
<abstracto.templates.version>1.4.64</abstracto.templates.version>
<apache-jena.version>4.9.0</apache-jena.version>
<rssreader.version>3.5.0</rssreader.version>
<jsoup.version>1.21.2</jsoup.version>

View File

@@ -0,0 +1,38 @@
{
<#assign userPing="<@186558865851154435>">
"additionalMessage": "${userPing}",
"embeds": [
{
"title": {
<#assign donatorName><#if donation.anonymous><#include "donations_response_anonymous"><#else>${donation.donatorName}</#if></#assign>
<#assign donationAmount=donation.amount>
"title": "<@safe_include "debra_donation_notification_embed_title"/>"
},
<#if donation.message != 'gespendet'>
<#assign donationMessage=donation.message>
"description": "${donationMessage?json_string}",
</#if>
"fields": [
{
<#assign totalDonationAmount=totalDonationAmount>
"name": "<@safe_include "debra_donation_notification_embed_field_amount_title"/>",
"value": "<@safe_include "debra_donation_notification_embed_field_amount_value"/>"
}
],
"imageUrl": "https://cdn.discordapp.com/attachments/299115929206390784/1047306670319079474/dotpict-1.png",
"footer": {
"text": "<@safe_include "debra_donation_notification_embed_footer"/>"
}
}
],
"buttons": [
{
"label": "<@safe_include "debra_donation_notification_link_button_label"/>",
"url": "https://tinyurl.com/debra25",
"buttonStyle": "link",
"metaConfig": {
"persistCallback": false
}
}
]
}