You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Freezing posts (i.e., individual replies or comments within a thread) is aimed at ensuring that once a post is frozen, it becomes completely immutable. This prevents any further editing, deletion, or flagging actions, even if the post’s author or a moderator would normally be allowed to modify it.
Updates the Post (or reply/comment) struct to include a Frozen boolean field.
Example
typePoststruct {
PostIDstringParentIDstring// if empty, this is a thread; if set, it's a reply/commentAuthorAddressContentstringTimestamp time.TimeFlags []FlagFrozenbool// indicates whether the post is frozen// ... other fields
}
Implements a FreezePost(boardID BoardID, threadID PostID, postID PostID) function that:
Checks that the specified post is not already frozen.
Validates the caller's permission to freeze posts (e.g., PermissionPostFreeze).
Sets the post’s Frozen flag to true to block any further modifications.
Example
funcFreezePost(boardIDBoardID, threadIDPostID, postIDPostID) {
board:=mustGetBoard(boardID)
thread:=mustGetThread(board, threadID)
post:=mustGetReply(thread, postID) // assuming posts are accessed via replies in a threadifpost.Frozen {
panic("post is already frozen")
}
caller:=std.GetOrigCaller()
args:=Args{boardID, threadID, postID}
board.perms.WithPermission(caller, PermissionPostFreeze, args, func(Args) {
// Re-check the post to ensure it hasn't been frozen in the meantimepost:=mustGetReply(thread, postID)
ifpost.Frozen {
panic("post is already frozen")
}
post.Frozen=true
})
}
Provides an UnfreezePost(boardID BoardID, threadID PostID, postID PostID) function that:
Validates that the post is currently frozen.
Checks that the caller is authorized to perform the unfreeze operation.
Resets the Frozen flag to false.
Overrides Existing Permissions
Once a post is frozen, any actions that would normally modify it (editing, deleting, adding flags, etc.) are blocked.
Relevant post-modification functions check for the Frozen state and respond with an error or panic if true.
Tests
Confirms that a frozen post cannot be edited, deleted, or flagged.
Ensures that only users with the freeze permission can freeze or unfreeze a post.
Attempting to freeze an already frozen post results in an appropriate error.
Validate that once a post is unfrozen, normal modifications are allowed again.
The text was updated successfully, but these errors were encountered:
Context:
Freezing posts (i.e., individual replies or comments within a thread) is aimed at ensuring that once a post is frozen, it becomes completely immutable. This prevents any further editing, deletion, or flagging actions, even if the post’s author or a moderator would normally be allowed to modify it.
Follows: #3755
Related to:
Acceptance Criteria:
Updates the
Post
(or reply/comment) struct to include aFrozen
boolean field.Example
Implements a
FreezePost(boardID BoardID, threadID PostID, postID PostID)
function that:PermissionPostFreeze
).Frozen
flag totrue
to block any further modifications.Example
Provides an
UnfreezePost(boardID BoardID, threadID PostID, postID PostID)
function that:Frozen
flag tofalse
.Overrides Existing Permissions
Frozen
state and respond with an error or panic if true.Tests
The text was updated successfully, but these errors were encountered: