mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-01 23:35:21 +00:00
[SIS-16] additional features for meetups to:
define a location update properties being able to define which type of decisions should receive meetup notifications reference the meetup in a notification preparing for release
This commit is contained in:
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -34,5 +34,5 @@ jobs:
|
||||
env:
|
||||
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/sissi/
|
||||
VERSION: ${{ env.version }}
|
||||
ABSTRACTO_VERSION: 1.4.15
|
||||
ABSTRACTO_VERSION: 1.4.16
|
||||
ABSTRACTO_REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto/
|
||||
@@ -0,0 +1,158 @@
|
||||
package dev.sheldan.sissi.module.meetup.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.CommandContext;
|
||||
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.meetup.config.MeetupFeatureDefinition;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupSlashCommandNames;
|
||||
import dev.sheldan.sissi.module.meetup.exception.NotMeetupOrganizerException;
|
||||
import dev.sheldan.sissi.module.meetup.model.database.Meetup;
|
||||
import dev.sheldan.sissi.module.meetup.service.MeetupServiceBean;
|
||||
import dev.sheldan.sissi.module.meetup.service.management.MeetupManagementServiceBean;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class ChangeMeetup extends AbstractConditionableCommand {
|
||||
|
||||
private static final String CHANGE_MEETUP_COMMAND = "changeMeetup";
|
||||
private static final String MEETUP_ID_PARAMETER = "meetupId";
|
||||
private static final String MEETUP_NEW_VALUE_PARAMETER = "newValue";
|
||||
private static final String MEETUP_PROPERTY_PARAMETER = "property";
|
||||
|
||||
@Autowired
|
||||
private SlashCommandParameterService slashCommandParameterService;
|
||||
|
||||
@Autowired
|
||||
private MeetupManagementServiceBean meetupManagementServiceBean;
|
||||
|
||||
@Autowired
|
||||
private MeetupServiceBean meetupServiceBean;
|
||||
|
||||
@Autowired
|
||||
private InteractionService interactionService;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Long meetupId = (Long) parameters.get(0);
|
||||
Meetup meetup = meetupManagementServiceBean.getMeetup(meetupId, commandContext.getGuild().getIdLong());
|
||||
if(!meetup.getOrganizer().getUserReference().getId().equals(commandContext.getAuthor().getIdLong())) {
|
||||
throw new NotMeetupOrganizerException();
|
||||
}
|
||||
String property = (String) parameters.get(1);
|
||||
MeetupProperty propertyEnum = MeetupProperty.valueOf(property);
|
||||
String newValue = (String) parameters.get(2);
|
||||
return updateMeetup(meetup, propertyEnum, newValue).thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> updateMeetup(Meetup meetup, MeetupProperty propertyEnum, String newValue) {
|
||||
CompletableFuture<Void> future;
|
||||
switch (propertyEnum) {
|
||||
case TOPIC:
|
||||
future = meetupServiceBean.changeMeetupTopic(meetup, newValue);
|
||||
break;
|
||||
case LOCATION:
|
||||
future = meetupServiceBean.changeMeetupLocation(meetup, newValue);
|
||||
break;
|
||||
default:
|
||||
case DESCRIPTION:
|
||||
future = meetupServiceBean.changeMeetupDescription(meetup, newValue);
|
||||
break;
|
||||
}
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||
Long meetupId = slashCommandParameterService.getCommandOption(MEETUP_ID_PARAMETER, event, Integer.class).longValue();
|
||||
Meetup meetup = meetupManagementServiceBean.getMeetup(meetupId, event.getGuild().getIdLong());
|
||||
if(!meetup.getOrganizer().getUserReference().getId().equals(event.getMember().getIdLong())) {
|
||||
throw new NotMeetupOrganizerException();
|
||||
}
|
||||
String newValue = slashCommandParameterService.getCommandOption(MEETUP_NEW_VALUE_PARAMETER, event, String.class);
|
||||
String property = slashCommandParameterService.getCommandOption(MEETUP_PROPERTY_PARAMETER, event, String.class);
|
||||
MeetupProperty propertyEnum = MeetupProperty.valueOf(property);
|
||||
return updateMeetup(meetup, propertyEnum, newValue)
|
||||
.thenCompose(commandResult -> interactionService.replyEmbed("changeMeetup_response", event))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandConfiguration getConfiguration() {
|
||||
Parameter meetupIdParameter = Parameter
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(MEETUP_ID_PARAMETER)
|
||||
.type(Long.class)
|
||||
.build();
|
||||
|
||||
List<String> meetupProperties = Arrays
|
||||
.stream(MeetupProperty.values())
|
||||
.map(Enum::name)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Parameter meetupPropertyParameter = Parameter
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(MEETUP_PROPERTY_PARAMETER)
|
||||
.type(String.class)
|
||||
.choices(meetupProperties)
|
||||
.build();
|
||||
|
||||
Parameter newValueParameter = Parameter
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(MEETUP_NEW_VALUE_PARAMETER)
|
||||
.type(String.class)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(meetupIdParameter, meetupPropertyParameter, newValueParameter);
|
||||
HelpInfo helpInfo = HelpInfo
|
||||
.builder()
|
||||
.templated(true)
|
||||
.build();
|
||||
|
||||
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||
.builder()
|
||||
.enabled(true)
|
||||
.rootCommandName(MeetupSlashCommandNames.MEETUP)
|
||||
.commandName("changeMeetup")
|
||||
.build();
|
||||
|
||||
return CommandConfiguration.builder()
|
||||
.name(CHANGE_MEETUP_COMMAND)
|
||||
.module(UtilityModuleDefinition.UTILITY)
|
||||
.templated(true)
|
||||
.async(true)
|
||||
.slashCommandConfig(slashCommandConfig)
|
||||
.supportsEmbedException(true)
|
||||
.causesReaction(true)
|
||||
.parameters(parameters)
|
||||
.help(helpInfo)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureDefinition getFeature() {
|
||||
return MeetupFeatureDefinition.MEETUP;
|
||||
}
|
||||
|
||||
public enum MeetupProperty {
|
||||
DESCRIPTION, TOPIC, LOCATION
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
private static final String MEETUP_TIME_PARAMETER = "meetupTime";
|
||||
private static final String TOPIC_PARAMETER = "topic";
|
||||
private static final String DESCRIPTION_PARAMETER = "description";
|
||||
private static final String LOCATION_PARAMETER = "location";
|
||||
private static final String CONFIRMATION_TEMPLATE = "createMeetup_confirmation";
|
||||
|
||||
@Override
|
||||
@@ -86,7 +87,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
}
|
||||
AUserInAServer organizer = userInServerManagementService.loadOrCreateUser(commandContext.getAuthor());
|
||||
AChannel meetupChannel = channelManagementService.loadChannel(commandContext.getChannel().getIdLong());
|
||||
Meetup meetup = meetupManagementServiceBean.createMeetup(meetupTime, meetupTopic, description, organizer, meetupChannel);
|
||||
Meetup meetup = meetupManagementServiceBean.createMeetup(meetupTime, meetupTopic, description, organizer, meetupChannel, null);
|
||||
String confirmationId = componentService.generateComponentId();
|
||||
String cancelId = componentService.generateComponentId();
|
||||
MeetupConfirmationModel model = MeetupConfirmationModel
|
||||
@@ -95,6 +96,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
.guildId(commandContext.getGuild().getIdLong())
|
||||
.description(description)
|
||||
.topic(meetupTopic)
|
||||
.location(meetup.getLocation())
|
||||
.confirmationId(confirmationId)
|
||||
.cancelId(cancelId)
|
||||
.meetupId(meetup.getId().getId())
|
||||
@@ -117,10 +119,17 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
} else {
|
||||
description = "";
|
||||
}
|
||||
|
||||
String location;
|
||||
if(slashCommandParameterService.hasCommandOption(LOCATION_PARAMETER, event)) {
|
||||
location = slashCommandParameterService.getCommandOption(LOCATION_PARAMETER, event, String.class);
|
||||
} else {
|
||||
location = null;
|
||||
}
|
||||
Instant meetupTime = Instant.ofEpochSecond(time);
|
||||
AUserInAServer organizer = userInServerManagementService.loadOrCreateUser(event.getMember());
|
||||
AChannel meetupChannel = channelManagementService.loadChannel(event.getChannel().getIdLong());
|
||||
Meetup meetup = meetupManagementServiceBean.createMeetup(meetupTime, topic, description, organizer, meetupChannel);
|
||||
Meetup meetup = meetupManagementServiceBean.createMeetup(meetupTime, topic, description, organizer, meetupChannel, location);
|
||||
String confirmationId = componentService.generateComponentId();
|
||||
String cancelId = componentService.generateComponentId();
|
||||
MeetupConfirmationModel model = MeetupConfirmationModel
|
||||
@@ -129,6 +138,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
.guildId(event.getGuild().getIdLong())
|
||||
.description(description)
|
||||
.topic(topic)
|
||||
.location(meetup.getLocation())
|
||||
.confirmationId(confirmationId)
|
||||
.cancelId(cancelId)
|
||||
.meetupId(meetup.getId().getId())
|
||||
@@ -166,7 +176,17 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
.type(String.class)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(timeParameter, topicParameter, descriptionParameter);
|
||||
Parameter locationParameter = Parameter
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(LOCATION_PARAMETER)
|
||||
.remainder(true)
|
||||
.optional(true)
|
||||
.slashCommandOnly(true)
|
||||
.type(String.class)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(timeParameter, topicParameter, descriptionParameter, locationParameter);
|
||||
HelpInfo helpInfo = HelpInfo
|
||||
.builder()
|
||||
.templated(true)
|
||||
|
||||
@@ -15,6 +15,7 @@ import dev.sheldan.sissi.module.meetup.config.MeetupFeatureDefinition;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupSlashCommandNames;
|
||||
import dev.sheldan.sissi.module.meetup.exception.NotMeetupOrganizerException;
|
||||
import dev.sheldan.sissi.module.meetup.model.database.Meetup;
|
||||
import dev.sheldan.sissi.module.meetup.model.database.MeetupDecision;
|
||||
import dev.sheldan.sissi.module.meetup.service.MeetupServiceBean;
|
||||
import dev.sheldan.sissi.module.meetup.service.management.MeetupManagementServiceBean;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
@@ -24,6 +25,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class NotifyMeetupParticipants extends AbstractConditionableCommand {
|
||||
@@ -42,6 +44,7 @@ public class NotifyMeetupParticipants extends AbstractConditionableCommand {
|
||||
|
||||
private static final String MEETUP_ID_PARAMETER = "meetupId";
|
||||
private static final String NOTIFICATION_MESSAGE_PARAMETER = "notificationMessage";
|
||||
private static final String NOTIFICATION_MEETUP_DECISION = "decision";
|
||||
private static final String NOTIFY_MEETUP_PARTICIPANTS_COMMAND = "notifyMeetupParticipants";
|
||||
private static final String NOTIFY_MEETUP_PARTICIPANTS_RESPONSE = "notifyMeetupParticipants_response";
|
||||
|
||||
@@ -54,7 +57,7 @@ public class NotifyMeetupParticipants extends AbstractConditionableCommand {
|
||||
throw new NotMeetupOrganizerException();
|
||||
}
|
||||
String notificationMessage = (String) parameters.get(1);
|
||||
return meetupServiceBean.notifyMeetupParticipants(meetup, notificationMessage)
|
||||
return meetupServiceBean.notifyMeetupParticipants(meetup, notificationMessage, null)
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@@ -65,8 +68,12 @@ public class NotifyMeetupParticipants extends AbstractConditionableCommand {
|
||||
if(!meetup.getOrganizer().getUserReference().getId().equals(event.getMember().getIdLong())) {
|
||||
throw new NotMeetupOrganizerException();
|
||||
}
|
||||
MeetupDecision toNotify = null;
|
||||
if(slashCommandParameterService.hasCommandOption(NOTIFICATION_MEETUP_DECISION, event)) {
|
||||
toNotify = MeetupDecision.valueOf(slashCommandParameterService.getCommandOption(NOTIFICATION_MEETUP_DECISION, event, String.class));
|
||||
}
|
||||
String notificationMessage = slashCommandParameterService.getCommandOption(NOTIFICATION_MESSAGE_PARAMETER, event, String.class);
|
||||
return meetupServiceBean.notifyMeetupParticipants(meetup, notificationMessage)
|
||||
return meetupServiceBean.notifyMeetupParticipants(meetup, notificationMessage, toNotify)
|
||||
.thenCompose(unused -> interactionService.replyEmbed(NOTIFY_MEETUP_PARTICIPANTS_RESPONSE, event))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
@@ -88,7 +95,22 @@ public class NotifyMeetupParticipants extends AbstractConditionableCommand {
|
||||
.remainder(true)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(meetupIdParameter, notificationMessage);
|
||||
List<String> meetupDecisions = Arrays
|
||||
.stream(MeetupDecision.values())
|
||||
.map(Enum::name)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Parameter meetupDecisionChoice = Parameter
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(NOTIFICATION_MEETUP_DECISION)
|
||||
.type(String.class)
|
||||
.optional(true)
|
||||
.choices(meetupDecisions)
|
||||
.slashCommandOnly(true)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(meetupIdParameter, notificationMessage, meetupDecisionChoice);
|
||||
HelpInfo helpInfo = HelpInfo
|
||||
.builder()
|
||||
.templated(true)
|
||||
|
||||
@@ -104,6 +104,10 @@ public class MeetupConfirmationListener implements ButtonClickedListener {
|
||||
messageModel.setNoId(noButtonId);
|
||||
messageModel.setMaybeId(maybeButtonId);
|
||||
messageModel.setNoTimeId(noTimeButtonId);
|
||||
meetup.setYesButtonId(yesButtonId);
|
||||
meetup.setMaybeButtonId(maybeButtonId);
|
||||
meetup.setNoTimeButtonId(noTimeButtonId);
|
||||
meetup.setNotInterestedButtonId(noButtonId);
|
||||
messageModel.setCancelled(false);
|
||||
Long meetupId = payload.getMeetupId();
|
||||
Long serverId = payload.getGuildId();
|
||||
|
||||
@@ -14,6 +14,7 @@ public class MeetupConfirmationModel {
|
||||
private MemberDisplay organizer;
|
||||
private Instant meetupTime;
|
||||
private Long meetupId;
|
||||
private String location;
|
||||
private String topic;
|
||||
private String description;
|
||||
private Long guildId;
|
||||
|
||||
@@ -43,6 +43,26 @@ public class Meetup {
|
||||
@Column(name = "message_id")
|
||||
private Long messageId;
|
||||
|
||||
@Getter
|
||||
@Column(name = "location")
|
||||
private String location;
|
||||
|
||||
@Getter
|
||||
@Column(name = "yes_button_id")
|
||||
private String yesButtonId;
|
||||
|
||||
@Getter
|
||||
@Column(name = "maybe_button_id")
|
||||
private String maybeButtonId;
|
||||
|
||||
@Getter
|
||||
@Column(name = "no_time_button_id")
|
||||
private String noTimeButtonId;
|
||||
|
||||
@Getter
|
||||
@Column(name = "not_interested_button_id")
|
||||
private String notInterestedButtonId;
|
||||
|
||||
@OneToMany(
|
||||
fetch = FetchType.LAZY,
|
||||
orphanRemoval = true,
|
||||
|
||||
@@ -15,6 +15,7 @@ public class MeetupMessageModel {
|
||||
private String topic;
|
||||
private String description;
|
||||
private Instant meetupTime;
|
||||
private String location;
|
||||
private MemberDisplay organizer;
|
||||
private Long meetupId;
|
||||
private String yesId;
|
||||
|
||||
@@ -11,4 +11,7 @@ import java.util.List;
|
||||
public class MeetupNotificationModel {
|
||||
private List<MemberDisplay> participants;
|
||||
private String notificationMessage;
|
||||
private Long meetupMessageId;
|
||||
private String meetupTopic;
|
||||
private Long meetupId;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.sissi.module.meetup.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.interaction.ComponentPayloadManagementService;
|
||||
import dev.sheldan.abstracto.core.interaction.ComponentPayloadService;
|
||||
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
|
||||
@@ -33,6 +34,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
@@ -145,6 +149,11 @@ public class MeetupServiceBean {
|
||||
.builder()
|
||||
.description(meetup.getDescription())
|
||||
.topic(meetup.getTopic())
|
||||
.location(meetup.getLocation())
|
||||
.noTimeId(meetup.getNoTimeButtonId())
|
||||
.yesId(meetup.getYesButtonId())
|
||||
.maybeId(meetup.getMaybeButtonId())
|
||||
.noId(meetup.getNotInterestedButtonId())
|
||||
.meetupTime(meetup.getMeetupTime())
|
||||
.meetupId(meetup.getId().getId())
|
||||
.participants(getMemberDisplays(participating))
|
||||
@@ -250,8 +259,8 @@ public class MeetupServiceBean {
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> notifyMeetupParticipants(Meetup meetup, String message) {
|
||||
List<MeetupDecision> decisionsToBeNotified = Arrays.asList(MeetupDecision.MAYBE, MeetupDecision.YES);
|
||||
public CompletableFuture<Void> notifyMeetupParticipants(Meetup meetup, String message, MeetupDecision toNotify) {
|
||||
List<MeetupDecision> decisionsToBeNotified = toNotify == null ? Arrays.asList(MeetupDecision.MAYBE, MeetupDecision.YES) : Arrays.asList(toNotify);
|
||||
List<MemberDisplay> participants = meetup
|
||||
.getParticipants()
|
||||
.stream()
|
||||
@@ -262,6 +271,9 @@ public class MeetupServiceBean {
|
||||
MeetupNotificationModel model = MeetupNotificationModel
|
||||
.builder()
|
||||
.notificationMessage(message)
|
||||
.meetupId(meetup.getId().getId())
|
||||
.meetupMessageId(meetup.getMessageId())
|
||||
.meetupTopic(meetup.getTopic())
|
||||
.participants(participants)
|
||||
.build();
|
||||
MessageChannel channel = channelService.getMessageChannelFromServer(meetup.getServer().getId(), meetup.getMeetupChannel().getId());
|
||||
@@ -386,4 +398,37 @@ public class MeetupServiceBean {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> changeMeetupDescription(Meetup meetup, String newDescription) {
|
||||
meetup.setDescription(newDescription);
|
||||
return updateMeetupMessage(meetup);
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> changeMeetupLocation(Meetup meetup, String newLocation) {
|
||||
try {
|
||||
meetup.setLocation(URLEncoder.encode(newLocation, StandardCharsets.UTF_8.toString()));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AbstractoRunTimeException(e);
|
||||
}
|
||||
return updateMeetupMessage(meetup);
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> changeMeetupTopic(Meetup meetup, String newTopic) {
|
||||
meetup.setTopic(newTopic);
|
||||
return updateMeetupMessage(meetup);
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> updateMeetupMessage(Meetup meetup) {
|
||||
Long meetupId = meetup.getId().getId();
|
||||
Long serverId = meetup.getId().getServerId();
|
||||
MeetupMessageModel meetupMessageModel = getMeetupMessageModel(meetup);
|
||||
MessageToSend updatedMeetupMessage = getMeetupMessage(meetupMessageModel);
|
||||
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))
|
||||
.exceptionally(throwable -> {
|
||||
log.info("Failed to update message of meetup {} in channel {} in server {}.", meetupId, meetup.getMeetupChannel().getId(), serverId, throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.sissi.module.meetup.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.core.models.ServerSpecificId;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
@@ -12,6 +13,9 @@ import dev.sheldan.sissi.module.meetup.repository.MeetupRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,22 +30,28 @@ public class MeetupManagementServiceBean {
|
||||
|
||||
public static final String MEETUP_COUNTER_KEY = "meetup";
|
||||
|
||||
public Meetup createMeetup(Instant timeStamp, String topic, String description, AUserInAServer organizer, AChannel meetupChannel) {
|
||||
public Meetup createMeetup(Instant timeStamp, String topic, String description, AUserInAServer organizer, AChannel meetupChannel, String location) {
|
||||
if(timeStamp.isBefore(Instant.now())) {
|
||||
throw new MeetupPastTimeException();
|
||||
}
|
||||
Long meetupId = counterService.getNextCounterValue(organizer.getServerReference(), MEETUP_COUNTER_KEY);
|
||||
Meetup meetup = Meetup
|
||||
.builder()
|
||||
.meetupTime(timeStamp)
|
||||
.description(description)
|
||||
.topic(topic)
|
||||
.organizer(organizer)
|
||||
.server(organizer.getServerReference())
|
||||
.meetupChannel(meetupChannel)
|
||||
.state(MeetupState.NEW)
|
||||
.id(new ServerSpecificId(organizer.getServerReference().getId(), meetupId))
|
||||
.build();
|
||||
Meetup meetup = null;
|
||||
try {
|
||||
meetup = Meetup
|
||||
.builder()
|
||||
.meetupTime(timeStamp)
|
||||
.description(description)
|
||||
.topic(topic)
|
||||
.location(URLEncoder.encode(location, StandardCharsets.UTF_8.toString()))
|
||||
.organizer(organizer)
|
||||
.server(organizer.getServerReference())
|
||||
.meetupChannel(meetupChannel)
|
||||
.state(MeetupState.NEW)
|
||||
.id(new ServerSpecificId(organizer.getServerReference().getId(), meetupId))
|
||||
.build();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new AbstractoRunTimeException(e);
|
||||
}
|
||||
return meetupRepository.save(meetup);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
|
||||
<property name="meetupFeature" value="(SELECT id FROM feature WHERE key = 'meetup')"/>
|
||||
|
||||
<changeSet author="Sheldan" id="meetup-change_command">
|
||||
<insert tableName="command">
|
||||
<column name="name" value="changeMeetup"/>
|
||||
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||
<column name="feature_id" valueComputed="${meetupFeature}"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<changeSet author="Sheldan" id="meetup-add_info_columns">
|
||||
<addColumn tableName="meetup">
|
||||
<column name="location" type="VARCHAR(100)" />
|
||||
</addColumn>
|
||||
<addColumn tableName="meetup">
|
||||
<column name="yes_button_id" type="VARCHAR(100)" />
|
||||
</addColumn>
|
||||
<addColumn tableName="meetup">
|
||||
<column name="maybe_button_id" type="VARCHAR(100)" />
|
||||
</addColumn>
|
||||
<addColumn tableName="meetup">
|
||||
<column name="no_time_button_id" type="VARCHAR(100)" />
|
||||
</addColumn>
|
||||
<addColumn tableName="meetup">
|
||||
<column name="not_interested_button_id" type="VARCHAR(100)" />
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="meetup.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -8,4 +8,5 @@
|
||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
||||
<include file="1.1.0/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.2.0/collection.xml" relativeToChangelogFile="true"/>
|
||||
<include file="1.3.18/collection.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
@@ -31,4 +31,4 @@ DEBRA_DONATION_NOTIFICATION_SERVER_ID=0
|
||||
PGADMIN_DEFAULT_PASSWORD=admin
|
||||
TOKEN=<INSERT TOKEN>
|
||||
YOUTUBE_API_KEY=<INSERT KEY>
|
||||
SISSI_VERSION=1.3.17
|
||||
SISSI_VERSION=1.3.18
|
||||
4
pom.xml
4
pom.xml
@@ -20,8 +20,8 @@
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<!-- edit in release.yml as well -->
|
||||
<!-- when releasing a new bot version, update the .env as well-->
|
||||
<abstracto.version>1.4.15</abstracto.version>
|
||||
<abstracto.templates.version>1.4.10</abstracto.templates.version>
|
||||
<abstracto.version>1.4.16</abstracto.version>
|
||||
<abstracto.templates.version>1.4.11</abstracto.templates.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"additionalMessage": "<@safe_include "changeMeetup_response_text"/>",
|
||||
"messageConfig": {
|
||||
"ephemeral": true
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,14 @@
|
||||
},
|
||||
"description": "<@format_instant_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": [
|
||||
|
||||
@@ -2,4 +2,7 @@
|
||||
<#assign userMentions><#list participants as user>${user.memberMention}<#sep>, </#list></#assign>
|
||||
"additionalMessage": "${userMentions?json_string}
|
||||
${notificationMessage}"
|
||||
<#if meetupMessageId??>,
|
||||
"referencedMessageId": ${meetupMessageId?c}
|
||||
</#if>
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
"description": "<#if cancelled>~~</#if><@safe_include "meetup_display_description"/><#if cancelled>~~</#if>"
|
||||
}
|
||||
],
|
||||
<#if yesId?has_content && noId?has_content && maybeId?has_content && !cancelled>
|
||||
"buttons": [
|
||||
{
|
||||
"label": "<@safe_include "meetup_message_yes_button_label"/>",
|
||||
@@ -42,8 +41,14 @@
|
||||
"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"
|
||||
}
|
||||
</#if>
|
||||
],
|
||||
</#if>
|
||||
"messageConfig": {
|
||||
"allowsRoleMention": true
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Property has been updated.
|
||||
@@ -0,0 +1 @@
|
||||
Changes a property of a meetup
|
||||
@@ -0,0 +1,3 @@
|
||||
This command is used to change a property of a meetup.
|
||||
That can include: description, topic and location.
|
||||
In order to clear the location please enter "". It is not possible to clear the topic or the description.
|
||||
@@ -0,0 +1 @@
|
||||
The ID of the meetup to change a property of
|
||||
@@ -0,0 +1 @@
|
||||
The new value of the property
|
||||
@@ -0,0 +1 @@
|
||||
Description
|
||||
@@ -0,0 +1 @@
|
||||
Location
|
||||
@@ -0,0 +1 @@
|
||||
Topic
|
||||
@@ -0,0 +1 @@
|
||||
The property to change
|
||||
@@ -0,0 +1 @@
|
||||
Location
|
||||
@@ -0,0 +1 @@
|
||||
Where the meetup should be. This will be used with a Google Maps search link in the display.
|
||||
@@ -0,0 +1 @@
|
||||
Maybe
|
||||
@@ -0,0 +1 @@
|
||||
No time
|
||||
@@ -0,0 +1 @@
|
||||
No
|
||||
@@ -0,0 +1 @@
|
||||
Yes
|
||||
@@ -0,0 +1 @@
|
||||
The decision of the people to be notified
|
||||
Reference in New Issue
Block a user