more interaction endpoints

This commit is contained in:
Devin Zuczek
2026-07-05 17:07:28 -04:00
parent bc7e4d718c
commit 8e255b0129
4 changed files with 131 additions and 31 deletions
+26
View File
@@ -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,