feat(api): add space roles with delegated member removal and structure management
This commit is contained in:
1 parent
059a29a8d5
commit
1dd54243ae
12 files changed
+551
-19
No files matched your search
@@ -6,5 +6,5 @@ public static class ApiContract
|
||||
// 去掉设备名与设备清单接口。设备只是账号的属性。
|
||||
// v8: 频道强制登录,去掉未登录访客(allow_guests、/guests、终端席位);便捷分享不受影响。
|
||||
// Keep this aligned with contracts/api-contract.json and docs/openapi.yaml.
|
||||
public const string Version = "8.1.0";
|
||||
public const string Version = "8.2.0";
|
||||
}
|
||||
@@ -172,6 +172,20 @@ public sealed class WorkspaceChannelRequest
|
||||
[JsonPropertyName("name")] public required string Name { get; init; }
|
||||
[JsonPropertyName("groupId")] public string? GroupId { get; init; }
|
||||
}
|
||||
public sealed class WorkspaceRoleRequest
|
||||
{
|
||||
[JsonPropertyName("name")] public required string Name { get; init; }
|
||||
[JsonPropertyName("prefix")] public string? Prefix { get; init; }
|
||||
[JsonPropertyName("suffix")] public string? Suffix { get; init; }
|
||||
[JsonPropertyName("color")] public string? Color { get; init; }
|
||||
[JsonPropertyName("permissions")] public required List<string> Permissions { get; init; }
|
||||
}
|
||||
public sealed class WorkspaceRoleMembersRequest { [JsonPropertyName("members")] public required List<string> Members { get; init; } }
|
||||
public sealed class WorkspaceRoleCreatedBody
|
||||
{
|
||||
[JsonPropertyName("workspace")] public required WorkspaceBody Workspace { get; init; }
|
||||
[JsonPropertyName("role")] public required WorkspaceRole Role { get; init; }
|
||||
}
|
||||
public sealed class WorkspaceGroupRequest { [JsonPropertyName("groupId")] public string? GroupId { get; init; } }
|
||||
public sealed class WorkspaceFolderRequest
|
||||
{
|
||||
@@ -222,6 +236,9 @@ public sealed class WorkspaceGroupCreatedBody
|
||||
[JsonSerializable(typeof(WorkspaceNameRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceChannelRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceGroupRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceRoleRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceRoleMembersRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceRoleCreatedBody))]
|
||||
[JsonSerializable(typeof(WorkspaceFolderRequest))]
|
||||
[JsonSerializable(typeof(WorkspaceMoveRequest))]
|
||||
[JsonSerializable(typeof(GoneLogBody))]
|
||||
|
||||
@@ -44,6 +44,24 @@ public static partial class Endpoints
|
||||
});
|
||||
api.MapDelete("/spaces/{id}/groups/{groupId}", (string id, string groupId, HttpContext ctx, ChannelService svc) =>
|
||||
Json(View(svc.DeleteWorkspaceGroup(ParseId(id), RequestAuth.FromHeaders(ctx.Request, false), groupId)), ApiJson.Default.WorkspaceBody));
|
||||
api.MapPost("/spaces/{id}/roles", async (string id, HttpContext ctx, ChannelService svc, CancellationToken ct) =>
|
||||
{
|
||||
var req = await ReadJson(ctx.Request, ApiJson.Default.WorkspaceRoleRequest, ct);
|
||||
var created = svc.CreateWorkspaceRoleResult(ParseId(id), RequestAuth.FromHeaders(ctx.Request, false), req.Name, req.Prefix, req.Suffix, req.Color, req.Permissions);
|
||||
return Json(new WorkspaceRoleCreatedBody { Workspace = View(created.State), Role = created.Role }, ApiJson.Default.WorkspaceRoleCreatedBody, 201);
|
||||
});
|
||||
api.MapPatch("/spaces/{id}/roles/{roleId}", async (string id, string roleId, HttpContext ctx, ChannelService svc, CancellationToken ct) =>
|
||||
{
|
||||
var req = await ReadJson(ctx.Request, ApiJson.Default.WorkspaceRoleRequest, ct);
|
||||
return Json(View(svc.UpdateWorkspaceRole(ParseId(id), RequestAuth.FromHeaders(ctx.Request, false), roleId, req.Name, req.Prefix, req.Suffix, req.Color, req.Permissions)), ApiJson.Default.WorkspaceBody);
|
||||
});
|
||||
api.MapDelete("/spaces/{id}/roles/{roleId}", (string id, string roleId, HttpContext ctx, ChannelService svc) =>
|
||||
Json(View(svc.DeleteWorkspaceRole(ParseId(id), RequestAuth.FromHeaders(ctx.Request, false), roleId)), ApiJson.Default.WorkspaceBody));
|
||||
api.MapPut("/spaces/{id}/roles/{roleId}/members", async (string id, string roleId, HttpContext ctx, ChannelService svc, CancellationToken ct) =>
|
||||
{
|
||||
var req = await ReadJson(ctx.Request, ApiJson.Default.WorkspaceRoleMembersRequest, ct);
|
||||
return Json(View(svc.SetWorkspaceRoleMembers(ParseId(id), RequestAuth.FromHeaders(ctx.Request, false), roleId, req.Members)), ApiJson.Default.WorkspaceBody);
|
||||
});
|
||||
api.MapPost("/spaces/{id}/folders", async (string id, HttpContext ctx, ChannelService svc, CancellationToken ct) =>
|
||||
{
|
||||
var req = await ReadJson(ctx.Request, ApiJson.Default.WorkspaceFolderRequest, ct);
|
||||
|
||||
Reference in new issue
Block a user