관리자 편집 보호: 자동 매칭은 관리자가 정한 영상을 덮어쓰지 않음(쓰기 시점 조건·실제 갱신만 집계), 다시 가져와도 관리자가 정한 장르(빈 선택 포함) 유지, 안 바꾼 유튜브 주소는 보내지 않음 + 후보 확정 버튼, 회귀 테스트 3개·e2e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -149,13 +149,15 @@ export function updateSong(db: Database, id: number, p: SongPatch, embed?: { aut
|
||||
id,
|
||||
);
|
||||
if (p.youtubeId !== undefined) {
|
||||
if (p.youtubeId === null) db.query("UPDATE songs SET youtube_id = NULL, youtube_status = 'none', youtube_source = 'admin' WHERE id = ?").run(id);
|
||||
// Clearing a video that isn't there is no change: it must not take the song out of the automatic search.
|
||||
if (p.youtubeId === null) db.query("UPDATE songs SET youtube_id = NULL, youtube_status = 'none', youtube_source = 'admin' WHERE id = ? AND youtube_id IS NOT NULL").run(id);
|
||||
else
|
||||
db.query(
|
||||
"UPDATE songs SET youtube_id = ?, youtube_status = 'matched', youtube_source = 'admin', youtube_channel = ?, youtube_title = ?, embeddable = 1, youtube_checked_at = ? WHERE id = ?",
|
||||
).run(p.youtubeId, embed?.author ?? null, embed?.title ?? null, now, id);
|
||||
}
|
||||
if (p.genres) {
|
||||
db.query("UPDATE songs SET genres_source = 'admin' WHERE id = ?").run(id);
|
||||
db.query('DELETE FROM song_genres WHERE song_id = ?').run(id);
|
||||
for (const g of p.genres) db.query("INSERT INTO song_genres (song_id, genre_id, source) VALUES (?, ?, 'admin')").run(id, g);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user