Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update channelServiceRoutes to add next() parameter to support restify 10.0.0+ #4429

Merged
merged 4 commits into from
Feb 16, 2023
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
39 changes: 26 additions & 13 deletions libraries/botbuilder/src/channelServiceRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processSendToConversation(req: WebRequest, res: WebResponse): void {
private processSendToConversation(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readActivity(req)
.then((activity) => {
Expand All @@ -92,6 +92,7 @@ export class ChannelServiceRoutes {
res.send(resourceResponse);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -105,7 +106,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processReplyToActivity(req: WebRequest, res: WebResponse): void {
private processReplyToActivity(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readActivity(req)
.then((activity) => {
Expand All @@ -117,6 +118,7 @@ export class ChannelServiceRoutes {
res.send(resourceResponse);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -130,7 +132,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processUpdateActivity(req: WebRequest, res: WebResponse): void {
private processUpdateActivity(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readActivity(req)
.then((activity) => {
Expand All @@ -142,6 +144,7 @@ export class ChannelServiceRoutes {
res.send(resourceResponse);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -155,13 +158,14 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processDeleteActivity(req: WebRequest, res: WebResponse): void {
private processDeleteActivity(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleDeleteActivity(authHeader, req.params.conversationId, req.params.activityId)
.then(() => {
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -171,7 +175,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processGetActivityMembers(req: WebRequest, res: WebResponse): void {
private processGetActivityMembers(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleGetActivityMembers(authHeader, req.params.conversationId, req.params.activityId)
Expand All @@ -181,6 +185,7 @@ export class ChannelServiceRoutes {
}
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -190,7 +195,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processCreateConversation(req: WebRequest, res: WebResponse): void {
private processCreateConversation(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readBody<ConversationParameters>(req).then((conversationParameters) => {
this.channelServiceHandler
Expand All @@ -201,6 +206,7 @@ export class ChannelServiceRoutes {
}
res.status(201);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -211,7 +217,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processGetConversations(req: WebRequest, res: WebResponse): void {
private processGetConversations(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleGetConversations(authHeader, req.params.conversationId, req.query.continuationToken)
Expand All @@ -221,6 +227,7 @@ export class ChannelServiceRoutes {
}
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -230,7 +237,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processGetConversationMembers(req: WebRequest, res: WebResponse): void {
private processGetConversationMembers(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleGetConversationMembers(authHeader, req.params.conversationId)
Expand All @@ -240,6 +247,7 @@ export class ChannelServiceRoutes {
res.send(channelAccounts);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -249,7 +257,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processGetConversationMember(req: WebRequest, res: WebResponse): void {
private processGetConversationMember(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleGetConversationMember(authHeader, req.params.memberId, req.params.conversationId)
Expand All @@ -259,6 +267,7 @@ export class ChannelServiceRoutes {
res.send(channelAccount);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -268,7 +277,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processGetConversationPagedMembers(req: WebRequest, res: WebResponse): void {
private processGetConversationPagedMembers(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
let pageSize = parseInt(req.query.pageSize);
if (isNaN(pageSize)) {
Expand All @@ -287,6 +296,7 @@ export class ChannelServiceRoutes {
res.send(pagedMembersResult);
}
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -296,13 +306,14 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processDeleteConversationMember(req: WebRequest, res: WebResponse): void {
private processDeleteConversationMember(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
this.channelServiceHandler
.handleDeleteConversationMember(authHeader, req.params.conversationId, req.params.memberId)
.then(() => {
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -312,7 +323,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processSendConversationHistory(req: WebRequest, res: WebResponse): void {
private processSendConversationHistory(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readBody<Transcript>(req)
.then((transcript) => {
Expand All @@ -324,6 +335,7 @@ export class ChannelServiceRoutes {
}
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand All @@ -337,7 +349,7 @@ export class ChannelServiceRoutes {
/**
* @private
*/
private processUploadAttachment(req: WebRequest, res: WebResponse): void {
private processUploadAttachment(req: WebRequest, res: WebResponse, next: Function): void {
const authHeader = req.headers.authorization || req.headers.Authorization || '';
ChannelServiceRoutes.readBody<AttachmentData>(req)
.then((attachmentData) => {
Expand All @@ -349,6 +361,7 @@ export class ChannelServiceRoutes {
}
res.status(200);
res.end();
return next();
})
.catch((err) => {
ChannelServiceRoutes.handleError(err, res);
Expand Down
Loading