Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

board.gno

2.47 Kb · 106 lines
  1package boards
  2
  3import "time"
  4
  5// Board defines a type for boards.
  6type Board struct {
  7	// ID is the unique identifier of the board.
  8	ID ID
  9
 10	// Name is the current name of the board.
 11	Name string
 12
 13	// Aliases contains a list of alternative names for the board.
 14	Aliases []string
 15
 16	// Readonly indicates that the board is readonly.
 17	Readonly bool
 18
 19	// Threads contains board threads.
 20	Threads PostStorage
 21
 22	// ThreadsSequence generates sequential ID for new threads.
 23	ThreadsSequence IdentifierGenerator
 24
 25	// Permissions enables support for permissioned boards.
 26	// This type of boards allows managing members with roles and permissions.
 27	// It also enables the implementation of permissioned execution of board related features.
 28	Permissions Permissions
 29
 30	// Creator is the account address that created the board.
 31	Creator address
 32
 33	// Meta allows storing board metadata.
 34	Meta any
 35
 36	// CreatedAt is the board's creation time.
 37	CreatedAt time.Time
 38
 39	// UpdatedAt is the board's update time.
 40	UpdatedAt time.Time
 41}
 42
 43// New creates a new basic non permissioned board.
 44func New(id ID) *Board {
 45	return &Board{
 46		ID:              id,
 47		Threads:         NewPostStorage(),
 48		ThreadsSequence: NewIdentifierGenerator(),
 49		CreatedAt:       time.Now(),
 50	}
 51}
 52
 53// SetID sets board ID value.
 54func (board *Board) SetID(v ID) {
 55	board.ID = v
 56}
 57
 58// SetName sets name value.
 59func (board *Board) SetName(v string) {
 60	board.Name = v
 61}
 62
 63// SetAliases sets board name aliases.
 64func (board *Board) SetAliases(v []string) {
 65	board.Aliases = v
 66}
 67
 68// SetReadonly sets readonly value.
 69func (board *Board) SetReadonly(v bool) {
 70	board.Readonly = v
 71}
 72
 73// SetThreadStorage sets the storage where board threads are stored.
 74func (board *Board) SetThreadStorage(v PostStorage) {
 75	board.Threads = v
 76}
 77
 78// SetThreadsSequence sets the sequential thread ID generator.
 79func (board *Board) SetThreadsSequence(v IdentifierGenerator) {
 80	board.ThreadsSequence = v
 81}
 82
 83// SetPermissions sets permissions value.
 84func (board *Board) SetPermissions(v Permissions) {
 85	board.Permissions = v
 86}
 87
 88// SetCreator sets the address of the account that created the board.
 89func (board *Board) SetCreator(v address) {
 90	board.Creator = v
 91}
 92
 93// SetCreatedAt sets the time when board was created.
 94func (board *Board) SetCreatedAt(v time.Time) {
 95	board.CreatedAt = v
 96}
 97
 98// SetUpdatedAt sets the time when a board value was updated.
 99func (board *Board) SetUpdatedAt(v time.Time) {
100	board.UpdatedAt = v
101}
102
103// SetMeta sets board metadata.
104func (board *Board) SetMeta(v any) {
105	board.Meta = v
106}