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
Flagging is a critical moderation function for identifying and managing inappropriate, spam, or otherwise undesirable content at the thread level. Threads are typically top-level posts within a board. Building on the broader flagging system, we now want to introduce thread-specific flagging that:
Allows authorized users (moderators, admins, owners) to flag entire threads.
Hides or restricts flagged threads once they reach a configurable threshold.
Integrates smoothly with the permissions system (HasPermission or WithPermission).
Acceptance Criteria
Struct Updates
Extend the Thread struct (or Post with ParentID == 0) to include a Flags field of type []Flag, plus a Hidden boolean.
Example
typeThreadstruct {
ThreadIDstringTitlestringAuthorAddressContentstringTimestamp time.TimeFlags []Flag// appended for thread-level flagsHiddenbool// ... other potential fields
}
typeFlagstruct {
UserAddressReasonstringDate time.Time
}
Flagging Function
Add a FlagThread(threadID string, reason string) function that:
Checks if the caller has permission to flag threads (e.g., "flag:thread").
Locates the thread by threadID.
Appends a new Flag to the thread.Flags.
If len(thread.Flags) >= ThreadFlagThreshold, set thread.Hidden = true.
Returns an error if the thread is already hidden or if the caller lacks permission.
Example
func (br*BoardsRealm) FlagThread(callerAddress, threadIDstring, reasonstring) error {
if!br.HasPermission(caller, "flag:thread", []interface{}{threadID}) {
returnerrors.New("caller does not have permission to flag threads")
}
thread:=br.GetThreadByID(threadID)
ifthread==nil {
returnerrors.New("thread not found")
}
ifthread.Hidden {
returnerrors.New("thread is already hidden")
}
newFlag:=Flag{
User: caller,
Reason: reason,
Date: time.Now(),
}
thread.Flags=append(thread.Flags, newFlag)
iflen(thread.Flags) >=br.Config.ThreadFlagThreshold {
thread.Hidden=true
}
br.UpdateThread(thread)
returnnil
}
Permissions
Must verify the correct permission key (e.g., "flag:thread").
By default, only moderators or admins can flag threads in the MVP.
Configuration
A ThreadFlagThreshold in BoardsRealmConfig, defaulting to 1 or a small integer.
Possibly overridden by a board-specific or AdminDAO-based setting later.
Tests
Confirm that a user with "flag:thread" can successfully flag a thread.
Ensure unauthorized users fail to flag.
Validate that a hidden thread cannot be flagged again.
Test repeated flags from the same user, invalid threadID, etc.
Notes
Initially, ThreadFlagThreshold might be set globally.
Future expansions:
Differing thresholds per board.
More detailed reason codes (e.g. “spam,” “abuse,” “off-topic”).
Automatic triggers for freezing a board if multiple threads get flagged quickly.
The text was updated successfully, but these errors were encountered:
Context
Flagging is a critical moderation function for identifying and managing inappropriate, spam, or otherwise undesirable content at the thread level. Threads are typically top-level posts within a board. Building on the broader flagging system, we now want to introduce thread-specific flagging that:
HasPermission
orWithPermission
).Acceptance Criteria
Struct Updates
Extend the
Thread
struct (orPost
withParentID == 0
) to include aFlags
field of type[]Flag
, plus aHidden
boolean.Example
Flagging Function
FlagThread(threadID string, reason string)
function that:Checks if the caller has permission to flag threads (e.g.,
"flag:thread"
).Locates the thread by
threadID
.Appends a new
Flag
to thethread.Flags
.If
len(thread.Flags) >= ThreadFlagThreshold
, setthread.Hidden = true
.Returns an error if the thread is already hidden or if the caller lacks permission.
Example
Permissions
"flag:thread"
).Configuration
ThreadFlagThreshold
inBoardsRealmConfig
, defaulting to 1 or a small integer.Tests
"flag:thread"
can successfully flag a thread.threadID
, etc.Notes
ThreadFlagThreshold
might be set globally.The text was updated successfully, but these errors were encountered: