feat(api): a guest's own bookings on both doors
GET /api/v1/bookings/mine (LNbits account auth; identity = the account's
Nostr pubkey, the same value the booking request carried) and RPC twin
chatelet_booking_list_mine (scoped by the signed sender_pubkey). Rows come
back newest check-in first via the m003 guest index, as guest_booking_dict:
the guest's own contact and counts, minus the Lightning/Nostr plumbing.
Declared ahead of /bookings/{booking_id} so 'mine' is not read as an id.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
9ab52f2c69
commit
8b816d83b0
8 changed files with 140 additions and 2 deletions
14
views_api.py
14
views_api.py
|
|
@ -8,8 +8,8 @@ the guest-facing surface (availability, booking) is what also rides the RPC.
|
|||
"""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from lnbits.core.models import WalletTypeInfo
|
||||
from lnbits.decorators import require_admin_key, require_invoice_key
|
||||
from lnbits.core.models import User, WalletTypeInfo
|
||||
from lnbits.decorators import check_user_exists, require_admin_key, require_invoice_key
|
||||
|
||||
from . import crud, services
|
||||
from .models import (
|
||||
|
|
@ -286,6 +286,16 @@ async def api_request_booking(data: BookingRequestData) -> BookingQuote:
|
|||
raise _to_http(exc) from exc
|
||||
|
||||
|
||||
@chatelet_api_router.get("/api/v1/bookings/mine")
|
||||
async def api_my_bookings(user: User = Depends(check_user_exists)) -> list[dict]:
|
||||
"""The signed-in guest's own stays. Identity is the LNbits account's Nostr
|
||||
pubkey — the same value the booking request carried as guest_pubkey.
|
||||
Declared before /bookings/{booking_id} so "mine" is not read as an id."""
|
||||
if not user.pubkey:
|
||||
raise HTTPException(409, "This account has no Nostr pubkey")
|
||||
return await services.list_guest_bookings(user.pubkey)
|
||||
|
||||
|
||||
@chatelet_api_router.get("/api/v1/bookings/{booking_id}")
|
||||
async def api_get_booking(
|
||||
booking_id: str, key: WalletTypeInfo = Depends(require_invoice_key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue