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

config.gno

0.93 Kb · 51 lines
 1package user
 2
 3import (
 4	"chain"
 5	"strconv"
 6
 7	"gno.land/p/akkadia/beta/accesscontrol"
 8	"gno.land/r/akkadia/beta/admin"
 9)
10
11const (
12	SetListLimitEvent = "SetListLimit"
13	SetFrozenEvent    = "SetFrozen"
14)
15
16var (
17	listLimit int = 100 // Max items per list query
18	isFrozen      = true
19)
20
21func SetListLimit(cur realm, limit int) {
22	accesscontrol.AssertIsAdmin(0, cur, admin.IsAdmin)
23	if limit < 1 {
24		panic("limit must be at least 1")
25	}
26
27	oldLimit := listLimit
28	listLimit = limit
29
30	chain.Emit(
31		SetListLimitEvent,
32		"oldLimit", strconv.Itoa(oldLimit),
33		"newLimit", strconv.Itoa(limit),
34	)
35}
36
37func GetListLimit() int {
38	return listLimit
39}
40
41// SetFrozen controls direct user creation and deletion only.
42func SetFrozen(cur realm, frozen bool) {
43	accesscontrol.AssertIsAdmin(0, cur, admin.IsAdmin)
44	oldFrozen := isFrozen
45	isFrozen = frozen
46	chain.Emit(
47		SetFrozenEvent,
48		"oldFrozen", strconv.FormatBool(oldFrozen),
49		"newFrozen", strconv.FormatBool(frozen),
50	)
51}