forked from osuripple/api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_privileges.go
68 lines (63 loc) · 1.47 KB
/
user_privileges.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package common
import "strings"
// user/admin privileges
const (
UserPrivilegePublic UserPrivileges = 1 << iota
UserPrivilegeNormal
UserPrivilegeDonor
AdminPrivilegeAccessRAP
AdminPrivilegeManageUsers
AdminPrivilegeBanUsers
AdminPrivilegeSilenceUsers
AdminPrivilegeWipeUsers
AdminPrivilegeManageBeatmap
AdminPrivilegeManageServer
AdminPrivilegeManageSetting
AdminPrivilegeManageBetaKey
AdminPrivilegeManageReport
AdminPrivilegeManageDocs
AdminPrivilegeManageBadges
AdminPrivilegeViewRAPLogs
AdminPrivilegeManagePrivilege
AdminPrivilegeSendAlerts
AdminPrivilegeChatMod
AdminPrivilegeKickUsers
UserPrivilegePendingVerification
UserPrivilegeTournamentStaff
AdminPrivilegeCaker
)
// UserPrivileges represents a bitwise enum of the privileges of an user.
type UserPrivileges uint64
var userPrivilegeString = [...]string{
"UserPublic",
"UserNormal",
"UserDonor",
"AdminAccessRAP",
"AdminManageUsers",
"AdminBanUsers",
"AdminSilenceUsers",
"AdminWipeUsers",
"AdminManageBeatmap",
"AdminManageServer",
"AdminManageSetting",
"AdminManageBetaKey",
"AdminManageReport",
"AdminManageDocs",
"AdminManageBadges",
"AdminViewRAPLogs",
"AdminManagePrivilege",
"AdminSendAlerts",
"AdminChatMod",
"AdminKickUsers",
"UserPendingVerification",
"UserTournamentStaff",
}
func (p UserPrivileges) String() string {
var pvs []string
for i, v := range userPrivilegeString {
if uint64(p)&uint64(1<<uint(i)) != 0 {
pvs = append(pvs, v)
}
}
return strings.Join(pvs, ", ")
}