Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
To maintain content quality and enforce community standards within the r/boards realm, a reliable flagging system is necessary. This system should allow designated users (e.g., moderators) to flag posts for review and potential deletion. The system should support a configurable threshold for automatic deletion when the flag count is met.
Acceptance Criteria:
[ ] Implements a Flag struct to store flagging details.
Example
```go
type Flag struct {
User Address
Reason string
}
```
[ ] Extends the Post struct to include a Flags field to track flags.
Example
```go
type Post struct {
ID int64
Content string
Flags []Flag
}
```
[ ] Includes a FlagPost method that:
Verifies user roles to ensure permission to flag.
Adds a Flag entry to the post's Flags field.
[ ] Includes logic to automatically delete posts when the Flags count reaches or exceeds a configurable NumFlagsNeeded threshold.
Example
```go
if len(post.Flags) >= NumFlagsNeeded {
post.Delete()
}
```
Eventually, can use bp.WithPermission() to enforce that only users with the "flag:post" permission can flag content.
Context:
To maintain content quality and enforce community standards within the
r/boards
realm, a reliable flagging system is necessary. This system should allow designated users (e.g., moderators) to flag posts for review and potential deletion. The system should support a configurable threshold for automatic deletion when the flag count is met.Acceptance Criteria:
[ ] Implements a
Flag
struct to store flagging details.Example
```go type Flag struct { User Address Reason string } ```[ ] Extends the
Post
struct to include aFlags
field to track flags.Example
```go type Post struct { ID int64 Content string Flags []Flag } ```[ ] Includes a
FlagPost
method that:Flag
entry to the post'sFlags
field.[ ] Includes logic to automatically delete posts when the
Flags
count reaches or exceeds a configurableNumFlagsNeeded
threshold.Example
```go if len(post.Flags) >= NumFlagsNeeded { post.Delete() } ```Eventually, can use
bp.WithPermission()
to enforce that only users with the "flag:post" permission can flag content.Example
```go bp.WithPermission(user, "flag:post", []interface{}{postID, reason}, func() { post.AddFlag(Flag{User: user, Reason: reason}) if len(post.Flags) >= NumFlagsNeeded { post.Delete() } }) ```[ ] Includes error handling for cases where:
[ ] Conduct tests to:
NumFlagsNeeded
.[ ]
NumFlagsNeeded
is configurable for future policy or threshold adjustments.