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
12
crud.py
12
crud.py
|
|
@ -139,6 +139,18 @@ async def get_booking_by_payment_hash(payment_hash: str) -> Booking | None:
|
|||
)
|
||||
|
||||
|
||||
async def get_bookings_for_guest(guest_pubkey: str, limit: int = 200) -> list[Booking]:
|
||||
"""A guest's own stays, newest check-in first (idx_bookings_guest_pubkey)."""
|
||||
return await db.fetchall(
|
||||
"""
|
||||
SELECT * FROM chatelet.bookings WHERE guest_pubkey = :pk
|
||||
ORDER BY check_in DESC LIMIT :limit
|
||||
""",
|
||||
{"pk": guest_pubkey, "limit": limit},
|
||||
Booking,
|
||||
)
|
||||
|
||||
|
||||
async def get_bookings_for_room(room_id: str) -> list[Booking]:
|
||||
return await db.fetchall(
|
||||
"SELECT * FROM chatelet.bookings WHERE room_id = :rid",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue