Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
Let only a room's owner or an admin change its access in the Gateway
Abel Dantas55a20f4dca6a
diff --git a/gateway/src/pages/rooms/RoomDetailPage.tsx b/gateway/src/pages/rooms/RoomDetailPage.tsxindex 5ac673527..86689bfd4 100644--- a/gateway/src/pages/rooms/RoomDetailPage.tsx+++ b/gateway/src/pages/rooms/RoomDetailPage.tsx@@ -98,9 +98,11 @@ export default function RoomDetailPage() {(user.id === room.owner_id ||canAdminTenant ||room.write_visibility === "public");- // Delete is stricter — owner or admin only, never via public write.- const canDelete =+ // Delete and access changes are stricter: owner or admin only, never via+ // public write (the server's `require_manage` / `delete` checks).+ const canManage =!!user && (user.id === room.owner_id || canAdminTenant);+ const canDelete = canManage;return (<Box>@@ -135,6 +137,7 @@ export default function RoomDetailPage() {<EditableFieldsSectionroom={room}canWrite={canWrite}+ canManage={canManage}onSaved={refetch}/><Divider />@@ -596,13 +599,18 @@ function RoleRow({// ── Editable fields ─────────────────────────────────────────────────────────-function EditableFieldsSection({+// Exported for its test.+export function EditableFieldsSection({room,canWrite,+ canManage,onSaved,}: {room: RoomDetail;canWrite: boolean;+ /** Owner or admin. A publicly writable room lets anyone edit its settings,+ * but only these people may change who can see and write to it. */+ canManage: boolean;onSaved: () => void;}) {const [name, setName] = useState(room.name);@@ -637,7 +645,11 @@ function EditableFieldsSection({!isBridged && description !== room.description ? description : undefined,instructions:instructions !== (room.instructions ?? "") ? instructions : undefined,- ...(access !== toAccessLevel(room) ? fromAccessLevel(access) : {}),+ // The server refuses the whole update if it carries a visibility+ // change from someone who doesn't manage the room.+ ...(canManage && access !== toAccessLevel(room)+ ? fromAccessLevel(access)+ : {}),});onSaved();} catch (err) {@@ -645,7 +657,7 @@ function EditableFieldsSection({} finally {setSaving(false);}- }, [room, name, description, instructions, access, isBridged, onSaved]);+ }, [room, name, description, instructions, access, isBridged, canManage, onSaved]);return (<Stack spacing={2}>@@ -691,7 +703,14 @@ function EditableFieldsSection({<AccessSelectvalue={access}onChange={setAccess}- disabled={!canWrite || saving}+ disabled={!canManage || saving}+ helpers={+ canManage+ ? undefined+ : {+ [access]: "Only the room's owner and admins can change who can see and write to it.",+ }+ }sx={{ maxWidth: 360 }}/><Box>diff --git a/gateway/src/pages/rooms/roomSettings.test.tsx b/gateway/src/pages/rooms/roomSettings.test.tsxnew file mode 100644index 000000000..24dae7f01--- /dev/null+++ b/gateway/src/pages/rooms/roomSettings.test.tsx@@ -0,0 +1,75 @@+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { RoomDetail } from "../../data/api";+import * as api from "../../data/api";+import { EditableFieldsSection } from "./RoomDetailPage";++// A publicly writable room lets anyone edit its settings, but the server only+// lets the owner or an admin change its access; a save carrying an access+// change from anyone else is refused whole.++vi.mock("../../data/api", async (importOriginal) => {+ const actual = await importOriginal<typeof import("../../data/api")>();+ return { ...actual, updateRoom: vi.fn() };+});++const room = {+ id: "r1",+ name: "lounge",+ description: "",+ instructions: "",+ read_visibility: "public",+ write_visibility: "public",+} as RoomDetail;++beforeEach(() => {+ vi.mocked(api.updateRoom).mockResolvedValue(room);+});++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});++function renderSettings(canManage: boolean) {+ render(+ <EditableFieldsSection+ room={room}+ canWrite={true}+ canManage={canManage}+ onSaved={vi.fn()}+ />,+ );+}++describe("room settings", () => {+ it("let a writer edit settings but not change access", async () => {+ renderSettings(false);++ expect(+ screen.getByRole("combobox", { name: "Access" }).getAttribute("aria-disabled"),+ ).toBe("true");+ expect(+ screen.getByText(/Only the room's owner and admins can change who can see/),+ ).toBeTruthy();++ fireEvent.change(screen.getByRole("textbox", { name: "Name" }), {+ target: { value: "lobby" },+ });+ fireEvent.click(screen.getByRole("button", { name: "Save" }));++ await waitFor(() => expect(api.updateRoom).toHaveBeenCalledTimes(1));+ const body = vi.mocked(api.updateRoom).mock.calls[0][1];+ expect(body.name).toBe("lobby");+ expect(body).not.toHaveProperty("read_visibility");+ expect(body).not.toHaveProperty("write_visibility");+ });++ it("let the owner or an admin change access", () => {+ renderSettings(true);++ expect(+ screen.getByRole("combobox", { name: "Access" }).getAttribute("aria-disabled"),+ ).toBeNull();+ });+});