Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Now returning InvokeResponse #413

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,17 @@ protected CompletableFuture<Void> onTeamsTeamRenamed(
return CompletableFuture.completedFuture(null);
}

private <T> CompletableFuture<T> notImplemented() {
protected <T> CompletableFuture<T> notImplemented() {
return notImplemented(null);
}

protected <T> CompletableFuture<T> notImplemented(String body) {
CompletableFuture<T> result = new CompletableFuture<>();
result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED));
result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED, body));
return result;
}

private <T> CompletableFuture<T> withException(Throwable t) {
protected <T> CompletableFuture<T> withException(Throwable t) {
CompletableFuture<T> result = new CompletableFuture<>();
result.completeExceptionally(new CompletionException(t));
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,8 +67,7 @@ public BotFrameworkHttpAdapter(CredentialProvider withCredentialProvider,
* @param bot A Bot.
* @return A CompletableFuture.
*/
public CompletableFuture<Void> processIncomingActivity(String authHeader, Activity activity, Bot bot) {
return processActivity(authHeader, activity, bot::onTurn)
.thenApply(invokeResponse -> null);
public CompletableFuture<InvokeResponse> processIncomingActivity(String authHeader, Activity activity, Bot bot) {
return processActivity(authHeader, activity, bot::onTurn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public CompletableFuture<ResponseEntity<Object>> incoming(

.handle((result, exception) -> {
if (exception == null) {
if (result != null) {
return new ResponseEntity<>(result.getBody(), HttpStatus.valueOf(result.getStatus()));
}
return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.microsoft.bot.schema.Activity;

import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -78,12 +79,22 @@ public List<MessagingExtensionAttachment> 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<MessagingExtensionAttachment> 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.
Expand Down