fix: recording save functionality and authentication

- Fix artist_name null handling in header component with email fallback
- Fix authentication in recording endpoints to use req.accountability
- Change duration field type from integer to double precision for millisecond precision
- Add createRecording service function with proper authentication
- Update play page to use fetch API for recording saves

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Valknar XXX
2025-10-28 05:16:36 +01:00
parent 5bd2d9c215
commit a252da6d9d
5 changed files with 65 additions and 31 deletions

View File

@@ -22,8 +22,6 @@ import DeviceCard from "$lib/components/device-card/device-card.svelte";
import RecordingSaveDialog from "./components/recording-save-dialog.svelte";
import type { BluetoothDevice, RecordedEvent, DeviceInfo } from "$lib/types";
import { toast } from "svelte-sonner";
import { customEndpoint } from "@directus/sdk";
import { getDirectusInstance } from "$lib/directus";
const client = new ButtplugClient("Sexy.Art");
let connected = $state(client.connected);
@@ -191,25 +189,25 @@ async function handleSaveRecording(data: {
}));
try {
const directus = getDirectusInstance();
await directus.request(
customEndpoint({
method: "POST",
path: "/sexy/recordings",
body: JSON.stringify({
title: data.title,
description: data.description,
duration: recordingDuration,
events: recordedEvents,
device_info: deviceInfo,
tags: data.tags,
status: "draft",
}),
headers: {
"Content-Type": "application/json",
},
const response = await fetch("/api/sexy/recordings", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
title: data.title,
description: data.description,
duration: recordingDuration,
events: recordedEvents,
device_info: deviceInfo,
tags: data.tags,
status: "draft",
}),
);
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
toast.success("Recording saved successfully!");
showSaveDialog = false;