Watch party invites by profile: host invites online profiles, invited users see running parties on open and can join one or dismiss
This commit is contained in:
@@ -2304,7 +2304,16 @@ app.get('/api/user/data', async (c) => {
|
||||
// Phone remote for a desktop instance — see remote.js
|
||||
// ============================================================================
|
||||
const remote = createRemoteHub({ requireSameNetwork: process.env.REMOTE_SAME_NETWORK === '1' });
|
||||
const party = createPartyHub();
|
||||
const party = createPartyHub({ profileExists: async (name) => !!(await getProfile(name)) });
|
||||
// Running parties that invited this online profile (protected profiles need their secret).
|
||||
app.get('/api/party/invites', async (c) => {
|
||||
const name = (c.req.query('name') || '').trim().toLowerCase();
|
||||
const row = name ? await getProfile(name) : null;
|
||||
if (!row) return c.json({ ok: true, invites: [] }, 200, { 'Cache-Control': 'no-store' });
|
||||
const denied = await profileGate(c, name, row, c.req.header('x-profile-secret'));
|
||||
if (denied) return denied;
|
||||
return c.json({ ok: true, invites: party.invitesFor(name) }, 200, { 'Cache-Control': 'no-store' });
|
||||
});
|
||||
|
||||
// Bun allows ONE websocket handler per server: party sockets are tagged
|
||||
// (ws.data.hub === 'party'), everything else belongs to the remote relay.
|
||||
|
||||
Reference in New Issue
Block a user