Add role hoisting / ranking.

This commit is contained in:
Paul
2021-08-11 14:16:16 +01:00
parent e9c638b126
commit 0602c5936c
4 changed files with 140 additions and 32 deletions
+118 -19
View File
@@ -3,7 +3,7 @@
"openapi": "3.0.0",
"info": {
"title": "Revolt API",
"version": "0.5.1-alpha.22",
"version": "0.5.1-alpha.24",
"description": "User-first privacy focused chat platform built with modern web technologies.\n\n# Authentication\n\nCurrently all relevant requests are authenticated by the use of two headers which identify a session.\n\n<SecurityDefinitions />",
"termsOfService": "https://revolt.chat/terms",
"contact": {
@@ -8766,25 +8766,50 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
"allOf": [
{
"$ref": "#/definitions/RoleInformation"
},
"colour": {
"description": "Valid HTML colour\n\nWarning: This is untrusted input, do not simply insert this anywhere.\n\n**Example usage:**\n```js\ndocument.body.style.color = role.colour;\n```",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"remove": {
"description": "Field to remove from role object",
"type": "string",
"enum": [
"Colour"
{
"type": "object",
"properties": {
"remove": {
"description": "Field to remove from role object",
"type": "string",
"enum": [
"Colour"
]
}
}
}
],
"definitions": {
"RoleInformation": {
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"colour": {
"description": "Valid HTML colour\n\nWarning: This is untrusted input, do not simply insert this anywhere.\n\n**Example usage:**\n```js\ndocument.body.style.color = role.colour;\n```",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"hoist": {
"description": "Whether to display this role separately on the members list",
"type": "boolean"
},
"rank": {
"description": "Role ranking\n\nA role with a smaller number will have permissions over roles with larger numbers.",
"type": "number"
}
},
"required": [
"name"
]
}
}
@@ -9719,6 +9744,9 @@
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"permissions": {
@@ -9740,6 +9768,14 @@
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"hoist": {
"description": "Whether to display this role separately on the members list",
"type": "boolean"
},
"rank": {
"description": "Role ranking\n\nA role with a smaller number will have permissions over roles with larger numbers.",
"type": "number"
}
},
"required": [
@@ -14682,6 +14718,9 @@
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"permissions": {
@@ -14703,6 +14742,14 @@
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"hoist": {
"description": "Whether to display this role separately on the members list",
"type": "boolean"
},
"rank": {
"description": "Role ranking\n\nA role with a smaller number will have permissions over roles with larger numbers.",
"type": "number"
}
},
"required": [
@@ -14723,6 +14770,47 @@
}
}
},
"RoleInformation": {
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"colour": {
"description": "Valid HTML colour\n\nWarning: This is untrusted input, do not simply insert this anywhere.\n\n**Example usage:**\n```js\ndocument.body.style.color = role.colour;\n```",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"hoist": {
"description": "Whether to display this role separately on the members list",
"type": "boolean"
},
"rank": {
"description": "Role ranking\n\nA role with a smaller number will have permissions over roles with larger numbers.",
"type": "number"
}
},
"required": [
"name"
],
"definitions": {
"AttachmentTag": {
"description": "Attachment tag",
"enum": [
"attachments",
"avatars",
"backgrounds",
"banners",
"icons"
],
"type": "string"
}
}
},
"Category": {
"type": "object",
"properties": {
@@ -14893,6 +14981,9 @@
"type": "object",
"properties": {
"name": {
"description": "Role name",
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"permissions": {
@@ -14914,6 +15005,14 @@
"minLength": 1,
"maxLength": 32,
"type": "string"
},
"hoist": {
"description": "Whether to display this role separately on the members list",
"type": "boolean"
},
"rank": {
"description": "Role ranking\n\nA role with a smaller number will have permissions over roles with larger numbers.",
"type": "number"
}
},
"required": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt-api",
"version": "0.5.1-alpha.22",
"version": "0.5.1-alpha.24",
"description": "Revolt API typings",
"main": "dist/index.js",
"type": "module",
+2 -11
View File
@@ -430,18 +430,9 @@ resource('/servers/:server/roles/:role', {
{
...roleParams,
...await body("Requested changes to role object.", schema`
import type { PermissionTuple, Colour } from './Servers';
interface ${'EditRole'} {
/**
* Role name
* @minLength 1
* @maxLength 32
**/
name?: string;
colour?: Colour;
import type { RoleInformation, Colour } from './Servers';
type ${'EditRole'} = RoleInformation & {
/**
* Field to remove from role object
*/
+19 -1
View File
@@ -30,7 +30,6 @@ export type PermissionTuple = [
number
]
/**
* Valid HTML colour
*
@@ -47,13 +46,32 @@ export type PermissionTuple = [
export type Colour = string;
export type Role = {
/**
* Role name
* @minLength 1
* @maxLength 32
**/
name: string
permissions: PermissionTuple
colour?: Colour
/**
* Whether to display this role separately on the members list
*/
hoist?: boolean
/**
* Role ranking
*
* A role with a smaller number will have permissions over roles with larger numbers.
*/
rank?: number
}
export type RoleInformation = Pick<Role, 'name' | 'colour' | 'hoist' | 'rank'>
export type Category = {
id: Id