Skip to content

Commit 5e341f6

Browse files
committed
Fix confirmation handler not using original command context
1 parent 6b1e8d0 commit 5e341f6

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

cloud-processors-confirmation/src/main/java/org/incendo/cloud/processors/confirmation/ConfirmationContext.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.checkerframework.checker.nullness.qual.NonNull;
2929
import org.immutables.value.Value;
3030
import org.incendo.cloud.Command;
31+
import org.incendo.cloud.context.CommandContext;
3132
import org.incendo.cloud.processors.immutables.ImmutableImpl;
3233

3334
/**
@@ -44,16 +45,18 @@ public interface ConfirmationContext<C> {
4445
/**
4546
* Creates a new confirmation context.
4647
*
47-
* @param <C> command sender type
48-
* @param creationTime time of creation
49-
* @param command command that requires confirmation
48+
* @param <C> command sender type
49+
* @param creationTime time of creation
50+
* @param command command that requires confirmation
51+
* @param commandContext command context that requires confirmation
5052
* @return the created context
5153
*/
5254
static <C> @NonNull ConfirmationContext<C> of(
5355
final @NonNull Instant creationTime,
54-
final @NonNull Command<C> command
56+
final @NonNull Command<C> command,
57+
final @NonNull CommandContext<C> commandContext
5558
) {
56-
return ConfirmationContextImpl.of(creationTime, command);
59+
return ConfirmationContextImpl.of(creationTime, command, commandContext);
5760
}
5861

5962
/**
@@ -69,4 +72,11 @@ public interface ConfirmationContext<C> {
6972
* @return the command
7073
*/
7174
@NonNull Command<C> command();
75+
76+
/**
77+
* Returns the execution context that required confirmation.
78+
*
79+
* @return the command context
80+
*/
81+
@NonNull CommandContext<C> commandContext();
7282
}

cloud-processors-confirmation/src/main/java/org/incendo/cloud/processors/confirmation/ConfirmationExecutionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ final class ConfirmationExecutionHandler<C> implements CommandExecutionHandler.F
5353
this.confirmationManager.configuration().noPendingCommandNotifier().accept(commandContext.sender());
5454
return CompletableFuture.completedFuture(null);
5555
}
56-
return pending.get().command().commandExecutionHandler().executeFuture(commandContext);
56+
return pending.get().command().commandExecutionHandler().executeFuture(pending.get().commandContext());
5757
}
5858
}

cloud-processors-confirmation/src/main/java/org/incendo/cloud/processors/confirmation/ConfirmationPostprocessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public void accept(final @NonNull CommandPostprocessingContext<C> context) {
5656
return;
5757
}
5858

59-
final ConfirmationContext<C> confirmationContext = ConfirmationContext.of(Instant.now(), context.command());
59+
final ConfirmationContext<C> confirmationContext = ConfirmationContext.of(
60+
Instant.now(), context.command(), context.commandContext()
61+
);
6062
this.confirmationManager.addPending(context.commandContext().sender(), confirmationContext);
6163
this.confirmationManager.configuration().confirmationRequiredNotifier().accept(
6264
context.commandContext().sender(),

0 commit comments

Comments
 (0)