mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
Treat legacy boolean commenting preference as disabled
Teams not yet migrated to the CommentingAccess enum may still have a boolean `false` stored for the commenting preference. Guard the enabled checks so `false` reads as disabled rather than enabled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -106,9 +106,9 @@ class Team extends Model {
|
||||
*/
|
||||
@computed
|
||||
get commentingEnabled(): boolean {
|
||||
return (
|
||||
this.getPreference(TeamPreference.Commenting) !== CommentingAccess.None
|
||||
);
|
||||
const access = this.getPreference(TeamPreference.Commenting);
|
||||
// A legacy boolean `false` (team not yet migrated) means disabled.
|
||||
return access !== CommentingAccess.None && access !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,10 +28,11 @@ export function commentingEnabled() {
|
||||
ctx: APIContext,
|
||||
next: Next
|
||||
) {
|
||||
if (
|
||||
ctx.state.auth.user.team.getPreference(TeamPreference.Commenting) ===
|
||||
CommentingAccess.None
|
||||
) {
|
||||
const commenting = ctx.state.auth.user.team.getPreference(
|
||||
TeamPreference.Commenting
|
||||
);
|
||||
// A legacy boolean `false` (team not yet migrated) means disabled.
|
||||
if (commenting === CommentingAccess.None || commenting === false) {
|
||||
throw ValidationError("Commenting is currently disabled");
|
||||
}
|
||||
return next();
|
||||
|
||||
@@ -56,7 +56,8 @@ allow(User, "comment", Document, (actor, document) => {
|
||||
!!document?.isActive,
|
||||
isTeamMutable(actor),
|
||||
can(actor, "read", document),
|
||||
commenting !== CommentingAccess.None,
|
||||
// A legacy boolean `false` (team not yet migrated) means disabled.
|
||||
commenting !== CommentingAccess.None && commenting !== false,
|
||||
or(!actor.isGuest, commenting === CommentingAccess.Everyone),
|
||||
or(!document?.collection, document?.collection?.commenting !== false)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user