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)
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
/**
|
|
* POST /api/users/me/push-token
|
|
*
|
|
* Client (Expo) ruft das nach `getExpoPushTokenAsync()` auf, um seinen Token
|
|
* im Backend zu hinterlegen. Idempotent: bei existierendem Token wird nur
|
|
* lastUsedAt + enabled aktualisiert.
|
|
*
|
|
* Body: { token: string, platform: "ios" | "android", deviceId?: string }
|
|
*/
|
|
import { requireUser } from "../../../utils/auth";
|
|
import { usePrisma } from "../../../utils/prisma";
|
|
import { z } from "zod";
|
|
|
|
const Body = z.object({
|
|
token: z.string().min(10).max(200), // ExponentPushToken[xxx]
|
|
platform: z.enum(["ios", "android"]),
|
|
deviceId: z.string().max(120).optional(),
|
|
/// iOS-PushKit-Token (64-char hex) für CallKit-Wake-Pushes. Optional —
|
|
/// Client kann später via separatem Call dieselbe Row updaten.
|
|
voipToken: z.string().min(32).max(200).optional(),
|
|
});
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const user = await requireUser(event);
|
|
const raw = await readBody(event).catch(() => ({}));
|
|
const parsed = Body.safeParse(raw);
|
|
if (!parsed.success) {
|
|
throw createError({
|
|
statusCode: 400,
|
|
data: { error: "INVALID_BODY", detail: parsed.error.flatten() },
|
|
});
|
|
}
|
|
|
|
const { token, platform, deviceId, voipToken } = parsed.data;
|
|
const db = usePrisma();
|
|
|
|
await db.pushToken.upsert({
|
|
where: { token },
|
|
create: {
|
|
userId: user.id,
|
|
token,
|
|
platform,
|
|
deviceId: deviceId ?? null,
|
|
voipToken: voipToken ?? null,
|
|
enabled: true,
|
|
lastUsedAt: new Date(),
|
|
},
|
|
update: {
|
|
userId: user.id, // Token könnte das Device gewechselt haben
|
|
platform,
|
|
deviceId: deviceId ?? null,
|
|
// Wichtig: voipToken nur überschreiben wenn der Client einen mitliefert,
|
|
// sonst behalten (separate VoIP-Rotation-Calls könnten ihn schon gesetzt haben).
|
|
...(voipToken !== undefined ? { voipToken } : {}),
|
|
enabled: true,
|
|
lastUsedAt: new Date(),
|
|
},
|
|
});
|
|
|
|
return { success: true, data: { ok: true } };
|
|
});
|