Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

hub source realm

Package hub exposes safe, read-only views over boards2's persistent state. The Get\* functions are crossing functions...

Overview

Package hub exposes safe, read-only views over boards2's persistent state. The Get* functions are crossing functions: callers must invoke them with `cross` (e.g. `hub.GetBoard(cross, id)`). The crossing into hub gives each call a live `cur` whose `Previous()` is the caller's realm — that's what boards2's protected entry points use for the namespace check.

Note for future maintainers: inside a Get* body, `cur.Previous()` is the *immediate* caller's realm, which may be an intermediary, not necessarily the end user. Do not graft user-identity gating onto these reads.

Functions 13

func GetFlags

crossing Action
1func GetFlags(cur realm, boardID, threadID, commentID uint64, start, count int) []boards.Flag
source

GetFlag returns a list with thread or comment moderation flags. To reverse iterate use a negative count. Thread flags are returned when `commentID` is zero, or comment flags are returned otherwise.

func GetMembers

crossing Action
1func GetMembers(cur realm, boardID uint64, start, count int) []boards.User
source

GetMembers returns a list with the members of a board. To reverse iterate use a negative count.

func GetBoard

crossing Action
1func GetBoard(cur realm, id uint64) (Board, bool)
source

GetBoard returns a safe board.

func GetBoards

crossing Action
1func GetBoards(cur realm, start, count int) []Board
source

GetBoards returns a list with all boards. To reverse iterate use a negative count.

func GetComment

crossing Action
1func GetComment(cur realm, boardID, threadID, commentID uint64) (Comment, bool)
source

GetComment returns a safe thread comment.

func GetComments

crossing Action
1func GetComments(cur realm, boardID, threadID uint64, start, count int) []Comment
source

GetComments returns a list with all thread comments and replies. To reverse iterate use a negative count. Top level comments can be filtered by checking `Comment.ParentID`, replies always have a parent comment or reply, while comments have no parent.

func GetReplies

crossing Action
1func GetReplies(cur realm, boardID, threadID, commentID uint64, start, count int) []Comment
source

GetReplies returns a list with top level comment replies. To reverse iterate use a negative count.

func GetReposts

crossing Action
1func GetReposts(cur realm, boardID, threadID uint64, start, count int) []Thread
source

GetReposts returns a list with repost of a board thread. To reverse iterate use a negative count.

func GetThread

crossing Action
1func GetThread(cur realm, boardID, threadID uint64) (Thread, bool)
source

GetThread returns a safe board thread.

func GetThreads

crossing Action
1func GetThreads(cur realm, boardID uint64, start, count int) []Thread
source

GetThreads returns a list with threads of a board. To reverse iterate use a negative count.

Types 5

type Board

struct
 1type Board struct {
 2	ref *boards.Board
 3
 4	// ID is the unique identifier of the board.
 5	ID uint64
 6
 7	// Name is the current name of the board.
 8	Name string
 9
10	// Aliases contains a list of alternative names for the board.
11	Aliases []string
12
13	// Readonly indicates that the board is readonly.
14	Readonly bool
15
16	// ThreadsCount contains the number of threads within the board.
17	ThreadCount int
18
19	// MemberCount contains the number of members of the board.
20	MemberCount int
21
22	// Creator is the account address that created the board.
23	Creator address
24
25	// CreatedAt is the board's creation time as Unix time.
26	CreatedAt int64
27
28	// UpdatedAt is the board's update time as Unix time.
29	UpdatedAt int64
30}
source

Board defines a safe type for boards.

Methods on Board

func IterateMembers

method on Board
1func (b Board) IterateMembers(start, count int, fn func(boards.User) bool) bool
source

IterateMembers iterates board members. To reverse iterate use a negative count.

func IterateThreads

method on Board
1func (b Board) IterateThreads(start, count int, fn func(Thread) bool) bool
source

IterateThreads iterates board threads by creation time. To reverse iterate use a negative count.

type Comment

struct
 1type Comment struct {
 2	ref *boards.Post
 3
 4	// ID is the unique identifier of the comment.
 5	ID uint64
 6
 7	// BoardID is the board ID where comment is created.
 8	BoardID uint64
 9
10	// ThreadID contains is the ID of the thread where comment is created.
11	ThreadID uint64
12
13	// ParentID is the ID of the parent comment or reply.
14	ParentID uint64
15
16	// Body contains the comment's content.
17	Body string
18
19	// Hidden indicates that comment is hidden.
20	Hidden bool
21
22	// ReplyCount contains the number of comments replies.
23	// Count only includes top level replies, sub-replies are not included.
24	ReplyCount int
25
26	// FlagCount contains the number of flags that comment has.
27	FlagCount int
28
29	// Creator is the account address that created the comment or reply.
30	Creator address
31
32	// CreatedAt is thread's creation time as Unix time.
33	CreatedAt int64
34
35	// UpdatedAt is thread's update time as Unix time.
36	UpdatedAt int64
37}
source

Comment defines a type for threads comment/replies.

Methods on Comment

func IterateFlags

method on Comment
1func (c Comment) IterateFlags(start, count int, fn func(boards.Flag) bool) bool
source

IterateFlags iterates comment moderation flags. To reverse iterate use a negative count.

func IterateReplies

method on Comment
1func (t Comment) IterateReplies(start, count int, fn func(Comment) bool) bool
source

IterateReplies iterates comment replies (sub-comments). To reverse iterate use a negative count.

type Flag

struct
1type Flag struct {
2	// User is the user that flagged.
3	User address
4
5	// Reason is the reason for flagging.
6	Reason string
7}
source

Flag defines a type for thread and comment flags.

type Member

struct
1type Member struct {
2	Address address
3	Roles   []string
4}
source

Member defines a type for board members.

type Thread

struct
 1type Thread struct {
 2	ref *boards.Post
 3
 4	// ID is the unique identifier of the thread.
 5	ID uint64
 6
 7	// OriginalBoardID contains the board ID of the original thread when current is a repost.
 8	OriginalBoardID uint64
 9
10	// OriginalThreadID contains the ID of the original thread when current is a repost.
11	OriginalThreadID uint64
12
13	// BoardID is the board ID where thread is created.
14	BoardID uint64
15
16	// Title contains thread's title.
17	Title string
18
19	// Body contains content of the thread.
20	Body string
21
22	// Hidden indicates that thread is hidden.
23	Hidden bool
24
25	// Readonly indicates that thread is readonly.
26	Readonly bool
27
28	// CommentCount contains the number of thread comments.
29	// Count only includes top level comment, replies are not included.
30	CommentCount int
31
32	// RepostCount contains the number of times thread has been reposted.
33	RepostCount int
34
35	// FlagCount contains the number of flags that thread has.
36	FlagCount int
37
38	// Creator is the account address that created the thread.
39	Creator address
40
41	// CreatedAt is thread's creation time as Unix time.
42	CreatedAt int64
43
44	// UpdatedAt is thread's update time as unix time.
45	UpdatedAt int64
46}
source

Thread defines a type for board threads.

Methods on Thread

func IterateComments

method on Thread
1func (t Thread) IterateComments(start, count int, fn func(Comment) bool) bool
source

IterateComments iterates thread comments. To reverse iterate use a negative count.

func IterateFlags

method on Thread
1func (t Thread) IterateFlags(start, count int, fn func(boards.Flag) bool) bool
source

IterateFlags iterates thread moderation flags. To reverse iterate use a negative count.

func IterateReposts

method on Thread
1func (t Thread) IterateReposts(start, count int, fn func(boardID, repostThreadID uint64) bool) bool
source

IterateReposts iterates thread reposts. To reverse iterate use a negative count.

Imports 3

Source Files 31