Caller/Callee UX: - lib/ringback.ts + assets/sounds/ringback_eu.mp3 (EU 425Hz Festnetz-Tone) - stores/call.ts: stopRingback bei connected, hangup-reasons, logCallToChat fix - locales: 'Wird angerufen…' statt 'Ruft an…' CallKit (iOS) + ConnectionService (Android): - lib/callkit.ts: setupCallKeep, displayIncomingCall, startOutgoingCall, reportConnected/Ended (appName 'ReBreak-Audio', includesCallsInRecents=false für DSGVO/DiGA) - hooks/useCallKeepEvents.ts: native answer/end/mute → useCallStore-Actions - stores/call.ts: CallKit-Aufrufe an allen lifecycle-Punkten - app.config.ts: @config-plugins/react-native-callkeep + UIBackgroundModes voip/audio + Android-Telecom-Perms VoIP-PushKit Backend: - services/voip-push.ts: @parse/node-apn Provider mit .p12 (Topic org.rebreak.app.voip) - services/push.ts sendCallRingPush: feuert beide Pfade (VoIP iOS + Expo Android/Fallback) - prisma: push_tokens.voip_token Column + Migration 20260604 - api/users/me/push-token: optional voipToken im Body - Env (Infisical): APNS_VOIP_P12_PATH/PASSWORD/TOPIC/PRODUCTION Push-tap routing + cold-start handling: - app/_layout.tsx: type:'call' Push → useCallStore.receiveIncoming + /call Docs: ops/CALLKIT_SETUP.md (Apple-Portal-Steps für VoIP-Cert)
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
/**
|
|
* POST /api/calls/ring
|
|
*
|
|
* Triggert einen Push an den Callee bei einem eingehenden Voice-Call.
|
|
* Wird vom Caller direkt nach dem Supabase-Realtime-Broadcast aufgerufen
|
|
* (fire-and-forget). Der Push deckt den Background-/Locked-Screen-Fall ab;
|
|
* Foreground wird weiter via Realtime gehandhabt.
|
|
*
|
|
* Body: { peerId: string, callId: string }
|
|
*
|
|
* Kein VoIPPushKit/CallKit (Phase 2). Regulärer APNs/FCM Alert-Push mit
|
|
* priority=high + channelId="calls".
|
|
*/
|
|
import { requireUser } from "../../utils/auth";
|
|
import { usePrisma } from "../../utils/prisma";
|
|
import { sendCallRingPush } from "../../services/push";
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const user = await requireUser(event);
|
|
const body = await readBody<{ peerId?: string; callId?: string }>(event);
|
|
|
|
const peerId = body?.peerId?.trim();
|
|
const callId = body?.callId?.trim();
|
|
if (!peerId || !callId) {
|
|
throw createError({ statusCode: 400, statusMessage: "peerId_and_callId_required" });
|
|
}
|
|
if (peerId === user.id) {
|
|
throw createError({ statusCode: 400, statusMessage: "cannot_ring_self" });
|
|
}
|
|
|
|
const db = usePrisma();
|
|
const me = await db.profile.findUnique({
|
|
where: { id: user.id },
|
|
select: { id: true, nickname: true, username: true, avatar: true },
|
|
});
|
|
if (!me) {
|
|
throw createError({ statusCode: 404, statusMessage: "caller_profile_not_found" });
|
|
}
|
|
|
|
const callerName = me.nickname || me.username || "Jemand";
|
|
|
|
// Fire-and-forget — auch wenn der Push fehlschlägt soll der Caller
|
|
// keine Verzögerung sehen. Der Realtime-Ring läuft parallel.
|
|
void sendCallRingPush({
|
|
receiverId: peerId,
|
|
callerName,
|
|
callerId: me.id,
|
|
callerNickname: me.nickname || me.username || "",
|
|
callerAvatar: me.avatar,
|
|
callId,
|
|
});
|
|
|
|
return { ok: true };
|
|
});
|