diff --git a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java index 3f1a31866..0d9c407ec 100644 --- a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java @@ -504,13 +504,17 @@ protected CompletableFuture onTeamsTeamRenamed( return CompletableFuture.completedFuture(null); } - private CompletableFuture notImplemented() { + protected CompletableFuture notImplemented() { + return notImplemented(null); + } + + protected CompletableFuture notImplemented(String body) { CompletableFuture result = new CompletableFuture<>(); - result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED)); + result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED, body)); return result; } - private CompletableFuture withException(Throwable t) { + protected CompletableFuture withException(Throwable t) { CompletableFuture result = new CompletableFuture<>(); result.completeExceptionally(new CompletionException(t)); return result; diff --git a/libraries/bot-integration-core/src/main/java/com/microsoft/bot/integration/BotFrameworkHttpAdapter.java b/libraries/bot-integration-core/src/main/java/com/microsoft/bot/integration/BotFrameworkHttpAdapter.java index 7bf542ba7..810ea0486 100644 --- a/libraries/bot-integration-core/src/main/java/com/microsoft/bot/integration/BotFrameworkHttpAdapter.java +++ b/libraries/bot-integration-core/src/main/java/com/microsoft/bot/integration/BotFrameworkHttpAdapter.java @@ -5,6 +5,7 @@ import com.microsoft.bot.builder.Bot; import com.microsoft.bot.builder.BotFrameworkAdapter; +import com.microsoft.bot.builder.InvokeResponse; import com.microsoft.bot.connector.authentication.ChannelProvider; import com.microsoft.bot.connector.authentication.ChannelValidation; import com.microsoft.bot.connector.authentication.CredentialProvider; @@ -66,8 +67,7 @@ public BotFrameworkHttpAdapter(CredentialProvider withCredentialProvider, * @param bot A Bot. * @return A CompletableFuture. */ - public CompletableFuture processIncomingActivity(String authHeader, Activity activity, Bot bot) { - return processActivity(authHeader, activity, bot::onTurn) - .thenApply(invokeResponse -> null); + public CompletableFuture processIncomingActivity(String authHeader, Activity activity, Bot bot) { + return processActivity(authHeader, activity, bot::onTurn); } } diff --git a/libraries/bot-integration-spring/src/main/java/com/microsoft/bot/integration/spring/BotController.java b/libraries/bot-integration-spring/src/main/java/com/microsoft/bot/integration/spring/BotController.java index a19ad992e..79c44e70b 100644 --- a/libraries/bot-integration-spring/src/main/java/com/microsoft/bot/integration/spring/BotController.java +++ b/libraries/bot-integration-spring/src/main/java/com/microsoft/bot/integration/spring/BotController.java @@ -79,6 +79,9 @@ public CompletableFuture> incoming( .handle((result, exception) -> { if (exception == null) { + if (result != null) { + return new ResponseEntity<>(result.getBody(), HttpStatus.valueOf(result.getStatus())); + } return new ResponseEntity<>(HttpStatus.ACCEPTED); } diff --git a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/CardImage.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/CardImage.java index 74a7b82c8..96940221e 100644 --- a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/CardImage.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/CardImage.java @@ -31,6 +31,21 @@ public class CardImage { @JsonInclude(JsonInclude.Include.NON_EMPTY) private CardAction tap; + /** + * Creates a new CardImage. + */ + public CardImage() { + + } + + /** + * Creates a new CardImage with an initial URL. + * @param withUrl The URL for the image. + */ + public CardImage(String withUrl) { + setUrl(withUrl); + } + /** * Get the url value. * diff --git a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResponse.java index 5f4d94661..93c800cbf 100644 --- a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResponse.java @@ -12,6 +12,14 @@ public class MessagingExtensionResponse { @JsonProperty(value = "composeExtension") private MessagingExtensionResult composeExtension; + /** + * Creates a new response with the specified result. + * @param withResult The result. + */ + public MessagingExtensionResponse(MessagingExtensionResult withResult) { + composeExtension = withResult; + } + /** * Gets the response result. * @return The result. diff --git a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResult.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResult.java index a0ac6a49f..7c8d200f3 100644 --- a/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResult.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResult.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.bot.schema.Activity; +import java.util.Collections; import java.util.List; /** @@ -78,12 +79,22 @@ public List getAttachments() { /** * Sets (Only when type is result) Attachments. + * This replaces all previous attachments on the object. * @param withAttachments The result attachments. */ public void setAttachments(List withAttachments) { attachments = withAttachments; } + /** + * Sets (Only when type is result) Attachments to the specific attachment. + * This replaces all previous attachments on the object. + * @param withAttachment The attachment. + */ + public void setAttachment(MessagingExtensionAttachment withAttachment) { + setAttachments(Collections.singletonList(withAttachment)); + } + /** * Gets (Only when type is auth or config) suggested actions. * @return The suggested actions.