mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-06-23 17:07:41 +00:00
[SIS-xxx] updating abstracto to get @time duration handling
adding instant parsing ability for meetup parameter remove change meetup time text command removing not needed method
This commit is contained in:
2
.env
2
.env
@@ -1,4 +1,4 @@
|
||||
REGISTRY_PREFIX=harbor.sheldan.dev/sissi/
|
||||
ABSTRACTO_PREFIX=harbor.sheldan.dev/abstracto/
|
||||
VERSION=1.5.20
|
||||
ABSTRACTO_VERSION=1.6.19
|
||||
ABSTRACTO_VERSION=1.6.20
|
||||
@@ -5,7 +5,6 @@ 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.ComponentService;
|
||||
@@ -13,10 +12,7 @@ import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandPrivilegeLevels;
|
||||
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.core.utils.ParseUtils;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupFeatureDefinition;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupSlashCommandNames;
|
||||
import dev.sheldan.sissi.module.meetup.exception.MeetupPastTimeException;
|
||||
@@ -57,44 +53,6 @@ public class ChangeMeetupTime extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private MeetupServiceBean meetupServiceBean;
|
||||
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@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();
|
||||
}
|
||||
Long newTimestamp = (Long) parameters.get(1);
|
||||
Instant newMeetupTime = Instant.ofEpochSecond(newTimestamp);
|
||||
if(newMeetupTime.isBefore(Instant.now())) {
|
||||
throw new MeetupPastTimeException();
|
||||
}
|
||||
String confirmationId = componentService.generateComponentId();
|
||||
String cancelId = componentService.generateComponentId();
|
||||
MeetupChangeTimeConfirmationModel model = MeetupChangeTimeConfirmationModel
|
||||
.builder()
|
||||
.meetupTime(newMeetupTime)
|
||||
.topic(meetup.getTopic())
|
||||
.description(meetup.getDescription())
|
||||
.userId(commandContext.getAuthor().getIdLong())
|
||||
.guildId(commandContext.getGuild().getIdLong())
|
||||
.meetupId(meetupId)
|
||||
.confirmationId(confirmationId)
|
||||
.cancelId(cancelId)
|
||||
.build();
|
||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(CHANGE_MEETUP_TIME_CONFIRMATION, model, commandContext.getGuild().getIdLong());
|
||||
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel()))
|
||||
.thenAccept(unused -> meetupServiceBean.storeMeetupChangeTimeConfirmation(model))
|
||||
.thenApply(unused -> CommandResult.fromSuccess());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||
Long meetupId = slashCommandParameterService.getCommandOption(MEETUP_ID_PARAMETER, event, Integer.class).longValue();
|
||||
@@ -102,8 +60,8 @@ public class ChangeMeetupTime extends AbstractConditionableCommand {
|
||||
if(!meetup.getOrganizer().getUserReference().getId().equals(event.getMember().getIdLong())) {
|
||||
throw new NotMeetupOrganizerException();
|
||||
}
|
||||
Integer time = slashCommandParameterService.getCommandOption(MEETUP_NEW_TIMESTAMP_PARAMETER, event, Long.class, Integer.class);
|
||||
Instant meetupTime = Instant.ofEpochSecond(time);
|
||||
String time = slashCommandParameterService.getCommandOption(MEETUP_NEW_TIMESTAMP_PARAMETER, event, String.class, String.class);
|
||||
Instant meetupTime = ParseUtils.parseInstant(time);
|
||||
if(meetupTime.isBefore(Instant.now())) {
|
||||
throw new MeetupPastTimeException();
|
||||
}
|
||||
@@ -138,7 +96,7 @@ public class ChangeMeetupTime extends AbstractConditionableCommand {
|
||||
.builder()
|
||||
.templated(true)
|
||||
.name(MEETUP_NEW_TIMESTAMP_PARAMETER)
|
||||
.type(Long.class)
|
||||
.type(Instant.class)
|
||||
.build();
|
||||
|
||||
List<Parameter> parameters = Arrays.asList(meetupIdParameter, newTimeStampParameter);
|
||||
@@ -162,6 +120,7 @@ public class ChangeMeetupTime extends AbstractConditionableCommand {
|
||||
.async(true)
|
||||
.slashCommandConfig(slashCommandConfig)
|
||||
.supportsEmbedException(true)
|
||||
.slashCommandOnly(true)
|
||||
.causesReaction(true)
|
||||
.parameters(parameters)
|
||||
.help(helpInfo)
|
||||
|
||||
@@ -23,6 +23,7 @@ import dev.sheldan.abstracto.core.service.management.UserInServerManagementServi
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.core.utils.ParseUtils;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupFeatureDefinition;
|
||||
import dev.sheldan.sissi.module.meetup.config.MeetupSlashCommandNames;
|
||||
import dev.sheldan.sissi.module.meetup.model.command.MeetupConfirmationModel;
|
||||
@@ -114,7 +115,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||
Integer time = slashCommandParameterService.getCommandOption(MEETUP_TIME_PARAMETER, event, Long.class, Integer.class);
|
||||
String time = slashCommandParameterService.getCommandOption(MEETUP_TIME_PARAMETER, event, Instant.class, String.class);
|
||||
String topic = slashCommandParameterService.getCommandOption(TOPIC_PARAMETER, event, String.class);
|
||||
String description;
|
||||
if(slashCommandParameterService.hasCommandOption(DESCRIPTION_PARAMETER, event)) {
|
||||
@@ -129,7 +130,7 @@ public class CreateMeetup extends AbstractConditionableCommand {
|
||||
} else {
|
||||
location = DEFAULT_LOCATION_STRING;
|
||||
}
|
||||
Instant meetupTime = Instant.ofEpochSecond(time);
|
||||
Instant meetupTime = ParseUtils.parseInstant(time);
|
||||
AUserInAServer organizer = userInServerManagementService.loadOrCreateUser(event.getMember());
|
||||
AChannel meetupChannel = channelManagementService.loadChannel(event.getChannel().getIdLong());
|
||||
Meetup meetup = meetupManagementServiceBean.createMeetup(meetupTime, topic, description, organizer, meetupChannel, location);
|
||||
|
||||
@@ -30,10 +30,6 @@ public class MeetupComponentManagementServiceBean {
|
||||
return meetupComponentRepository.save(component);
|
||||
}
|
||||
|
||||
public void deleteComponent(MeetupComponent meetupComponent) {
|
||||
meetupComponentRepository.delete(meetupComponent);
|
||||
}
|
||||
|
||||
public void deleteAllComponents(Meetup meetup) {
|
||||
meetupComponentRepository.deleteAll(meetup.getMeetupComponents());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ templateDeployment:
|
||||
repository: harbor.sheldan.dev/abstracto
|
||||
pullPolicy: Always
|
||||
image: abstracto-template-deployment
|
||||
tag: 1.6.19
|
||||
tag: 1.6.20
|
||||
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.19
|
||||
tag: 1.6.20
|
||||
dbConfigDeploymentData:
|
||||
repository: harbor.sheldan.dev/sissi
|
||||
pullPolicy: Always
|
||||
|
||||
4
pom.xml
4
pom.xml
@@ -18,8 +18,8 @@
|
||||
<properties>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<abstracto.version>1.6.20-SNAPSHOT</abstracto.version>
|
||||
<abstracto.templates.version>1.4.66-SNAPSHOT</abstracto.templates.version>
|
||||
<abstracto.version>1.6.20</abstracto.version>
|
||||
<abstracto.templates.version>1.4.66</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>
|
||||
|
||||
@@ -1 +1 @@
|
||||
New time of the meetup (https://www.unixtimestamp.com/)
|
||||
New time of the meetup (https://www.unixtimestamp.com/) or use @time: <time>
|
||||
@@ -1 +1 @@
|
||||
Time of the meetup (https://www.unixtimestamp.com/)
|
||||
Time of the meetup (https://www.unixtimestamp.com/) or use @time: <time>
|
||||
Reference in New Issue
Block a user