mirror of
https://github.com/djdevin/recflare.git
synced 2026-10-27 16:08:58 -07:00
support for 202507 endpoints (#37)
* [auth][api] accept the 20250424.01 client * [2025] unstable * 20250718.0 * correct one this time * stubs * more stubs * more stubs * [lists] add worker * [ai] route stubs * [api] player photo setting * [econ] add roomEconConfig route * [infra] update worker generators * [worker] add cards/moderation/platformnotification workers * [lists] updates to some endpoints * [clubs] stub out announcement endpoint, for now * [econ] stub out season endpoints for now * [chat] apps/chat stub out party endpoint not sure the shape yet * [api] stub out statsig and lockeditems * [doc] new services * [lists] stub the bulk endpoint * [datacollection] add placeholder service until we can kill it * [api] set gifting to lvl5 * update lock * [cdn] enable cache * [match] matchmake v2 * [lists] stub some lists * [ai] stubs * [rooms] new subroom save endpoint * [econ] add bulk purchase endpoint * [discovery] update featured creator to 1 for fun * [api] add photo settings flag * [chat] fixup chat permissions (sorta) * [auth] restrictions endpoint * [rooms] contributed endpoint * [api] fix outfit endpoint * [discovery] attempt to fix store * [chat] privacy endpoints * [api] cheered images * [rooms] add xp endpoint (disbaled) * [rooms] add xp endpoint (disabled) * update images-db for cheers * [rooms] add autocomplete endpoint * [cdn/img] increase cache ttl for statics * [api] bulk route for images * [accounts] add banner image * [api] add misc missing endpoints * [discovery] remove AI tab * [platformnotifications] stub some endpoints * [lists] add some more lists * [rooms] additional endpoints * [chat] stub a few privacy endpoints * [econ] stub some endpoints * misc db fixes * [api] tweak shape for images v6 * [rooms] dont show trending RROs
This commit is contained in:
@@ -199,6 +199,36 @@ export async function areFriends(
|
||||
return row !== null
|
||||
}
|
||||
|
||||
/**
|
||||
* How many of a player's friends are online right now — the friend graph joined to live
|
||||
* `presence`, which is the count the client's friends panel shows. `Friend` rows only,
|
||||
* from either side of the pair, and only unexpired presence (rows outlive the player by
|
||||
* up to the TTL, exactly as every other presence read treats them). Lobby (null-instance)
|
||||
* presence counts: those friends are signed in, just not in a room.
|
||||
*
|
||||
* A friend's `statusVisibility` is deliberately NOT consulted — nothing else in the stack
|
||||
* filters presence on it (the batch `/player` lookup reports it and lets the client
|
||||
* decide), so hiding people here would disagree with the list the panel then renders.
|
||||
*/
|
||||
export async function countOnlineFriends(
|
||||
db: D1Database,
|
||||
playerId: number,
|
||||
now = Math.floor(Date.now() / 1000)
|
||||
): Promise<number> {
|
||||
const row = await db
|
||||
.prepare(
|
||||
`SELECT COUNT(*) AS n FROM relationship r
|
||||
JOIN presence p
|
||||
ON p.account_id = CASE WHEN r.requester_id = ?1 THEN r.target_id ELSE r.requester_id END
|
||||
WHERE r.relationship_type = ?2
|
||||
AND (r.requester_id = ?1 OR r.target_id = ?1)
|
||||
AND p.expires_at > ?3`
|
||||
)
|
||||
.bind(playerId, RelationshipType.Friend, now)
|
||||
.first<{ n: number }>()
|
||||
return row?.n ?? 0
|
||||
}
|
||||
|
||||
/** How many mutual friends the mutual-friends lookup will return at most. */
|
||||
export const MUTUAL_FRIENDS_LIMIT = 100
|
||||
|
||||
|
||||
Reference in New Issue
Block a user