Discussion only open while a study is active; v2.11.1
Publish Container / build (push) Has been cancelled

- Community posts, replies, likes and lesson comments are refused (403) for finished and planned studies
- Reading a closed study's community/comments returns an empty list with closed:true
- Discussion hub lists only active studies; community page shows a closed notice
- Lesson page hides Lesson Discussion, 'Discuss this lesson' and 'Go to Community' for inactive studies; Community buttons hidden on study/dashboard pages
- Tests for isStudyDiscussionOpen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 5.5 committed 2026-10-09 11:49:03 -04:00
1 parent bb83f3e8c5
commit f1d4909acb
7 files changed
+98 -14

No files matched your search

+20
View File
@@ -12,6 +12,8 @@ import {
getCommunityDisplayName,
getAccessibleStudySlugs,
markStudyCompletedIfDone,
isStudyDiscussionOpen,
DISCUSSION_CLOSED_MESSAGE,
} from '../study-helpers.js'
import { state } from '../state.js'
import {
@@ -368,6 +370,11 @@ export function register(app) {
return
}
if (!isStudyDiscussionOpen(studySlug)) {
res.json({ studySlug, posts: [], closed: true, message: DISCUSSION_CLOSED_MESSAGE })
return
}
const posts = state.studyCommunityPosts
.filter(post => post.studySlug === studySlug)
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
@@ -413,6 +420,11 @@ export function register(app) {
return
}
if (!isStudyDiscussionOpen(studySlug)) {
res.status(403).json({ message: DISCUSSION_CLOSED_MESSAGE, closed: true })
return
}
const now = new Date().toISOString()
const authorName = getCommunityDisplayName(user)
const post = {
@@ -455,6 +467,11 @@ export function register(app) {
return
}
if (!isStudyDiscussionOpen(post.studySlug)) {
res.status(403).json({ message: DISCUSSION_CLOSED_MESSAGE, closed: true })
return
}
const reply = {
id: randomUUID(),
authorUserId: user.id,
@@ -480,6 +497,9 @@ export function register(app) {
if (!hasStudyAccess(user, post.studySlug)) {
res.status(403).json({ message: 'Please enroll in this study to like posts.' }); return
}
if (!isStudyDiscussionOpen(post.studySlug)) {
res.status(403).json({ message: DISCUSSION_CLOSED_MESSAGE, closed: true }); return
}
if (!Array.isArray(post.likedBy)) post.likedBy = []
const idx = post.likedBy.indexOf(user.id)
if (idx === -1) {