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

Commit 9d77a1c

Browse files
authored
Merge pull request #411 from microsoft/trboehre/invoke-and-serializer-fix
Corrected Invoke Activity reply type and Serialization class
2 parents 5d25283 + b3d53fa commit 9d77a1c

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/ActivityHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public CompletableFuture<Void> onTurn(TurnContext turnContext) {
6969
if (invokeResponse != null
7070
&& turnContext.getTurnState().get(BotFrameworkAdapter.INVOKE_RESPONSE_KEY) == null) {
7171

72-
Activity activity = new Activity(ActivityTypes.INVOKE);
72+
Activity activity = new Activity(ActivityTypes.INVOKE_RESPONSE);
7373
activity.setValue(invokeResponse);
7474

7575
return turnContext.sendActivity(activity);

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,17 @@ static CompletableFuture<ResourceResponse> traceActivity(
142142
*/
143143
CompletableFuture<ResourceResponse> sendActivity(Activity activity);
144144

145+
/**
146+
* Sends an Activity to the sender of the incoming Activity without
147+
* returning a ResourceResponse.
148+
*
149+
* @param activity The activity to send.
150+
* @return A task that represents the work queued to execute.
151+
*/
152+
default CompletableFuture<Void> sendActivityBlind(Activity activity) {
153+
return sendActivity(activity).thenApply(aVoid -> null);
154+
}
155+
145156
/**
146157
* Sends a list of activities to the sender of the incoming activity.
147158
*

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,14 @@ public void setAttachments(List<Attachment> withAttachments) {
771771
this.attachments = withAttachments;
772772
}
773773

774+
/**
775+
* Sets a single attachment on the Activity.
776+
* @param withAttachment The Attachment object.
777+
*/
778+
public void setAttachment(Attachment withAttachment) {
779+
setAttachments(Collections.singletonList(withAttachment));
780+
}
781+
774782
/**
775783
* Returns payload version of the Entities in an Activity.
776784
*
@@ -1194,6 +1202,14 @@ public Activity createTrace(String withName, Object withValue, String withValueT
11941202
return reply;
11951203
}
11961204

1205+
/**
1206+
* Creates a new message activity as a response to this activity.
1207+
* @return The new message activity.
1208+
*/
1209+
public Activity createReply() {
1210+
return createReply(null, null);
1211+
}
1212+
11971213
/**
11981214
* Creates a new message activity as a response to this activity.
11991215
*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.microsoft.bot.schema;
55

66
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.DeserializationFeature;
78
import com.fasterxml.jackson.databind.JsonNode;
89
import com.fasterxml.jackson.databind.ObjectMapper;
910

@@ -22,6 +23,7 @@ private Serialization() {
2223

2324
static {
2425
objectMapper = new ObjectMapper();
26+
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2527
objectMapper.findAndRegisterModules();
2628
}
2729

0 commit comments

Comments
 (0)