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,
|
roomCode,
|
||||||
isHost,
|
isHost,
|
||||||
content,
|
content,
|
||||||
player
|
player,
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
roomCode: string;
|
roomCode: string;
|
||||||
|
|
@ -102,7 +102,6 @@ export async function getRoomStatuses(roomCode: string) {
|
||||||
*/
|
*/
|
||||||
export function ModifiedWebhookReporter() {
|
export function ModifiedWebhookReporter() {
|
||||||
// Example replacing the Discord webhook code
|
// Example replacing the Discord webhook code
|
||||||
|
|
||||||
/*
|
/*
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Skip if watch party is not enabled or no status
|
// 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
|
|
@ -12,26 +12,28 @@ Send a player status update.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"userId": "user123", // Required: User identifier
|
"userId": "user123", // Required: User identifier
|
||||||
"roomCode": "room456", // Required: Room code
|
"roomCode": "room456", // Required: Room code
|
||||||
"isHost": true, // Optional: Whether the user is the host
|
"isHost": true, // Optional: Whether the user is the host
|
||||||
"content": { // Optional: Content information
|
"content": {
|
||||||
|
// Optional: Content information
|
||||||
"title": "Movie Title",
|
"title": "Movie Title",
|
||||||
"type": "Movie", // "Movie", "TV Show", etc.
|
"type": "Movie", // "Movie", "TV Show", etc.
|
||||||
"tmdbId": 12345, // Optional: TMDB ID for the content
|
"tmdbId": 12345, // Optional: TMDB ID for the content
|
||||||
"seasonNumber": 1, // Optional: Season number (for TV shows)
|
"seasonNumber": 1, // Optional: Season number (for TV shows)
|
||||||
"episodeNumber": 3 // Optional: Episode number (for TV shows)
|
"episodeNumber": 3 // Optional: Episode number (for TV shows)
|
||||||
},
|
},
|
||||||
"player": { // Optional: Player state
|
"player": {
|
||||||
|
// Optional: Player state
|
||||||
"isPlaying": true,
|
"isPlaying": true,
|
||||||
"isPaused": false,
|
"isPaused": false,
|
||||||
"isLoading": false,
|
"isLoading": false,
|
||||||
"hasPlayedOnce": true,
|
"hasPlayedOnce": true,
|
||||||
"time": 120.5, // Current playback position in seconds
|
"time": 120.5, // Current playback position in seconds
|
||||||
"duration": 3600, // Total content duration in seconds
|
"duration": 3600, // Total content duration in seconds
|
||||||
"volume": 0.8, // Volume level (0-1)
|
"volume": 0.8, // Volume level (0-1)
|
||||||
"playbackRate": 1, // Playback speed
|
"playbackRate": 1, // Playback speed
|
||||||
"buffered": 180 // Buffered seconds
|
"buffered": 180 // Buffered seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -41,7 +43,7 @@ Send a player status update.
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"success": true,
|
"success": true,
|
||||||
"timestamp": 1625097600000 // The timestamp assigned to this status update
|
"timestamp": 1625097600000 // The timestamp assigned to this status update
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -50,6 +52,7 @@ Send a player status update.
|
||||||
Get status updates for a specific user in a specific room.
|
Get status updates for a specific user in a specific room.
|
||||||
|
|
||||||
**Query Parameters:**
|
**Query Parameters:**
|
||||||
|
|
||||||
- `userId`: User identifier
|
- `userId`: User identifier
|
||||||
- `roomCode`: Room code
|
- `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.
|
Get status updates for all users in a specific room.
|
||||||
|
|
||||||
**Query Parameters:**
|
**Query Parameters:**
|
||||||
|
|
||||||
- `roomCode`: Room code
|
- `roomCode`: Room code
|
||||||
|
|
||||||
**Response:**
|
**Response:**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { defineEventHandler, getQuery, createError } from 'h3';
|
import { defineEventHandler, getQuery, createError } from 'h3';
|
||||||
import { playerStatusStore, CLEANUP_INTERVAL } from '~/utils/playerStatus';
|
import { playerStatusStore, CLEANUP_INTERVAL } from '~/utils/playerStatus';
|
||||||
|
|
||||||
export default defineEventHandler((event) => {
|
export default defineEventHandler(event => {
|
||||||
const query = getQuery(event);
|
const query = getQuery(event);
|
||||||
const userId = query.userId as string;
|
const userId = query.userId as string;
|
||||||
const roomCode = query.roomCode as string;
|
const roomCode = query.roomCode as string;
|
||||||
|
|
@ -24,7 +24,7 @@ export default defineEventHandler((event) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
roomCode,
|
roomCode,
|
||||||
users: roomStatuses
|
users: roomStatuses,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,13 +44,13 @@ export default defineEventHandler((event) => {
|
||||||
return {
|
return {
|
||||||
userId,
|
userId,
|
||||||
roomCode,
|
roomCode,
|
||||||
statuses: recentStatuses
|
statuses: recentStatuses,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// If neither is provided, return error
|
// If neither is provided, return error
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 400,
|
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 { defineEventHandler, readBody, createError } from 'h3';
|
||||||
import { playerStatusStore, PlayerStatus } from '~/utils/playerStatus';
|
import { playerStatusStore, PlayerStatus } from '~/utils/playerStatus';
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async event => {
|
||||||
const body = await readBody(event);
|
const body = await readBody(event);
|
||||||
|
|
||||||
if (!body || !body.userId || !body.roomCode) {
|
if (!body || !body.userId || !body.roomCode) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 400,
|
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,
|
seasonId: body.content?.seasonId,
|
||||||
episodeId: body.content?.episodeId,
|
episodeId: body.content?.episodeId,
|
||||||
seasonNumber: body.content?.seasonNumber,
|
seasonNumber: body.content?.seasonNumber,
|
||||||
episodeNumber: body.content?.episodeNumber
|
episodeNumber: body.content?.episodeNumber,
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
isPlaying: body.player?.isPlaying || false,
|
isPlaying: body.player?.isPlaying || false,
|
||||||
|
|
@ -35,7 +35,7 @@ export default defineEventHandler(async (event) => {
|
||||||
playbackRate: body.player?.playbackRate || 1,
|
playbackRate: body.player?.playbackRate || 1,
|
||||||
buffered: body.player?.buffered || 0,
|
buffered: body.player?.buffered || 0,
|
||||||
},
|
},
|
||||||
timestamp: Date.now()
|
timestamp: Date.now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const key = `${status.userId}:${status.roomCode}`;
|
const key = `${status.userId}:${status.roomCode}`;
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,14 @@ const progressMetaSchema = z.object({
|
||||||
const progressItemSchema = z.object({
|
const progressItemSchema = z.object({
|
||||||
meta: progressMetaSchema,
|
meta: progressMetaSchema,
|
||||||
tmdbId: z.string().transform(val => val || randomUUID()),
|
tmdbId: z.string().transform(val => val || randomUUID()),
|
||||||
duration: z.number().min(0).transform(n => Math.round(n)),
|
duration: z
|
||||||
watched: z.number().min(0).transform(n => Math.round(n)),
|
.number()
|
||||||
|
.min(0)
|
||||||
|
.transform(n => Math.round(n)),
|
||||||
|
watched: z
|
||||||
|
.number()
|
||||||
|
.min(0)
|
||||||
|
.transform(n => Math.round(n)),
|
||||||
seasonId: z.string().optional(),
|
seasonId: z.string().optional(),
|
||||||
episodeId: z.string().optional(),
|
episodeId: z.string().optional(),
|
||||||
seasonNumber: z.number().optional(),
|
seasonNumber: z.number().optional(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue