rebreak-monorepo/backend/server/api/me/calls-enabled.post.ts
chahinebrini 89e4e3481b feat(calls): Phase 0 — calls_enabled opt-out + canCall guard (mutual-follow); DM UI batch
Backend (voice-call groundwork, no call engine yet):
- Profile.callsEnabled (Boolean default true) + migration
- canCall(caller,callee): mutual-follow AND callee.callsEnabled — server-side hard guard
- POST /api/me/calls-enabled (opt-out toggle), GET /api/chat/can-call/:userId
- expose callsEnabled in /api/auth/me

Frontend:
- "Allow calls" toggle in Profile privacy section (default on, optimistic+rollback)
- Me.callsEnabled + i18n DE/EN/FR/AR

Bundled DM UI work from this session:
- image lightbox is now a swipeable carousel over all shared images (+ counter)
- keyboard stays open after sending (input ref refocus)
- voice notes: Instagram-style waveforms (own=white/mint, other=black/grey),
  removed the blue progress dot; lazy-load expo-media-library with clean fallback
- expo-linear-gradient + expo-media-library deps

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 21:14:31 +02:00

24 lines
720 B
TypeScript

/**
* POST /api/me/calls-enabled
*
* Opt-out toggle für eingehende Voice-Calls des authentifizierten Users.
* calls_enabled=false → andere User können nicht anrufen (zusätzlich zur
* Mutual-Follow-Schranke). Default true.
*
* Body: { enabled: boolean }
* Response: { callsEnabled: boolean }
*/
import { requireUser } from "../../utils/auth";
import { setCallsEnabled } from "../../db/profile";
export default defineEventHandler(async (event) => {
const user = await requireUser(event);
const body = await readBody(event);
if (typeof body?.enabled !== "boolean") {
throw createError({ statusCode: 400, message: "INVALID_ENABLED" });
}
return setCallsEnabled(user.id, body.enabled);
});