feat: per-operator settings — house rules + card acceptance (multi-tenant)
Chatelet is multi-tenant: any LNbits user can host rooms. What an operator decides for all their rooms now lives in chatelet.operator_settings, keyed by user id and created lazily (m003, which also indexes bookings by guest): check-in/out times, cancellation policy, and accept_fiat. Guests see it: the public room view (both doors) gains house_rules and payment_methods, and the kind:30402 listing carries payment_methods, checkin_time and checkout_time tags so a generic Nostr client can render the right pay buttons and rules without our RPC. The check-in DM reads the room owner's rules instead of the instance row. Card is offered only when the operator opted in, the room is fiat-priced, and LNbits core has a fiat provider for that user — resolved through settings.get_fiat_providers_for_user(owner), the one seam lnbits#67's per-user Stripe credentials will plug into; chatelet never sees creds. Operator endpoints: GET/PUT /api/v1/operator (admin key → wallet user) and RPC twins chatelet_operator_get/update (AUTH_WALLET); saving re-publishes the owner's active listings. Admin UI moves the house-rule inputs into a per-operator card with the card toggle and a provider hint. The old house-rule columns on settings stay for old rows but are no longer read. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
feaaef93e3
commit
9ab52f2c69
17 changed files with 531 additions and 42 deletions
|
|
@ -123,3 +123,27 @@ async def m002_room_checkin_instructions(db):
|
|||
"ALTER TABLE chatelet.rooms ADD COLUMN checkin_instructions TEXT "
|
||||
"NOT NULL DEFAULT '';"
|
||||
)
|
||||
|
||||
|
||||
async def m003_operator_settings_and_guest_index(db):
|
||||
"""Chatelet is multi-tenant: every LNbits user may host rooms. What an
|
||||
operator decides for *all their rooms* — house rules and whether they
|
||||
take card payments — lives here, keyed by LNbits user id, created lazily.
|
||||
The single `chatelet.settings` row keeps only instance-wide knobs; its
|
||||
old house-rule columns stay in place but are no longer read.
|
||||
|
||||
Also indexes bookings by guest so a guest can list their own stays."""
|
||||
await db.execute(f"""
|
||||
CREATE TABLE chatelet.operator_settings (
|
||||
user_id TEXT PRIMARY KEY,
|
||||
accept_fiat BOOLEAN NOT NULL DEFAULT false,
|
||||
checkin_time TEXT NOT NULL DEFAULT '15:00',
|
||||
checkout_time TEXT NOT NULL DEFAULT '11:00',
|
||||
cancellation_policy TEXT NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now},
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT {db.timestamp_now}
|
||||
);
|
||||
""")
|
||||
await db.execute(
|
||||
"CREATE INDEX chatelet.idx_bookings_guest_pubkey ON bookings (guest_pubkey);"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue