Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.onUnrecognizedActivityType(async (context, next) => {
// Handle EndOfConversation returned by the skill.
if (context.activity.type === ActivityTypes.EndOfConversation) {
// forget skill invocation
this.activeSkillProperty.set(context, undefined);
// We are back at the root
await context.sendActivity('Back in the root bot. Say \'skill\' and I\'ll patch you through');
// Save conversation state
await this.conversationState.saveChanges(context, true);
}
// By calling next() you ensure that the next BotHandler is run.
await next();
});
skillResponses.forEach(async (skillResponse: Activity) => {
// Once a Skill has finished it signals that it's handing back control to the parent through a
// EndOfConversation event which then causes the SkillDialog to be closed. Otherwise it remains "in control".
if (skillResponse.type === ActivityTypes.EndOfConversation) {
endOfConversation = true;
} else if (skillResponse.name === TokenEvents.tokenRequestEventName) {
if (tokenRequestHandler) {
await tokenRequestHandler(skillResponse);
}
} else {
// Trace messages are not filtered out and are sent along with messages/events.
filteredResponses.push(skillResponse);
}
});
it('should render nothing at the end of conversation', () => {
wrapper = shallow();
const middleware = card => children => <div>{children}</div>;
const mockCard = { activity: { type: ActivityTypes.EndOfConversation, valueType: ValueTypes.Activity } };
const activityWrapper = (wrapper.instance() as any).createActivityMiddleware()(middleware)(mockCard)(<span>);
expect(activityWrapper).toBe(null);
});
</span>
private createActivityMiddleware = () => next => card => children => {
const { valueType } = card.activity;
this.activityMap[card.activity.id] = valueType === ValueTypes.Activity ? card.activity.value : card.activity;
switch (card.activity.type) {
case ActivityTypes.Trace:
return this.renderTraceActivity(next, card, children);
case ActivityTypes.EndOfConversation:
return null;
default:
return this.activityWrapper(next, card, children);
}
};