Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
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 @@ -31,6 +31,7 @@
import com.microsoft.bot.connector.rest.RestOAuthClient;
import com.microsoft.bot.schema.AadResourceUrls;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityEventNames;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.CallerIdConstants;
import com.microsoft.bot.schema.ChannelAccount;
Expand Down Expand Up @@ -1040,7 +1041,7 @@ public CompletableFuture<Void> createConversation(
.thenCompose(conversationResourceResponse -> {
// Create a event activity to represent the result.
Activity eventActivity = Activity.createEventActivity();
eventActivity.setName("CreateConversation");
eventActivity.setName(ActivityEventNames.CREATE_CONVERSATION);
eventActivity.setChannelId(channelId);
eventActivity.setServiceUrl(serviceUrl);
eventActivity.setId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.connector.Channels;
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
Expand All @@ -19,6 +21,7 @@
import com.microsoft.bot.connector.authentication.SimpleChannelProvider;
import com.microsoft.bot.connector.authentication.SimpleCredentialProvider;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityEventNames;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.CallerIdConstants;
import com.microsoft.bot.schema.ConversationAccount;
Expand All @@ -32,6 +35,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -66,7 +71,7 @@ public void CreateConversationOverloadProperlySetsTenantId() {
final String ActivityIdValue = "SendActivityId";
final String ConversationIdValue = "NewConversationId";
final String TenantIdValue = "theTenantId";
final String EventActivityName = "CreateConversation";
final String EventActivityName = ActivityEventNames.CREATE_CONVERSATION;

// so we can provide a mock ConnectorClient.
class TestBotFrameworkAdapter extends BotFrameworkAdapter {
Expand Down Expand Up @@ -319,6 +324,39 @@ private void processActivityCreatesCorrectCredsAndClient(
}, callback).join();
}

@Test
public void ShouldNotLogContinueConversation() {
TranscriptStore transcriptStore = new MemoryTranscriptStore();
TranscriptLoggerMiddleware sut = new TranscriptLoggerMiddleware(transcriptStore);

String conversationId = UUID.randomUUID().toString();
TestAdapter adapter = new TestAdapter(TestAdapter.createConversationReference(conversationId, "User1", "Bot"))
.use(sut);

Activity continueConversation = new Activity(ActivityTypes.EVENT);
continueConversation.setName(ActivityEventNames.CONTINUE_CONVERSATION);

new TestFlow(adapter, turnContext -> {
return turnContext.sendActivity("bar").thenApply(resourceResponse -> null);
})
.send("foo")
.assertReply(activity -> {
Assert.assertEquals("bar", activity.getText());
PagedResult<Activity> activities = transcriptStore.getTranscriptActivities(activity.getChannelId(), conversationId).join();
Assert.assertEquals(2, activities.getItems().size());
})
.send(continueConversation)
.assertReply(activity -> {
// Ensure the event hasn't been added to the transcript.
PagedResult<Activity> activities = transcriptStore.getTranscriptActivities(activity.getChannelId(), conversationId).join();

Assert.assertFalse(activities.getItems().stream().anyMatch(a -> a.isType(ActivityTypes.EVENT) && StringUtils
.equals(a.getName(), ActivityEventNames.CONTINUE_CONVERSATION)));
Assert.assertEquals(3, activities.getItems().size());
})
.startTest().join();
}

private static void getAppCredentialsAndAssertValues(
TurnContext turnContext,
String expectedAppId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public CompletableFuture<AttachmentInfo> getAttachmentInfo(String attachmentId)
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("getAttachmentInfoAsync", responseBodyResponse);
throw new ErrorResponseException("getAttachmentInfo", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public CompletableFuture<InputStream> getAttachment(String attachmentId, String
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("getAttachmentAsync", responseBodyResponse);
throw new ErrorResponseException("getAttachment", responseBodyResponse);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public CompletableFuture<ConversationsResult> getConversations(String continuati
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("getConversationsAsync", responseBodyResponse);
throw new ErrorResponseException("getConversations", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -279,7 +279,7 @@ public CompletableFuture<ConversationResourceResponse> createConversation(
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"createConversationAsync",
"createConversation",
responseBodyResponse
);
}
Expand Down Expand Up @@ -339,7 +339,7 @@ public CompletableFuture<ResourceResponse> sendToConversation(
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("sendToConversationAsync", responseBodyResponse);
throw new ErrorResponseException("sendToConversation", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -402,7 +402,7 @@ public CompletableFuture<ResourceResponse> updateActivity(
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"updateActivityAsync", responseBodyResponse);
"updateActivity", responseBodyResponse);
}
});
});
Expand Down Expand Up @@ -463,7 +463,7 @@ public CompletableFuture<ResourceResponse> replyToActivity(
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("replyToActivityAsync", responseBodyResponse);
throw new ErrorResponseException("replyToActivity", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -511,7 +511,7 @@ public CompletableFuture<Void> deleteActivity(String conversationId, String acti
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("deleteActivityAsync", responseBodyResponse);
throw new ErrorResponseException("deleteActivity", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -553,7 +553,7 @@ public CompletableFuture<List<ChannelAccount>> getConversationMembers(String con
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"getConversationMembersAsync",
"getConversationMembers",
responseBodyResponse
);
}
Expand Down Expand Up @@ -603,7 +603,7 @@ public CompletableFuture<ChannelAccount> getConversationMember(
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"getConversationMembersAsync",
"getConversationMember",
responseBodyResponse
);
}
Expand Down Expand Up @@ -656,7 +656,7 @@ public CompletableFuture<Void> deleteConversationMember(
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"deleteConversationMemberAsync",
"deleteConversationMember",
responseBodyResponse
);
}
Expand Down Expand Up @@ -707,7 +707,7 @@ public CompletableFuture<List<ChannelAccount>> getActivityMembers(
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("getActivityMembersAsync", responseBodyResponse);
throw new ErrorResponseException("getActivityMembers", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -757,7 +757,7 @@ public CompletableFuture<ResourceResponse> uploadAttachment(
} catch (ErrorResponseException e) {
throw e;
} catch (Throwable t) {
throw new ErrorResponseException("uploadAttachmentAsync", responseBodyResponse);
throw new ErrorResponseException("uploadAttachment", responseBodyResponse);
}
});
}
Expand Down Expand Up @@ -812,7 +812,7 @@ public CompletableFuture<ResourceResponse> sendConversationHistory(
throw e;
} catch (Throwable t) {
throw new ErrorResponseException(
"sendConversationHistoryAsync",
"sendConversationHistory",
responseBodyResponse
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static ConversationReference clone(ConversationReference conversationRefe
@JsonIgnore
public Activity getContinuationActivity() {
Activity activity = Activity.createEventActivity();
activity.setName("ContinueConversation");
activity.setName(ActivityEventNames.CONTINUE_CONVERSATION);
activity.setId(UUID.randomUUID().toString());
activity.setChannelId(getChannelId());
activity.setConversation(getConversation());
Expand Down