Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r/boards] comment flagging #3480

Open
6 tasks
salmad3 opened this issue Jan 10, 2025 · 0 comments
Open
6 tasks

[r/boards] comment flagging #3480

salmad3 opened this issue Jan 10, 2025 · 0 comments

Comments

@salmad3
Copy link
Member

salmad3 commented Jan 10, 2025

Context

While thread flagging manages top-level posts, comment flagging addresses user replies within a thread. Comments often form nested discussions, so it’s crucial for moderators and admins to flag problematic replies without hiding the entire thread.

Acceptance Criteria

  • Struct Updates

    • Extend the Comment struct (or Post where ParentID != 0) to include a Flags field of type []Flag and a Hidden boolean.
    Example
    type Comment struct {
        CommentID    string
        ParentThread string
        Author       Address
        Content      string
        Timestamp    time.Time
        Flags        []Flag
        Hidden       bool
        // ... other fields
    }
  • Flag Comment Function

    • A FlagComment(caller Address, commentID string, reason string) function:
      1. Checks if the caller has "flag:comment" permission.
      2. Fetches the comment by ID.
      3. Appends a Flag to comment.Flags.
      4. If len(comment.Flags) >= CommentFlagThreshold, set comment.Hidden = true.
      5. Returns an error if already hidden or if caller lacks permission.
    Example
    func (br *BoardsRealm) FlagComment(caller Address, commentID string, reason string) error {
        if !br.HasPermission(caller, "flag:comment", []interface{}{commentID}) {
            return errors.New("caller does not have permission to flag comments")
        }
    
        comment := br.GetCommentByID(commentID)
        if comment == nil {
            return errors.New("comment not found")
        }
        if comment.Hidden {
            return errors.New("comment is already hidden")
        }
    
        newFlag := Flag{
            User:   caller,
            Reason: reason,
            Date:   time.Now(),
        }
        comment.Flags = append(comment.Flags, newFlag)
    
        if len(comment.Flags) >= br.Config.CommentFlagThreshold {
            comment.Hidden = true
        }
    
        br.UpdateComment(comment)
        return nil
    }
  • Permissions

    • Must verify "flag:comment".
    • Restricted to moderators, admins, or owners by default.
  • Hidden Comment Behavior

    • A hidden comment should either not appear or appear as [Hidden Comment].
    • The child replies might still be visible, or the entire sub-thread might hide—implementation detail for MVP.
  • Configuration

    • CommentFlagThreshold in BoardsRealmConfig, defaulting to 1 or a small integer for MVP.
    • Ability to be overridden at board level or via AdminDAO in future.
  • Tests

    • Successfully flagging a comment by an authorized user.
    • Failing to flag with no permissions.
    • Hiding comments upon threshold.
    • Edge cases: repeated flags, invalid comment IDs, etc.

Notes

  • This system parallels thread flagging but focuses on deeper discussion layers.
  • Future expansions include:
    • Distinct reason codes, feedback loops for moderators.
    • “Soft hides” that let the author see their own comment but hide it from others.
    • Appeals or multi-step moderation for flagged comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant