Insta-style Online-Status mit Following-Filter + User-opt-out: - Profile.lastSeenAt + Profile.presenceVisible (default true) - GET /api/presence/last-seen?userIds=... batch, server-side filter durch Follow-Relation + presenceVisible - GET /api/me/following → User-IDs für client-side Channel-Filter (Supabase Realtime Presence hat keine server-side Filter) - POST /api/me/presence-visibility Toggle - POST /api/me/last-seen Heartbeat (Phase-1-Fallback bis Edge-Function) - /api/auth/me extended um presenceVisible für Settings-Initial-State DB-Layer nutzt raw SQL bis Migration auf staging gelaufen ist (Prisma-Client refresh erst nach CI generate). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
23 lines
673 B
TypeScript
23 lines
673 B
TypeScript
/**
|
|
* POST /api/me/presence-visibility
|
|
*
|
|
* Opt-out toggle for the authenticated user's online status visibility.
|
|
* When visible=false, no other user will see lastSeenAt regardless of follow status.
|
|
*
|
|
* Body: { visible: boolean }
|
|
* Response: { presenceVisible: boolean }
|
|
*/
|
|
import { requireUser } from "../../utils/auth";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const user = await requireUser(event);
|
|
|
|
const body = await readBody(event);
|
|
if (typeof body?.visible !== "boolean") {
|
|
throw createError({ statusCode: 400, message: "INVALID_VISIBLE" });
|
|
}
|
|
|
|
const result = await setPresenceVisible(user.id, body.visible);
|
|
return result;
|
|
});
|