market: self-heal orphan stalls — re-publish kind-30017 when user has merchant but no stall on relay #38

Closed
opened 2026-05-03 08:02:29 +00:00 by padreug · 0 comments
Owner

Summary

Stopgap for the upstream bug tracked in aiolabs/lnbits#<TBD>_create_default_merchant writes the merchant + stall to nostrmarket's internal SQLite but never publishes the kind-30017 stall event to relays. Until that's fixed and rolled out, our webapp can self-heal by republishing the missing stall on behalf of any logged-in user it detects in this state.

Why we need our own fix

  • LNbits fix only helps future signups. Existing orphaned merchants stay orphaned until they manually go to nostrmarket UI and resave their stall.
  • The webapp can republish silently and transparently with no user friction.
  • It also handles the rarer case of a stall event that was once published but later deleted/pruned from the relay.

Acceptance criteria

When a logged-in user lands on /market/dashboard (or any merchant view), do this once per session:

  1. Query the relay for kind-30017 events authored by auth.currentUser.value.pubkey.
  2. Hit LNbits GET /nostrmarket/api/v1/stall to list this user's stalls.
  3. For each stall in (2) whose id isn't represented in (1), call LNbits PUT /nostrmarket/api/v1/stall/{stallId} with the existing stall data — this triggers sign_and_send_to_nostr server-side and republishes.
  4. Toast nothing. Log a single console.info so we can see it in DevTools.

Suggested implementation

  • New composable useMarketStallSelfHeal() under src/modules/market/composables/
  • Called from MarketDashboard.vue onMounted (after the existing fully-authed check we just added)
  • Use injectService(SERVICE_TOKENS.RELAY_HUB) for the relay query and injectService(SERVICE_TOKENS.NOSTRMARKET_API) for the LNbits round-trips
  • Cache the "checked-this-session" flag in sessionStorage so we don't re-run on every dashboard mount

Out of scope

  • Republishing missing product events. Products that point at a stall that is on the relay but with the wrong id are out of scope — that's a different category of bug.
  • Backfilling orphan products in browse-all mode (issue TBD if we want to filter or relabel them).

Companion

Upstream LNbits issue: aiolabs/lnbits#<TBD>_create_default_merchant: missing kind-30017 stall publish to relays. Both should be tracked together.

## Summary Stopgap for the upstream bug tracked in `aiolabs/lnbits#<TBD>` — `_create_default_merchant` writes the merchant + stall to nostrmarket's internal SQLite but never publishes the kind-30017 stall event to relays. Until that's fixed and rolled out, our webapp can self-heal by republishing the missing stall on behalf of any logged-in user it detects in this state. ## Why we need our own fix - LNbits fix only helps **future** signups. Existing orphaned merchants stay orphaned until they manually go to nostrmarket UI and resave their stall. - The webapp can republish silently and transparently with no user friction. - It also handles the rarer case of a stall event that was once published but later deleted/pruned from the relay. ## Acceptance criteria When a logged-in user lands on `/market/dashboard` (or any merchant view), do this once per session: 1. Query the relay for kind-30017 events authored by `auth.currentUser.value.pubkey`. 2. Hit LNbits `GET /nostrmarket/api/v1/stall` to list this user's stalls. 3. For each stall in (2) whose id isn't represented in (1), call LNbits `PUT /nostrmarket/api/v1/stall/{stallId}` with the existing stall data — this triggers `sign_and_send_to_nostr` server-side and republishes. 4. Toast nothing. Log a single `console.info` so we can see it in DevTools. ## Suggested implementation - New composable `useMarketStallSelfHeal()` under `src/modules/market/composables/` - Called from `MarketDashboard.vue` `onMounted` (after the existing fully-authed check we just added) - Use `injectService(SERVICE_TOKENS.RELAY_HUB)` for the relay query and `injectService(SERVICE_TOKENS.NOSTRMARKET_API)` for the LNbits round-trips - Cache the "checked-this-session" flag in `sessionStorage` so we don't re-run on every dashboard mount ## Out of scope - Republishing missing **product** events. Products that point at a stall that *is* on the relay but with the wrong id are out of scope — that's a different category of bug. - Backfilling orphan products in browse-all mode (issue TBD if we want to filter or relabel them). ## Companion Upstream LNbits issue: `aiolabs/lnbits#<TBD>` — `_create_default_merchant: missing kind-30017 stall publish to relays`. Both should be tracked together.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/webapp#38
No description provided.