Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_flag_reply_07_filetest.gno

1.66 Kb · 54 lines
 1package main
 2
 3import (
 4	"testing"
 5
 6	"gno.land/p/gnoland/boards"
 7
 8	boards2 "gno.land/r/gnoland/boards2/v1"
 9)
10
11const (
12	owner     address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
13	moderator address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
14)
15
16var (
17	bid      boards.ID
18	rid, tid boards.ID
19)
20
21func init() {
22	// Created a board with flagging threshold greater than 1
23	testing.SetRealm(testing.NewUserRealm(owner))
24	bid = boards2.CreateBoard(cross, "test-board", false, false)
25	boards2.SetFlaggingThreshold(cross, bid, 2)
26
27	// Create a reply so the realm owner can flag and hide it with a single flag
28	tid = boards2.CreateThread(cross, bid, "Foo", "bar")
29	rid = boards2.CreateReply(cross, bid, tid, 0, "body")
30	// Also freeze board to make sure that realm owner can still flag the reply
31	boards2.FreezeBoard(cross, bid)
32}
33
34func main() {
35	testing.SetRealm(testing.NewUserRealm(owner))
36
37	boards2.FlagReply(cross, bid, tid, rid, "Reason")
38
39	// Render content must contain a message about the hidden reply
40	println(boards2.Render("test-board/1/2"))
41}
42
43// Output:
44// ## Foo
45//
46// **[g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq](/u/g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq)** `owner` · 2009-02-13 11:31pm UTC
47// bar
48//
49// ↳ [Flag](/r/gnoland/boards2/v1:test-board/1/flag) • [Repost](/r/gnoland/boards2/v1:test-board/1/repost) • [Show all Replies](/r/gnoland/boards2/v1:test-board/1)
50//
51//
52// >
53// > **[g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq](/u/g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq)** `owner` · 2009-02-13 11:31pm UTC [#2](/r/gnoland/boards2/v1:test-board/1/2)
54// > ⚠ Reply is hidden as it has been flagged as [inappropriate](/r/gnoland/boards2/v1:test-board/1/2/flagging-reasons)