Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async processActivity(activity: Activity, callback: BotCallbackHandler): Promise {
const message: string = `Received an incoming activity. ActivityId: ${activity.id}`;
this.telemetryClient.trackTrace({
message: message,
severityLevel: Severity.Information
});
const context: TurnContext = new TurnContext(this, activity);
await this.runMiddleware(context, callback);
// We do not support Invoke in websocket transport
if (activity.type === ActivityTypes.Invoke) {
return { status: 501 };
}
return { status: 200 };
}
if (request.path.toLocaleLowerCase() !== MESSAGES_PATH) {
response.statusCode = StatusCodes.NOT_FOUND;
return response;
}
try {
this.middleWare.forEach((mw): void => {
this.use(mw);
});
let context = new TurnContext(this, body);
await this.runMiddleware(context, async (turnContext): Promise => {
await this.bot.run(turnContext);
});
if (body.type === ActivityTypes.Invoke) {
let invokeResponse: any = context.turnState.get(INVOKE_RESPONSE);
if (invokeResponse && invokeResponse.value) {
const value: InvokeResponse = invokeResponse.value;
response.statusCode = value.status;
response.setBody(value.body);
} else {
response.statusCode = StatusCodes.NOT_IMPLEMENTED;
}
} else {
response.statusCode = StatusCodes.OK;
}
} catch (error) {
response.statusCode = StatusCodes.INTERNAL_SERVER_ERROR;
this.logger.log(error);