[SIS-xxx] upgrading to abstracto version supporting components v2

changing meetup and quote command responses to use components v2
changing column name of quote attachment
This commit is contained in:
Sheldan
2025-07-13 20:09:45 +02:00
parent 5f6df14c24
commit be35a84dcf
33 changed files with 248 additions and 171 deletions

2
.env
View File

@@ -1,4 +1,4 @@
REGISTRY_PREFIX=harbor.sheldan.dev/sissi/
ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.5.5
ABSTRACTO_VERSION=1.6.8
ABSTRACTO_VERSION=1.6.9

View File

@@ -60,7 +60,7 @@ public class MeetupDecisionListener implements ButtonClickedListener {
MeetupMessageModel meetupMessageModel = meetupServiceBean.getMeetupMessageModel(meetup);
addParticipationToModel(meetupMessageModel, userInAServer, payload.getMeetupDecision());
MessageToSend messageToSend = meetupServiceBean.getMeetupMessage(meetupMessageModel, model.getServerId());
channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), model.getEvent().getChannel(), meetup.getMessageId())
channelService.editMessageInAChannelFuture(messageToSend, 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 -> {
log.info("Failed to update message of meetup {} in channel {} in server {}.", meetup.getId().getId(), meetup.getMeetupChannel().getId(), meetup.getServer().getId(), throwable);

View File

@@ -372,7 +372,7 @@ public class MeetupServiceBean {
List<Long> userIdsToNotify = participants
.stream()
.map(meetupParticipator -> meetupParticipator.getParticipator().getUserReference().getId())
.collect(Collectors.toList());
.toList();
Long serverId = meetup.getServer().getId();
@@ -415,7 +415,7 @@ public class MeetupServiceBean {
List<Long> userInServerIds = participants
.stream()
.map(meetupParticipant -> meetupParticipant.getParticipator().getUserInServerId())
.collect(Collectors.toList());
.toList();
meetup
.getParticipants().removeIf(meetupParticipant -> userInServerIds.contains(meetupParticipant.getParticipator().getUserInServerId()));
MeetupMessageModel meetupMessageModel = getMeetupMessageModel(meetup);

View File

@@ -1,6 +1,8 @@
package dev.sheldan.sissi.module.quotes.model.command;
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
import lombok.Builder;
import lombok.Getter;
@@ -11,14 +13,14 @@ import java.util.List;
@Builder
public class QuoteResponseModel {
private Long quoteId;
private String authorAvatarURL;
private String authorName;
private UserDisplay authorUserDisplay;
private MemberDisplay authorMemberDisplay;
private ServerChannelMessage quotedMessage;
private String quoteContent;
private List<String> imageAttachmentURLs;
private List<String> mediaAttachmentURLs;
private List<String> fileAttachmentURLs;
private String adderAvatarURL;
private String adderName;
private UserDisplay adderUserDisplay;
private MemberDisplay adderMemberDisplay;
private Instant creationDate;
private String sourceChannelName;
}

View File

@@ -41,8 +41,8 @@ public class QuoteAttachment {
@Getter
@Setter
@Column(name = "is_image", nullable = false)
@Column(name = "is_media", nullable = false)
@Builder.Default
private Boolean isImage = false;
private Boolean isMedia = false;
}

View File

@@ -4,6 +4,8 @@ import dev.sheldan.abstracto.core.models.ServerChannelMessage;
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.models.template.display.MemberDisplay;
import dev.sheldan.abstracto.core.models.template.display.UserDisplay;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.MemberService;
import dev.sheldan.abstracto.core.service.UserService;
@@ -103,21 +105,21 @@ public class QuoteServiceBean {
List<String> imageAttachments = quote
.getAttachments()
.stream()
.filter(QuoteAttachment::getIsImage)
.filter(QuoteAttachment::getIsMedia)
.map(QuoteAttachment::getUrl)
.collect(Collectors.toList());
List<String> fileAttachments = quote
.getAttachments()
.stream()
.filter(quoteAttachment -> !quoteAttachment.getIsImage())
.filter(quoteAttachment -> !quoteAttachment.getIsMedia())
.map(QuoteAttachment::getUrl)
.collect(Collectors.toList());
QuoteResponseModel.QuoteResponseModelBuilder modelBuilder = QuoteResponseModel
.builder()
.quoteContent(quote.getText())
.imageAttachmentURLs(imageAttachments)
.mediaAttachmentURLs(imageAttachments)
.quoteId(quote.getId())
.fileAttachmentURLs(fileAttachments)
.creationDate(quote.getCreated())
@@ -166,42 +168,14 @@ public class QuoteServiceBean {
.filter(user -> user.getIdLong() == quoteAdderUserId)
.findFirst()
.orElse(null);
String adderAvatar = Optional
.ofNullable(adderMember)
.map(member -> member.getUser().getAvatarUrl())
.orElse(Optional
.ofNullable(adderUser)
.map(User::getAvatarUrl)
.orElse(null));
String authorAvatar = Optional
.ofNullable(authorMember)
.map(member -> member.getUser().getAvatarUrl())
.orElse(Optional
.ofNullable(authorUser)
.map(User::getAvatarUrl)
.orElse(null));
String adderName = Optional
.ofNullable(adderMember)
.map(Member::getEffectiveName)
.orElse(Optional
.ofNullable(adderUser)
.map(User::getName)
.orElse(null));
String authorName = Optional
.ofNullable(authorMember)
.map(Member::getEffectiveName)
.orElse(Optional
.ofNullable(authorUser)
.map(User::getName)
.orElse(null));
String channelName = sourceChannel
.map(Channel::getName)
.orElse(null);
QuoteResponseModel model = modelBuilder
.adderAvatarURL(adderAvatar)
.authorAvatarURL(authorAvatar)
.adderName(adderName)
.authorName(authorName)
.authorMemberDisplay(authorMember != null ? MemberDisplay.fromMember(authorMember) : null)
.authorUserDisplay(authorUser != null ? UserDisplay.fromUser(authorUser) : UserDisplay.fromServerUser(ServerUser.fromId(serverId, quotedUserId)))
.adderMemberDisplay(adderMember != null ? MemberDisplay.fromMember(adderMember) : null)
.adderUserDisplay(adderUser != null ? UserDisplay.fromUser(adderUser) : UserDisplay.fromServerUser(ServerUser.fromId(serverId, quoteAdderUserId)))
.sourceChannelName(channelName)
.build();
return templateService.renderEmbedTemplate(QUOTE_RESPONSE_TEMPLATE_KEY, model, serverId);
@@ -260,7 +234,7 @@ public class QuoteServiceBean {
List<Pair<String, Boolean>> attachments = quoteMessage
.getAttachments()
.stream()
.map(attachment -> Pair.of(attachment.getProxyUrl(), attachment.isImage()))
.map(attachment -> Pair.of(attachment.getProxyUrl(), attachment.isImage() || attachment.isVideo()))
.toList();
return quoteManagementService.createQuote(author, adder, quoteMessage.getContentDisplay(), ServerChannelMessage.fromMessage(quoteMessage), attachments);
}

View File

@@ -45,7 +45,7 @@ public class QuoteManagementService {
.url(stringBooleanPair.getLeft())
.quote(quote)
.server(adder.getServerReference())
.isImage(stringBooleanPair.getRight())
.isMedia(stringBooleanPair.getRight())
.build())
.toList();

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,12 @@
<?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-rename-media-column">
<renameColumn
tableName="quote_attachment"
newColumnName="is_media"
oldColumnName="is_image" />
</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

@@ -5,4 +5,5 @@
<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"/>
<include file="1.5.6/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -93,7 +93,7 @@ templateDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-template-deployment
tag: 1.6.8
tag: 1.6.9
templateDeploymentData:
repository: harbor.sheldan.dev/sissi
pullPolicy: Always
@@ -104,7 +104,7 @@ dbConfigDeployment:
repository: harbor.sheldan.dev/abstracto
pullPolicy: Always
image: abstracto-db-deployment
tag: 1.6.8
tag: 1.6.9
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.8</abstracto.version>
<abstracto.templates.version>1.4.56</abstracto.templates.version>
<abstracto.version>1.6.9</abstracto.version>
<abstracto.templates.version>1.4.57</abstracto.templates.version>
<apache-jena.version>4.9.0</apache-jena.version>
<rssreader.version>3.5.0</rssreader.version>
</properties>

View File

@@ -1,33 +1,30 @@
<#include "format_instant">
{
"embeds": [
"components": [
{
<#include "abstracto_color">,
"title": {
"title": "${topic?json_string}"
},
"description": "<@format_instant_long_date_time instant=meetupTime/>
${description?json_string}"
<#if location?? && location != "%22%22">,
"fields": [
{
"name": "<@safe_include "createMeetup_confirmation_location_field_title"/>",
"value": "https://www.google.com/maps?q=${location?json_string}"
}
]
</#if>
}
],
"buttons": [
{
"label": "<@safe_include "createMeetup_confirm_button_label"/>",
"id": "${confirmationId}",
"buttonStyle": "success"
<#assign hasLocation=location?? && location != "%22%22">
"type": "textDisplay",
"content": "<#include "createMeetup_meetup_information">"
},
{
"label": "<@safe_include "createMeetup_cancel_button_label"/>",
"id": "${cancelId}",
"buttonStyle": "danger"
"type": "actionRow",
"actionRowItems": [
{
"label": "<@safe_include "createMeetup_confirm_button_label"/>",
"id": "${confirmationId}",
"buttonStyle": "success",
"type": "button"
},
{
"label": "<@safe_include "createMeetup_cancel_button_label"/>",
"id": "${cancelId}",
"buttonStyle": "danger",
"type": "button"
}
]
}
]
],
"messageConfig": {
"useComponentsV2": true
}
}

View File

@@ -1,10 +1,36 @@
<#include "format_instant">
{
"embeds": [
"components": [
<#list meetups as meetup>
<#assign meetup=meetup>
<#assign topic=meetup.topic>
<#assign time><@format_instant_long_date_time instant=meetup.meetupTime/>
</#assign><#assign timeRelative><@format_instant_relative instant=meetup.meetupTime/></#assign>
<#assign link=meetup.meetupMessage.jumpUrl>
{
<#include "abstracto_color">,
"description": "<#list meetups as meetup><#assign meetup=meetup><#assign topic=meetup.topic><#assign time><@format_instant_long_date_time instant=meetup.meetupTime/></#assign><#assign timeRelative><@format_instant_relative instant=meetup.meetupTime/></#assign><#assign link=meetup.meetupMessage.jumpUrl><#include "meetup_list_meetup_display">
<#else><#include "meetup_list_no_meetups"></#list>"
"type": "section",
"components": [
{
"type": "textDisplay",
"content": "<#include "meetup_list_meetup_display">"
}
]
,"accessory": {
"type": "button",
"label": "<#include "meetup_list_jump_button_label"/>",
"url": "${link}",
"buttonStyle": "link"
}
}
]
<#sep>,</#sep>
<#else>
{
"type": "textDisplay",
"content": "<#include "meetup_list_no_meetups">"
}
</#list>
],
"messageConfig": {
"useComponentsV2": true
}
}

View File

@@ -1,63 +1,74 @@
<#include "format_instant">
{
<#assign roleMention="<@&371419588619141121>"/>
"additionalMessage": "${roleMention?json_string}",
"embeds": [
"components": [
{
"type": "textDisplay",
<#assign roleMention="<@&371419588619141121>"/>
"content": "<#if cancelled>~~</#if>${roleMention?json_string} ${topic?json_string} - <@safe_include "meetup_message_id_display"/><#if cancelled>~~</#if>"
},
<#if description?has_content>
{
<#assign descriptionText>${description?json_string}</#assign>
<#assign organizerText>${organizer.memberMention}</#assign>
"type": "textDisplay",
"content": "<#if cancelled>~~</#if><@safe_include "meetup_description_component"/><#if cancelled>~~</#if>"
},
</#if>
{
<#include "abstracto_color">,
"title": {
"title": "${topic?json_string} - <@safe_include "meetup_message_id_display"/>"
},
<#assign time><@format_instant_long_date_time instant=meetupTime/></#assign>
<#assign timeRelative><@format_instant_relative instant=meetupTime/></#assign>
<#assign organizerText>${organizer.memberMention}</#assign>
<#assign meetupId=meetupId/>
<#assign descriptionText>${description?json_string}</#assign>
<#assign participantsText> (${participants?size}) <#list participants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign maybeParticipantsText> (${maybeParticipants?size}) <#list maybeParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign noTimeParticipantsText> (${noTimeParticipants?size}) <#list noTimeParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign declinedParticipantsText> (${declinedParticipants?size}) <#list declinedParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
"description": "<#if cancelled>~~</#if><@safe_include "meetup_display_description"/><#if cancelled>~~</#if>"
}
],
"buttons": [
{
"label": "<@safe_include "meetup_message_yes_button_label"/>",
"id": "${yesId}",
"buttonStyle": "success"
},
{
"label": "<@safe_include "meetup_message_maybe_button_label"/>",
"id": "${maybeId}",
"buttonStyle": "secondary"
},
{
"label": "<@safe_include "meetup_message_no_time_button_label"/>",
"id": "${noTimeId}",
"buttonStyle": "danger"
},
{
"label": "<@safe_include "meetup_message_no_button_label"/>",
"id": "${noId}",
"buttonStyle": "danger"
}
<#if location?? && location != "%22%22">,
{
"label": "<@safe_include "meetup_message_location_button_label"/>",
"url": "https://www.google.com/maps?q=${location?json_string}",
"buttonStyle": "link"
"type": "section",
"components": [
{
"type": "textDisplay",
"content": "<@safe_include "meetup_display_time_component"/>"
}
]
<#if location?? && location != "%22%22">
,"accessory": {
"type": "button",
"label": "<@safe_include "meetup_message_location_button_label"/>",
"url": "https://www.google.com/maps?q=${location?json_string}",
"buttonStyle": "link"
}
</#if>
}
<#macro decision_component button_id button_style label_template content_template user>
{
"type": "section",
"components": [
{
"type": "textDisplay",
"content": "<@safe_include content_template/>"
}
]
,"accessory": {
"type": "button",
"id": "${button_id}",
"label": "<@safe_include label_template/>",
"buttonStyle": "${button_style}"
}
}
</#macro>
<#assign participantsText> (${participants?size}) <#list participants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign maybeParticipantsText> (${maybeParticipants?size}) <#list maybeParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign noTimeParticipantsText> (${noTimeParticipants?size}) <#list noTimeParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
<#assign declinedParticipantsText> (${declinedParticipants?size}) <#list declinedParticipants as member>${member.memberMention}<#sep>, </#sep><#else><#include "meetup_message_no_member"></#list></#assign>
,<@decision_component yesId "success" "meetup_message_yes_button_label" "meetup_user_display_participants" participantsText/>
,<@decision_component maybeId "secondary" "meetup_message_maybe_button_label" "meetup_user_display_maybe_participants" maybeParticipantsText/>
,<@decision_component noId "danger" "meetup_message_no_button_label" "meetup_user_display_declined_participants" declinedParticipantsText/>
,<@decision_component noTimeId "danger" "meetup_message_no_time_button_label" "meetup_user_display_no_time_participants" noTimeParticipantsText/>
<#if meetupIcsModel.attachIcsFile>
,{
"type": "fileDisplay",
"fileName": "<@safe_include "meetup_ics_file_name"/>.ics",
"fileContent": "<@safe_include "meetup_ice_file_download"/>"
}
</#if>
],
<#if meetupIcsModel.attachIcsFile>
"files": [
{
"fileName": "<@safe_include "meetup_ics_file_name"/>.ics",
"fileContent": "<@safe_include "meetup_ice_file_download"/>"
}
],
</#if>
"messageConfig": {
"allowsRoleMention": true
"allowsRoleMention": true,
"allowsUserMention": false,
"useComponentsV2": true
}
}

View File

@@ -1,26 +1,66 @@
<#include "format_instant">
{
"embeds": [
"components": [
{
<#include "abstracto_color">,
"author": {
<#assign authorName><@default_template_if_null authorName "quote_response_default_author_name"/></#assign>
<#assign channelName><@default_template_if_null sourceChannelName "quote_response_default_channel_name"/></#assign>
"name": "<@safe_include "quote_response_header_author_name"/>"
<#if authorAvatarURL??>,"avatar": "${authorAvatarURL}"</#if>
},
<#assign quoteId=quoteId>
<#assign quoteDescription=quoteContent>
<#assign authorName><#if authorMemberDisplay?has_content>${authorMemberDisplay.name}<#elseif authorUserDisplay?has_content>${authorUserDisplay.name}<#else><@safe_include "quote_response_default_author_name"/></#if></#assign>
<#assign adderUserName><#if adderMemberDisplay?has_content>${adderMemberDisplay.name}<#elseif adderUserDisplay?has_content>${adderMemberDisplay.name}<#else><@safe_include "quote_response_default_adder_name"/></#if></#assign>
<#assign channelName><@default_template_if_null sourceChannelName "quote_response_default_channel_name"/></#assign>
<#assign creationDate><@format_instant_date_time instant=creationDate/></#assign>
"type": "textDisplay",
"content": "<@safe_include "quote_response_header_author_name"/>"
},
{
"type": "section",
"components": [
{
<#assign quoteId=quoteId>
"type": "textDisplay",
"content": "<@safe_include "quote_response_title"/>"
}
],
<#assign quoteJumpUrl=quotedMessage.jumpUrl>
"description": "<@safe_include "quote_response_description"/>",
"footer": {
<#assign adderUserName><@default_template_if_null adderName "quote_response_default_adder_name"/></#assign>
"text": "<@safe_include "quote_response_footer_adder_name" />"
<#if adderAvatarURL??>,"icon": "${adderAvatarURL}"</#if>
},
<#if imageAttachmentURLs?size = 1>
"imageUrl": "${imageAttachmentURLs[0]}",
"accessory": {
"type": "button",
"label": "<@safe_include "quote_response_jump_label"/>",
"url": "${quoteJumpUrl}",
"buttonStyle": "link"
}
},
{
"type": "container",
"components": [
<#assign hasContent=false>
<#if quoteContent?has_content>
<#assign hasContent=true>
{
"type": "textDisplay",
<#assign quoteDescription=quoteContent>
"content": "${quoteDescription}"
}
</#if>
"timeStamp": "${creationDate}"
<#if mediaAttachmentURLs?size gt 0>
<#assign hasContent=true>
,{
"type": "mediaGallery",
"images": [
<#list mediaAttachmentURLs as image>
{
"url": "${image}"
}<#sep>,</#list>
]
}
</#if>
<#if hasContent==false>
{
"type": "textDisplay",
"content": "<@safe_include "quote_response_no_content"/>"
}
</#if>
]
}
]
],
"messageConfig": {
"allowsUserMention": false,
"useComponentsV2": true
}
}

View File

@@ -0,0 +1,5 @@
${topic?json_string} - <@format_instant_long_date_time instant=meetupTime/>
${description?json_string}
<#if hasLocation>https://www.google.com/maps?q=${location?json_string}</#if>

View File

@@ -1,3 +1,2 @@
Time: ${time} ${timeRelative}
Link: [here](${link})
Meetup Topic: `${topic?json_string}`

View File

@@ -0,0 +1,3 @@
Description: ${descriptionText}
Organized by: ${organizerText}

View File

@@ -1,11 +0,0 @@
Time: ${time} ${timeRelative}
<#if descriptionText?hasContent>Description: ${descriptionText}</#if>
Organized by: ${organizerText}
Participants: ${participantsText}
Maybe: ${maybeParticipantsText}
Declined: ${declinedParticipantsText}
No time: ${noTimeParticipantsText}

View File

@@ -1,2 +0,0 @@
[**Quote #${quoteId?c}**](${quoteJumpUrl})
${quoteDescription}

View File

@@ -1 +1 @@
${authorName} in ${channelName}
${authorName} in ${channelName} added by ${adderUserName} at ${creationDate}