mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-21 21:57:28 +08:00
fix: add fallback savetime
This commit is contained in:
@@ -89,12 +89,12 @@ export async function POST(request: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const favoriteWithoutUserId = {
|
const finalFavorite = {
|
||||||
...favorite,
|
...favorite,
|
||||||
save_time: favorite.save_time ?? Date.now(),
|
save_time: favorite.save_time ?? Date.now(),
|
||||||
} as Omit<Favorite, 'user_id'>;
|
} as Favorite;
|
||||||
|
|
||||||
await db.saveFavorite(authInfo.username, source, id, favoriteWithoutUserId);
|
await db.saveFavorite(authInfo.username, source, id, finalFavorite);
|
||||||
|
|
||||||
return NextResponse.json({ success: true }, { status: 200 });
|
return NextResponse.json({ success: true }, { status: 200 });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ export async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
console.log('username', authInfo.username);
|
|
||||||
console.log('body', body);
|
|
||||||
const { key, record }: { key: string; record: PlayRecord } = body;
|
const { key, record }: { key: string; record: PlayRecord } = body;
|
||||||
|
|
||||||
if (!key || !record) {
|
if (!key || !record) {
|
||||||
@@ -64,7 +62,12 @@ export async function POST(request: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.savePlayRecord(authInfo.username, source, id, record);
|
const finalRecord = {
|
||||||
|
...record,
|
||||||
|
save_time: record.save_time ?? Date.now(),
|
||||||
|
} as PlayRecord;
|
||||||
|
|
||||||
|
await db.savePlayRecord(authInfo.username, source, id, finalRecord);
|
||||||
|
|
||||||
return NextResponse.json({ success: true }, { status: 200 });
|
return NextResponse.json({ success: true }, { status: 200 });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user