beatmap ranking in API

This commit is contained in:
Howl
2016-04-27 20:03:06 +02:00
parent 32029d963e
commit 3782ed3c7c
3 changed files with 73 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ const (
PrivilegeManageAPIKeys // admin permission to manage user permission, not only self permissions. Only ever do this if you completely trust the application, because this essentially means to put the entire ripple database in the hands of a (potentially evil?) application.
PrivilegeBlog // can do pretty much anything to the blog, and the documentation.
PrivilegeAPIMeta // can do /meta API calls. basically means they can restart the API server.
PrivilegeBeatmap // rank/unrank beatmaps. also BAT when implemented
)
// Privileges is a bitwise enum of the privileges of an user's API key.
@@ -76,11 +77,16 @@ func (p Privileges) HasPrivilegeBlog() bool {
return p&PrivilegeBlog != 0
}
// HasPrivilegeAPIMeta returns whether the Blog privilege is included in the privileges.
// HasPrivilegeAPIMeta returns whether the APIMeta privilege is included in the privileges.
func (p Privileges) HasPrivilegeAPIMeta() bool {
return p&PrivilegeAPIMeta != 0
}
// HasPrivilegeBeatmap returns whether the Beatmap privilege is included in the privileges.
func (p Privileges) HasPrivilegeBeatmap() bool {
return p&PrivilegeBeatmap != 0
}
var privilegeString = [...]string{
"Read",
"ReadConfidential",
@@ -94,6 +100,7 @@ var privilegeString = [...]string{
"ManageAPIKeys",
"Blog",
"APIMeta",
"Beatmap",
}
func (p Privileges) String() string {
@@ -119,6 +126,7 @@ var privilegeMustBe = [...]int{
4,
3,
4,
4,
}
// CanOnly removes any privilege that the user has requested to have, but cannot have due to their rank.