mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 20:10:33 +00:00
prettier
This commit is contained in:
parent
e37eeae3fe
commit
0cacd84da7
7 changed files with 3714 additions and 1344 deletions
|
|
@ -8,7 +8,7 @@ export async function sendPlayerStatus({
|
|||
roomCode,
|
||||
isHost,
|
||||
content,
|
||||
player
|
||||
player,
|
||||
}: {
|
||||
userId: string;
|
||||
roomCode: string;
|
||||
|
|
@ -102,7 +102,6 @@ export async function getRoomStatuses(roomCode: string) {
|
|||
*/
|
||||
export function ModifiedWebhookReporter() {
|
||||
// Example replacing the Discord webhook code
|
||||
|
||||
/*
|
||||
useEffect(() => {
|
||||
// Skip if watch party is not enabled or no status
|
||||
|
|
|
|||
4949
pnpm-lock.yaml
4949
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -15,14 +15,16 @@ Send a player status update.
|
|||
"userId": "user123", // Required: User identifier
|
||||
"roomCode": "room456", // Required: Room code
|
||||
"isHost": true, // Optional: Whether the user is the host
|
||||
"content": { // Optional: Content information
|
||||
"content": {
|
||||
// Optional: Content information
|
||||
"title": "Movie Title",
|
||||
"type": "Movie", // "Movie", "TV Show", etc.
|
||||
"tmdbId": 12345, // Optional: TMDB ID for the content
|
||||
"seasonNumber": 1, // Optional: Season number (for TV shows)
|
||||
"episodeNumber": 3 // Optional: Episode number (for TV shows)
|
||||
},
|
||||
"player": { // Optional: Player state
|
||||
"player": {
|
||||
// Optional: Player state
|
||||
"isPlaying": true,
|
||||
"isPaused": false,
|
||||
"isLoading": false,
|
||||
|
|
@ -50,6 +52,7 @@ Send a player status update.
|
|||
Get status updates for a specific user in a specific room.
|
||||
|
||||
**Query Parameters:**
|
||||
|
||||
- `userId`: User identifier
|
||||
- `roomCode`: Room code
|
||||
|
||||
|
|
@ -94,6 +97,7 @@ Get status updates for a specific user in a specific room.
|
|||
Get status updates for all users in a specific room.
|
||||
|
||||
**Query Parameters:**
|
||||
|
||||
- `roomCode`: Room code
|
||||
|
||||
**Response:**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { defineEventHandler, getQuery, createError } from 'h3';
|
||||
import { playerStatusStore, CLEANUP_INTERVAL } from '~/utils/playerStatus';
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
export default defineEventHandler(event => {
|
||||
const query = getQuery(event);
|
||||
const userId = query.userId as string;
|
||||
const roomCode = query.roomCode as string;
|
||||
|
|
@ -24,7 +24,7 @@ export default defineEventHandler((event) => {
|
|||
|
||||
return {
|
||||
roomCode,
|
||||
users: roomStatuses
|
||||
users: roomStatuses,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -44,13 +44,13 @@ export default defineEventHandler((event) => {
|
|||
return {
|
||||
userId,
|
||||
roomCode,
|
||||
statuses: recentStatuses
|
||||
statuses: recentStatuses,
|
||||
};
|
||||
}
|
||||
|
||||
// If neither is provided, return error
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Missing required query parameters: roomCode and/or userId'
|
||||
statusMessage: 'Missing required query parameters: roomCode and/or userId',
|
||||
});
|
||||
});
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import { defineEventHandler, readBody, createError } from 'h3';
|
||||
import { playerStatusStore, PlayerStatus } from '~/utils/playerStatus';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
export default defineEventHandler(async event => {
|
||||
const body = await readBody(event);
|
||||
|
||||
if (!body || !body.userId || !body.roomCode) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Missing required fields: userId, roomCode'
|
||||
statusMessage: 'Missing required fields: userId, roomCode',
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ export default defineEventHandler(async (event) => {
|
|||
seasonId: body.content?.seasonId,
|
||||
episodeId: body.content?.episodeId,
|
||||
seasonNumber: body.content?.seasonNumber,
|
||||
episodeNumber: body.content?.episodeNumber
|
||||
episodeNumber: body.content?.episodeNumber,
|
||||
},
|
||||
player: {
|
||||
isPlaying: body.player?.isPlaying || false,
|
||||
|
|
@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
|
|||
playbackRate: body.player?.playbackRate || 1,
|
||||
buffered: body.player?.buffered || 0,
|
||||
},
|
||||
timestamp: Date.now()
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
|
||||
const key = `${status.userId}:${status.roomCode}`;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,14 @@ const progressMetaSchema = z.object({
|
|||
const progressItemSchema = z.object({
|
||||
meta: progressMetaSchema,
|
||||
tmdbId: z.string().transform(val => val || randomUUID()),
|
||||
duration: z.number().min(0).transform(n => Math.round(n)),
|
||||
watched: z.number().min(0).transform(n => Math.round(n)),
|
||||
duration: z
|
||||
.number()
|
||||
.min(0)
|
||||
.transform(n => Math.round(n)),
|
||||
watched: z
|
||||
.number()
|
||||
.min(0)
|
||||
.transform(n => Math.round(n)),
|
||||
seasonId: z.string().optional(),
|
||||
episodeId: z.string().optional(),
|
||||
seasonNumber: z.number().optional(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue