Skip to content

Commit 0dd58e4

Browse files
committed
fix default activity period when enabling courses
1 parent f182e2c commit 0dd58e4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/server/routes/chatInstance.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,15 @@ chatInstanceRouter.post('/:id/enable', async (req, res) => {
9090
throw ApplicationError.NotFound('ChatInstance not found')
9191
}
9292

93-
// @todo what?? this is extremely confusing. shouldnt we set the activity period based on the courseActivityPeriod??
94-
const defaultActivityPeriod = {
95-
startDate: chatInstance.activityPeriod.startDate,
96-
endDate: addMonths(chatInstance.activityPeriod.startDate, 1).toDateString(),
97-
}
93+
const defaultActivityPeriod = chatInstance.courseActivityPeriod
94+
? {
95+
startDate: chatInstance.courseActivityPeriod.startDate,
96+
endDate: addMonths(chatInstance.courseActivityPeriod?.endDate, 1).toDateString(),
97+
}
98+
: {
99+
startDate: new Date().toDateString(),
100+
endDate: addMonths(new Date(), 1).toDateString(),
101+
}
98102

99103
chatInstance.usageLimit = DEFAULT_TOKEN_LIMIT
100104
chatInstance.activityPeriod = defaultActivityPeriod

0 commit comments

Comments
 (0)