feat(episodes): let owners remove episodes from the RSS feed

Adds an "unlisted" flag on episodes rather than reusing the existing
hard-delete route, since a hard delete cascades to purchases/earnings
(ON DELETE CASCADE) and would wipe a producer's sales history and any
unwithdrawn earnings for that episode. Unlisting only affects feed.xml
output — the episode, its purchases, and reseller listings all stay
intact and it can be relisted at any time.

Wires up the missing frontend for it too: the podcast settings page
had no episode list or management controls at all before this, despite
the backend already exposing full episode CRUD.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-09 21:14:23 +00:00
co-authored by Claude Sonnet 5
parent 69241a28b1
commit 5ebea55353
6 changed files with 110 additions and 4 deletions
+31
View File
@@ -153,6 +153,7 @@ describe('login allowlist', () => {
describe('podcasts, episodes, feed', () => {
let podcastId: string;
let episodeId: string;
const sha = 'c'.repeat(64);
it('creates a podcast', async () => {
@@ -188,6 +189,7 @@ describe('podcasts, episodes, feed', () => {
});
expect(res.statusCode).toBe(201);
expect(res.json().enclosure_url).toContain(`${sha}.mp4`);
episodeId = res.json().id;
} finally {
vi.unstubAllGlobals();
}
@@ -229,6 +231,35 @@ describe('podcasts, episodes, feed', () => {
});
expect(cached.statusCode).toBe(304);
});
it('removing an episode from the feed hides it from feed.xml but keeps it in the owner list', async () => {
const unlist = await app.inject({
method: 'PUT',
url: `/api/podcasts/${podcastId}/episodes/${episodeId}`,
headers: { cookie },
payload: { unlisted: true },
});
expect(unlist.statusCode).toBe(200);
expect(unlist.json().unlisted).toBe(1);
const feed = await app.inject({ method: 'GET', url: `/feeds/${podcastId}/feed.xml` });
expect(feed.body).not.toContain(`${sha}.mp4`);
const owned = await app.inject({ method: 'GET', url: `/api/podcasts/${podcastId}`, headers: { cookie } });
expect(owned.json().episodes.some((e: { id: string }) => e.id === episodeId)).toBe(true);
const relist = await app.inject({
method: 'PUT',
url: `/api/podcasts/${podcastId}/episodes/${episodeId}`,
headers: { cookie },
payload: { unlisted: false },
});
expect(relist.statusCode).toBe(200);
expect(relist.json().unlisted).toBe(0);
const feedAgain = await app.inject({ method: 'GET', url: `/feeds/${podcastId}/feed.xml` });
expect(feedAgain.body).toContain(`${sha}.mp4`);
});
});
describe('streams + mediamtx auth webhook', () => {
+11
View File
@@ -148,6 +148,17 @@ CREATE TABLE cashu_proofs (
created_at INTEGER NOT NULL
);
CREATE INDEX idx_cashu_proofs_unspent ON cashu_proofs(spent_at);
`,
},
{
id: 3,
sql: `
-- Removing an episode from the RSS feed doesn't have to mean deleting it outright:
-- a hard DELETE cascades to purchases/earnings (ON DELETE CASCADE), which would wipe
-- a producer's sales history and any unwithdrawn earnings for that episode. "unlisted"
-- lets the feed simply omit the episode while everything else (purchases, reseller
-- listings, the blob itself) stays intact and reversible.
ALTER TABLE episodes ADD COLUMN unlisted INTEGER NOT NULL DEFAULT 0;
`,
},
];
+1 -1
View File
@@ -8,7 +8,7 @@ export default async function feedRoutes(app: FastifyInstance) {
const { db, settings } = app.ctx;
const getPodcast = db.prepare('SELECT * FROM podcasts WHERE id = ?');
const listEpisodes = db.prepare('SELECT * FROM episodes WHERE podcast_id = ? ORDER BY pub_date DESC');
const listEpisodes = db.prepare('SELECT * FROM episodes WHERE podcast_id = ? AND unlisted = 0 ORDER BY pub_date DESC');
const listAllPodcasts = db.prepare('SELECT * FROM podcasts ORDER BY created_at');
app.get('/feeds/:id/feed.xml', async (req, reply) => {
+3 -2
View File
@@ -35,6 +35,7 @@ const episodeSchema = z.object({
episode_no: z.number().int().positive().nullish(),
pub_date: z.number().int().positive().optional(),
price_sats: z.number().int().positive().nullish(),
unlisted: z.boolean().optional(),
});
export default async function podcastRoutes(app: FastifyInstance) {
@@ -168,10 +169,10 @@ export default async function podcastRoutes(app: FastifyInstance) {
const d = { ...episode, ...parsed.data };
db.prepare(`
UPDATE episodes SET title=?, description=?, duration_secs=?, season=?, episode_no=?,
pub_date=?, price_sats=?
pub_date=?, price_sats=?, unlisted=?
WHERE id=?
`).run(d.title, d.description, d.duration_secs ?? null, d.season ?? null,
d.episode_no ?? null, d.pub_date, d.price_sats ?? null, eid);
d.episode_no ?? null, d.pub_date, d.price_sats ?? null, d.unlisted ? 1 : 0, eid);
return getEpisode.get(eid, id) as Episode;
});
+1
View File
@@ -41,6 +41,7 @@ export interface Episode {
price_sats: number | null;
pub_date: number;
created_at: number;
unlisted: number;
}
export interface Purchase {