Skip to content

fix(cli): send forum roots and replies as forum kinds - #5925

Open
Chessing234 wants to merge 6 commits into
block:mainfrom
Chessing234:fix/cli-forum-default-kind
Open

fix(cli): send forum roots and replies as forum kinds#5925
Chessing234 wants to merge 6 commits into
block:mainfrom
Chessing234:fix/cli-forum-default-kind

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Fixes #5075.

messages send published kind:9 whenever --kind was omitted. Desktop's forum surface lists kind:45001 topics and their kind:45003 comments, so a default send into a forum channel is accepted by the relay, returns an event id, and never appears where people read that channel. It stays reachable by notification or deep link, which is what makes it look like a delivery problem rather than a kind problem.

The send now resolves the channel's type from its kind:39000 discovery event (t tag, written by emit_group_discovery_events) and picks the kind that channel's canonical surface shows: 45001 for a forum root, 45003 for a forum reply, 9 everywhere else. An explicit --kind is honoured unchanged, and --broadcast stays on kind:9 — broadcast is a stream concept, and a flag should not silently redirect the event kind. A channel with no discovery event keeps the stream default rather than failing the send.

Acceptance criteria from the issue: root send to a forum publishes 45001 ✅, stream sends still publish 9 ✅, explicit override unchanged ✅, regression tests for both defaults ✅, --kind help now names the kinds ✅. The one I cannot tick myself is "appears as a topic in Desktop's forum surface" — I have no forum channel to send into; the claim rests on Desktop listing 45001, which is the issue's own evidence.

Verified locally: cargo test -p buzz-cli --lib (355 passed, 6 new), clippy and fmt clean. The extra kind:39000 read costs one query per send that omits --kind; sends already query channel members for mention resolution on the same path.

`messages send` published kind:9 whenever `--kind` was omitted. Desktop's
forum surface lists kind:45001 topics and their kind:45003 comments, so a
default send into a forum channel was accepted by the relay, returned an
event id, and then never appeared where people read that channel. The
event stayed reachable by deep link or notification, which is what makes
the failure hard to spot.

Resolve the channel's type from its kind:39000 discovery event and pick the
kind that channel's canonical surface shows. An explicit `--kind` is still
honoured unchanged, and `--broadcast` stays on kind:9 — it is a stream-only
concept, so a flag should not silently redirect the event kind.

Signed-off-by: Taksh <takshkothari09@gmail.com>
Pins the `t`-tag read, the forum root/reply split, the stream and DM cases,
and that --broadcast is left on kind:9.

Signed-off-by: Taksh <takshkothari09@gmail.com>
"channel default" was accurate but unhelpful; name the kinds so a caller
can tell whether they need --kind at all.

Signed-off-by: Taksh <takshkothari09@gmail.com>
@Chessing234
Chessing234 requested a review from a team as a code owner August 15, 2026 04:24

@themiguelamador themiguelamador left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The forum default still has an invisible-success path: --broadcast forces an implicit forum send back to kind 9. That event is accepted but omitted from Desktop's forum surface—the same user-visible failure this PR fixes. The PR describes broadcast as stream-only, so a forum invocation should fail clearly rather than silently publish hidden content. Explicit forum kinds combined with --broadcast also ignored the flag.

I consolidated selection into a tested resolve_message_kind contract. Ordinary forum roots/replies remain 45001/45003; forum broadcast is rejected; explicit forum kinds reject the ignored broadcast flag; and explicit --kind 9 --broadcast remains the expert opt-out. Selection now runs before attachment upload, preventing invalid broadcast combinations from leaving orphaned media. CLI help identifies broadcast as stream-only.

Fix: Complear/buzz@c56c71995 (review/pr-5925-fix)

Verified: full buzz-cli unit suite (357 passed); cargo clippy -p buzz-cli --all-targets -- -D warnings; rustfmt; git diff --check.

@Chessing234

Copy link
Copy Markdown
Contributor Author

Thanks — all of it addressed, in af89a28, b8b7027 and d281d5f. Complear/buzz 404s for me (gh api repos/Complear/buzz and fetching c56c71995 both fail), so this is written from your description.

default_message_kind is gone; selection is now one contract, resolve_message_kind(explicit, channel_type, is_reply, broadcast) -> Result<u16, CliError>, with the whole policy in its doc comment:

  • implicit forum + --broadcast → rejected. You are right that the fallback to kind 9 was the same invisible success the PR is fixing, reachable by adding a flag. The error names the opt-out.
  • explicit --kind 45001/45003 + --broadcast → rejected. Confirmed the flag was being dropped: build_forum_post and build_forum_comment take no broadcast argument, so there was nothing to honour.
  • --kind 9 --broadcast → still allowed, in a forum channel too, since the caller named the kind.
  • implicit forum root/reply → 45001/45003 unchanged; everything else → 9.
  • the unsupported---kind error moved in here too, so every kind decision has one home.

Before the upload. Selection now runs before the attachment loop, so a rejected combination cannot leave media stored with no event referencing it. That also covers --kind 7 --file …, which previously uploaded and then rejected the kind. The reply flag reads p.reply_to.is_some() rather than thread_ref.is_some() — equivalent (thread_ref is Some exactly when reply_to is), and it means the kind is settled without waiting on the parent-event round-trip.

Help. --broadcast now reads "Also publish to the Nostr network. Stream-only (kind 9): rejected in a forum channel and with --kind 45001/45003". Verified in the generated buzz messages send --help.

Verified on the pushed head: cargo test -p buzz-cli --lib 360 passed (was 355; 7 new cases covering both rejections, the --kind 9 --broadcast opt-out, broadcast on a stream channel, and the unsupported kind), cargo clippy -p buzz-cli --all-targets -- -D warnings clean, cargo fmt --all -- --check clean, git diff --check clean. Still unverified on my side: the Desktop forum surface itself, since I have no forum channel to send into.

The review points out two invisible-success paths the first commit left
open, and both come back to --broadcast being a stream-only concept:

- An implicit forum send with --broadcast fell back to kind 9. That event is
  accepted by the relay and never listed on the forum surface — the exact
  failure this PR exists to fix, reachable by adding a flag.
- An explicit --kind 45001/45003 with --broadcast dropped the flag silently:
  build_forum_post and build_forum_comment take no broadcast argument.

Selection is now one tested contract, resolve_message_kind, which rejects
both rather than half-applying them. --kind 9 --broadcast stays as the
explicit opt-out, in a forum channel too: the caller named the kind.

The unsupported --kind error moves into the same function, so every kind
decision has one home.

Signed-off-by: Taksh <takshkothari09@gmail.com>
The review asks that CLI help identify broadcast as stream-only, now that a
forum invocation is an error rather than a silent kind 9.

Signed-off-by: Taksh <takshkothari09@gmail.com>
The review asks that selection run before attachment upload, so an invalid
broadcast combination cannot leave orphaned media on the relay. Every
rejection in resolve_message_kind is a usage error the caller retries, and
the upload loop ran first, so the files were already stored with no event
referencing them.

The reply flag is read from p.reply_to.is_some() rather than
thread_ref.is_some(); thread_ref is Some exactly when reply_to is, and it is
resolved by a relay round-trip that no longer needs to happen first.

Signed-off-by: Taksh <takshkothari09@gmail.com>
@Chessing234
Chessing234 force-pushed the fix/cli-forum-default-kind branch from d281d5f to da2a99d Compare August 16, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz messages send defaults to an invisible stream event for forum roots

2 participants