Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test("open channels accept adds from anyone, member or not", () => {
);
});

test("private channels accept adds from every active member role", () => {
for (const selfRole of ["owner", "admin", "member", "bot", "guest"]) {
test("private channels accept adds from every active role that can post", () => {
for (const selfRole of ["owner", "admin", "member", "bot"]) {
assert.equal(
canAddChannelMembers({
channelType: "stream",
Expand All @@ -46,6 +46,20 @@ test("private channels accept adds from every active member role", () => {
);
});

test("guests never add anyone, as the relay's decide_member_put refuses", () => {
for (const visibility of ["open", "private"]) {
assert.equal(
canAddChannelMembers({
channelType: "stream",
visibility,
selfRole: "guest",
}),
false,
`a guest must not be offered adds (${visibility} channel)`,
);
}
});

test("DMs never accept adds, even from an owner", () => {
assert.equal(
canAddChannelMembers({
Expand Down
14 changes: 8 additions & 6 deletions desktop/src/features/channels/lib/channelMemberAdmission.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/**
* Client mirror of the relay's kind:9000 authority for adding *another*
* identity to a channel (`validate_admin_event` + `buzz_db::channel::add_member`):
* identity to a channel (`buzz_core::channel::decide_member_put`):
*
* - DMs: nobody — membership is fixed at creation.
* - Open channels: anyone, member or not.
* - Private channels: any active member. The relay separately reserves elevated
* role grants and active-role changes for owners/admins.
* - Guests: never. A guest can read and leave but not write, and adding
* people is a write.
* - Open channels: anyone else, member or not.
* - Private channels: any other active member. The relay separately reserves
* elevated role grants and active-role changes for owners/admins.
*
* Unknown visibility fails closed — the relay is the authority and a hidden
* button is cheaper than an opaque rejection.
Expand All @@ -19,7 +21,7 @@ export function canAddChannelMembers({
visibility?: string | null;
selfRole?: string | null;
}): boolean {
if (channelType === "dm") {
if (channelType === "dm" || selfRole === "guest") {
return false;
}

Expand All @@ -36,4 +38,4 @@ export function canAddChannelMembers({

/** Explains a denied add so the user isn't left guessing at a missing button. */
export const PRIVATE_CHANNEL_ADD_DENIED_MESSAGE =
"Only channel members can add people to a private channel.";
"Only channel members who can post can add people to a private channel.";