fix(relay): let DM participants rename their own DM (#4739) - #5243
Open
bonpiedlaroute wants to merge 1 commit into
Open
bonpiedlaroute wants to merge 1 commit into
bonpiedlaroute wants to merge 1 commit into
Conversation
Signed-off-by: bonpiedlaroute <noel.tchidjo@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4739.
Summary
Renaming a group DM is impossible for everyone, community owner included. The
kind:9002 privileged-tag gate (
side_effects.rs:595) requiresowneroradmin,but
buzz-db/src/dm.rsenrols every DM participant with a hardcoded role —VALUES ($1, $2, $3, 'member', $4), commented as an invariant ("alwaysmemberfor DMs") — and a DM never carries an owner-role agent for the NIP-OA fallback
either. So this isn't a policy against renaming; it's an authorization predicate
no principal can satisfy.
Change
The handler already has the tier this needs, documented two lines above the check:
"topic/purpose allow any member", implemented with
state.is_member_cached.namenow rides that tier for
channel_type == "dm"only, behindis_dm_rename_only.Every other privileged tag stays locked — a rename carrying
about/archived/visibility/ttlfalls back to the owner/admin gate.No new query:
validate_admin_eventalready loads the channel record for thearchived-channel check, so
channel.channel_typewas in scope.Why the rename actually lands
The gate is only half the path, so I traced the rest rather than assuming it:
is_memberfilters onremoved_at IS NULLonly, no rolepredicate (
buzz-db/src/channel.rs:654), so a plainmemberpasses;handle_edit_metadata'snamearm callsupdate_channel(name: Some(..))with no channel-type condition(
side_effects.rs:1445);emit_group_discovery_eventspushes["name", &channel.name]unconditionally (
side_effects.rs:1057); the DM branch only addshiddenandptags (:1073). It runs at the end ofhandle_edit_metadata(:1649).Tests
Four unit tests on the predicate, no infrastructure needed. The one that matters
for review is
dm_edit_touching_another_privileged_tag_stays_role_gated: itasserts a rename cannot smuggle
visibilityorarchivedpast the gate, for eachof the four locked tags.
cargo fmt --check,cargo clippy -p buzz-relay --all-targets -- -D warnings,just test-unitandjust desktop-tauri-testare clean.Not included
Desktop excludes DMs from channel management entirely
(
ChannelManagementSheet.tsx:142), so the UI unlock is a separate PR — happy tofollow up once the relay side lands.
The rule is isolated in one small pure predicate, so if you'd rather scope it
differently — creator-only, or a community-owner bypass — that's a one-function
change rather than a rework.