// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_hub_6_d_filetest // Test getting flags from a comment package z_hub_6_d_filetest import ( "testing" boards2 "gno.land/r/gnoland/boards2/v1" ) const ( owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh" admin = "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" moderator = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" ) var comment boards2.Comment func init(cur realm) { testing.SetRealm(testing.NewUserRealm(owner)) boardID := boards2.CreateBoard(cross(cur), "test123", false, false) threadID := boards2.CreateThread(cross(cur), boardID, "Title", "Body") commentID := boards2.CreateReply(cross(cur), boardID, threadID, 0, "Comment") // Invite member boards2.InviteMember(cross(cur), boardID, admin, "admin") boards2.InviteMember(cross(cur), boardID, moderator, "moderator") // Update flagging threshold to two flags boards2.SetFlaggingThreshold(cross(cur), boardID, 2) // Add first flag testing.SetRealm(testing.NewUserRealm(admin)) boards2.FlagReply(cross(cur), boardID, threadID, commentID, "Reason 1") // Add second flag testing.SetRealm(testing.NewUserRealm(moderator)) boards2.FlagReply(cross(cur), boardID, threadID, commentID, "Reason 2") // Get readonly comment comment, _ = boards2.GetComment(uint64(boardID), uint64(threadID), uint64(commentID)) } func main(cur realm) { flags := boards2.GetFlags(comment.BoardID(), comment.ThreadID(), comment.ID(), 0, comment.FlagCount()) for _, f := range flags { println(f.User(), f.Reason()) } } // Output: // g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 Reason 1 // g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj Reason 2