mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 23:21:30 -07:00
more interaction endpoints
This commit is contained in:
@@ -17,6 +17,8 @@ import {
|
||||
getRoomsByCreator,
|
||||
getRoomsByIds,
|
||||
getSimilarRooms,
|
||||
removeCheer,
|
||||
removeFavorite,
|
||||
getVisitedRooms,
|
||||
searchRooms,
|
||||
setRoomDescription,
|
||||
@@ -270,6 +272,18 @@ const app = new Hono<App>()
|
||||
)
|
||||
return c.json({ ...interaction, LastVisitedAt: new Date().toISOString() })
|
||||
})
|
||||
// Explicitly un-cheer a room (DELETE clears the cheer, vs the PUT toggle).
|
||||
// Auth-gated; idempotent — un-cheering when there's no cheer is a no-op.
|
||||
.delete('/rooms/:roomId{[0-9]+}/interactionby/me/cheer', async (c) => {
|
||||
const accountId = await authedAccountId(c)
|
||||
if (accountId === null) return unauthorized(c)
|
||||
const interaction = await removeCheer(
|
||||
c.env.DB,
|
||||
accountId,
|
||||
Number.parseInt(c.req.param('roomId'), 10)
|
||||
)
|
||||
return c.json({ ...interaction, LastVisitedAt: new Date().toISOString() })
|
||||
})
|
||||
.put('/rooms/:roomId{[0-9]+}/interactionby/me/favorite', async (c) => {
|
||||
const accountId = await authedAccountId(c)
|
||||
if (accountId === null) return unauthorized(c)
|
||||
@@ -280,6 +294,18 @@ const app = new Hono<App>()
|
||||
)
|
||||
return c.json({ ...interaction, LastVisitedAt: new Date().toISOString() })
|
||||
})
|
||||
// Explicitly un-favorite a room (DELETE clears the favorite, vs the PUT toggle).
|
||||
// Auth-gated; idempotent — un-favoriting when there's no favorite is a no-op.
|
||||
.delete('/rooms/:roomId{[0-9]+}/interactionby/me/favorite', async (c) => {
|
||||
const accountId = await authedAccountId(c)
|
||||
if (accountId === null) return unauthorized(c)
|
||||
const interaction = await removeFavorite(
|
||||
c.env.DB,
|
||||
accountId,
|
||||
Number.parseInt(c.req.param('roomId'), 10)
|
||||
)
|
||||
return c.json({ ...interaction, LastVisitedAt: new Date().toISOString() })
|
||||
})
|
||||
|
||||
// Clone a room into a new one owned by the caller, using the `name` form field
|
||||
// (also accepted as a query param). Auth is required — no valid token is a 401,
|
||||
|
||||
Reference in New Issue
Block a user