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

Commit 078c4d3

Browse files
authored
Merge pull request #413 from microsoft/trboehre/return-invokeresponse
Now returning InvokeResponse
2 parents 9d77a1c + cbb4f5b commit 078c4d3

File tree

6 files changed

+47
-6
lines changed

6 files changed

+47
-6
lines changed

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,17 @@ protected CompletableFuture<Void> onTeamsTeamRenamed(
504504
return CompletableFuture.completedFuture(null);
505505
}
506506

507-
private <T> CompletableFuture<T> notImplemented() {
507+
protected <T> CompletableFuture<T> notImplemented() {
508+
return notImplemented(null);
509+
}
510+
511+
protected <T> CompletableFuture<T> notImplemented(String body) {
508512
CompletableFuture<T> result = new CompletableFuture<>();
509-
result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED));
513+
result.completeExceptionally(new InvokeResponseExcetion(HttpURLConnection.HTTP_NOT_IMPLEMENTED, body));
510514
return result;
511515
}
512516

513-
private <T> CompletableFuture<T> withException(Throwable t) {
517+
protected <T> CompletableFuture<T> withException(Throwable t) {
514518
CompletableFuture<T> result = new CompletableFuture<>();
515519
result.completeExceptionally(new CompletionException(t));
516520
return result;

libraries/bot-integration-core/src/main/java/com/microsoft/bot/integration/BotFrameworkHttpAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.microsoft.bot.builder.Bot;
77
import com.microsoft.bot.builder.BotFrameworkAdapter;
8+
import com.microsoft.bot.builder.InvokeResponse;
89
import com.microsoft.bot.connector.authentication.ChannelProvider;
910
import com.microsoft.bot.connector.authentication.ChannelValidation;
1011
import com.microsoft.bot.connector.authentication.CredentialProvider;
@@ -66,8 +67,7 @@ public BotFrameworkHttpAdapter(CredentialProvider withCredentialProvider,
6667
* @param bot A Bot.
6768
* @return A CompletableFuture.
6869
*/
69-
public CompletableFuture<Void> processIncomingActivity(String authHeader, Activity activity, Bot bot) {
70-
return processActivity(authHeader, activity, bot::onTurn)
71-
.thenApply(invokeResponse -> null);
70+
public CompletableFuture<InvokeResponse> processIncomingActivity(String authHeader, Activity activity, Bot bot) {
71+
return processActivity(authHeader, activity, bot::onTurn);
7272
}
7373
}

libraries/bot-integration-spring/src/main/java/com/microsoft/bot/integration/spring/BotController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public CompletableFuture<ResponseEntity<Object>> incoming(
7979

8080
.handle((result, exception) -> {
8181
if (exception == null) {
82+
if (result != null) {
83+
return new ResponseEntity<>(result.getBody(), HttpStatus.valueOf(result.getStatus()));
84+
}
8285
return new ResponseEntity<>(HttpStatus.ACCEPTED);
8386
}
8487

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/CardImage.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ public class CardImage {
3131
@JsonInclude(JsonInclude.Include.NON_EMPTY)
3232
private CardAction tap;
3333

34+
/**
35+
* Creates a new CardImage.
36+
*/
37+
public CardImage() {
38+
39+
}
40+
41+
/**
42+
* Creates a new CardImage with an initial URL.
43+
* @param withUrl The URL for the image.
44+
*/
45+
public CardImage(String withUrl) {
46+
setUrl(withUrl);
47+
}
48+
3449
/**
3550
* Get the url value.
3651
*

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ public class MessagingExtensionResponse {
1212
@JsonProperty(value = "composeExtension")
1313
private MessagingExtensionResult composeExtension;
1414

15+
/**
16+
* Creates a new response with the specified result.
17+
* @param withResult The result.
18+
*/
19+
public MessagingExtensionResponse(MessagingExtensionResult withResult) {
20+
composeExtension = withResult;
21+
}
22+
1523
/**
1624
* Gets the response result.
1725
* @return The result.

libraries/bot-schema/src/main/java/com/microsoft/bot/schema/teams/MessagingExtensionResult.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.annotation.JsonProperty;
88
import com.microsoft.bot.schema.Activity;
99

10+
import java.util.Collections;
1011
import java.util.List;
1112

1213
/**
@@ -78,12 +79,22 @@ public List<MessagingExtensionAttachment> getAttachments() {
7879

7980
/**
8081
* Sets (Only when type is result) Attachments.
82+
* This replaces all previous attachments on the object.
8183
* @param withAttachments The result attachments.
8284
*/
8385
public void setAttachments(List<MessagingExtensionAttachment> withAttachments) {
8486
attachments = withAttachments;
8587
}
8688

89+
/**
90+
* Sets (Only when type is result) Attachments to the specific attachment.
91+
* This replaces all previous attachments on the object.
92+
* @param withAttachment The attachment.
93+
*/
94+
public void setAttachment(MessagingExtensionAttachment withAttachment) {
95+
setAttachments(Collections.singletonList(withAttachment));
96+
}
97+
8798
/**
8899
* Gets (Only when type is auth or config) suggested actions.
89100
* @return The suggested actions.

0 commit comments

Comments
 (0)