From b7733e812fadd6007976d262bd1d793572a36ba7 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 29 Aug 2026 11:15:54 +0200 Subject: feat: node workflow redesign — wizard auto-config, reset, MusicBrainz contact MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wizard (Electron): - Auto-provisions node config (hub URL + username) from logged-in user - node:start handles both cold start and restart of misconfigured daemon - Waits for daemon to reach 'running', auto-links node key on hub - probeNode accepts intermediate states for wizard progress feedback Reset (meshbay-node reset): - Unlinks node key from hub (DELETE /me/node_key, best-effort) - Stops and disables daemon (systemctl --user disable --now) - Erases ~/.config/meshbay, ~/.local/share/meshbay, ~/.local/state/meshbay MusicBrainz contact: - Resolved from owner's hub email instead of per-node roster config - Removed musicbrainz_contact UI and WebRTC handshake field - Removed set_musicbrainz_contact/musicbrainz_contact from roster Node pairing: - Added operator pairing banner on NodePage - Added operator_paired flag to list_groups Co-Authored-By: Claude Opus 4.6 --- .../meshbay-node/src/meshbay_node/musicbrainz.py | 33 +++++----------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'packages/meshbay-node/src/meshbay_node/musicbrainz.py') diff --git a/packages/meshbay-node/src/meshbay_node/musicbrainz.py b/packages/meshbay-node/src/meshbay_node/musicbrainz.py index 6ca1cf4..59f3778 100644 --- a/packages/meshbay-node/src/meshbay_node/musicbrainz.py +++ b/packages/meshbay-node/src/meshbay_node/musicbrainz.py @@ -17,40 +17,25 @@ account, only: enforced by convention (and by MusicBrainz throttling abusive clients), not a token bucket handed out by the server. -Contact resolution order (docs/musicbay.md §3.2), same shape as tmdb.py's -token resolution: - - 1. an operator-supplied contact string (roster.py group_settings, - group_id="") - 2. the MESHBAY_MUSICBRAINZ_CONTACT_DEFAULT environment variable - 3. none — MusicBrainz lookups are inert (callers get an empty result, - never an exception). Deliberately **not** falling back to a generic - User-Agent: sending an unidentified client to a service that polices - its User-Agent policy risks the node's IP being blocked, which is a - worse failure than "no music metadata yet". - -No literal contact value lives in this file, for the same reason tmdb.py -carries no literal token — see docs/musicbay.md §3.2 on why a personal -address must never land in source control. +Contact resolution: the node owner's hub account email, fetched once at +login via ``GET /v1/users/me`` and passed to this client at construction. +If the owner has no email on file, lookups are inert (callers get an +empty result, never an exception). """ import asyncio import difflib import logging -import os import re import time import httpx -from meshbay_node.roster import Roster - log = logging.getLogger(__name__) _BASE_URL = "https://musicbrainz.org/ws/2/" _COVER_ART_BASE = "https://coverartarchive.org/release/" _TIMEOUT = 10.0 -_DEFAULT_CONTACT_ENV = "MESHBAY_MUSICBRAINZ_CONTACT_DEFAULT" _APP_NAME = "MeshBay-Node" # MusicBrainz's own stated courtesy limit for unauthenticated use. Enforced @@ -112,9 +97,9 @@ def _best_match_release(artist: str, album: str, results: list[dict]) -> tuple[d class MusicBrainzClient: """One instance per node, holding the resolved contact and an httpx client.""" - def __init__(self, roster: Roster | None = None, + def __init__(self, owner_email: str = "", transport: httpx.AsyncBaseTransport | None = None): - self._roster = roster + self._owner_email = owner_email # `transport` is a test-only seam (httpx.MockTransport) — production # callers never pass it. self._client = httpx.AsyncClient(timeout=_TIMEOUT, transport=transport) @@ -125,11 +110,7 @@ class MusicBrainzClient: await self._client.aclose() async def _resolve_contact(self) -> str | None: - if self._roster is not None: - contact = await self._roster.musicbrainz_contact() - else: - contact = None - return contact or os.environ.get(_DEFAULT_CONTACT_ENV) or None + return self._owner_email or None async def _pace(self) -> None: """Serializes every call through this client to >= _MIN_INTERVAL_SECS apart.""" -- cgit v1.2.3