Add the share toggle and privacy dialog to the podcast page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-20 15:12:51 +02:00
1 parent 588ea4e99e
commit 74ad88d06e
6 files changed
+318 -2

No files matched your search

+20
View File
@@ -409,6 +409,26 @@ translations! {
player_podcast_unsubscribe: "Unsubscribe", "Отписаться";
player_podcast_unsubscribe_confirm: "Unsubscribe from “{title}”? The feed will no longer be checked. Your progress and listening history are kept: subscribing again continues where you stopped.", "Отписаться от «{title}»? Лента больше не будет проверяться. Прогресс и история прослушиваний сохранятся: при повторной подписке вы продолжите с того же места.";
player_podcast_subscribe: "Subscribe", "Подписаться";
player_podcast_share: "Share in the federation", "Поделиться в федерации";
player_podcast_unshare: "Stop sharing", "Перестать делиться";
player_podcast_sharing: "Saving…", "Сохраняем…";
player_podcast_shared_badge: "Shared in the federation", "Опубликован в федерации";
player_podcast_share_private: "Private: only your own devices see this subscription. Sharing publishes the podcast card (title, description, artwork, feed URL) from this server so that other federation members can find it and subscribe. Your progress, history and account are never published.", "Приватно: подписку видят только ваши устройства. «Поделиться» публикует карточку подкаста (название, описание, обложку, адрес RSS-ленты) от имени этого сервера, чтобы другие участники федерации могли найти его и подписаться. Ваш прогресс, история и аккаунт не публикуются.";
player_podcast_share_published: "Published: other federation members can find this podcast and subscribe. Your progress, history and account stay private.", "Опубликовано: участники федерации могут найти этот подкаст и подписаться. Ваш прогресс, история и аккаунт остаются приватными.";
player_podcast_share_publishing: "Shared: the server is publishing the card…", "Включено: сервер публикует карточку…";
player_podcast_share_discovery_off: "Shared: the card will be published when federation is enabled on this server.", "Включено: карточка будет опубликована, когда на этом сервере включат федерацию.";
player_podcast_share_pending: "Sharing is on, but the feed URL may contain private data. It is not published until you confirm.", "Публикация включена, но адрес ленты может содержать личные данные. Пока вы не подтвердите, он не публикуется.";
player_podcast_share_review: "Review and publish", "Проверить и опубликовать";
player_podcast_share_unavailable: "This podcast cannot be published", "Этот подкаст нельзя опубликовать";
player_podcast_share_dialog_title: "Publish this feed URL?", "Опубликовать адрес ленты?";
player_podcast_share_dialog_text: "The podcast card is visible to everyone in the federation, and anyone can subscribe with its feed URL. This URL may contain private data:", "Карточку подкаста увидят все участники федерации, и любой сможет подписаться по адресу ленты. Похоже, этот адрес содержит личные данные:";
player_podcast_share_dialog_hint: "If this is a personal feed (for example, a paid or member subscription), do not publish it: others could use your access.", "Если это личная лента (например, платная подписка или лента для участников), не публикуйте её: другие смогут воспользоваться вашим доступом.";
player_podcast_share_dialog_confirm: "Publish anyway", "Всё равно опубликовать";
player_podcast_warning_secret_query: "the query parameter «{name}» looks like an access key", "параметр «{name}» похож на ключ доступа";
player_podcast_warning_private_host: "{host} usually serves personal subscriber feeds", "{host} обычно отдаёт личные ленты подписчиков";
player_podcast_warning_entropy_query: "the value of the parameter «{name}» looks like a secret token", "значение параметра «{name}» похоже на секретный токен";
player_podcast_warning_entropy_path: "a part of the address looks like a secret token", "часть адреса похожа на секретный токен";
player_podcast_warning_other: "the address looks like a personal feed", "адрес похож на личную ленту";
player_podcast_all_seasons: "All seasons", "Все сезоны";
player_podcast_season: "Season", "Сезон";
player_podcast_no_season: "No season", "Без сезона";
+23
View File
@@ -48,6 +48,29 @@
</div>
</template>
<!-- Podcast: confirm publishing a feed URL that looks private -->
<template x-if="$store.podcasts.shareDialog">
<div class="modal-overlay" @click.self="$store.podcasts.cancelShare()" @keydown.escape.window="$store.podcasts.cancelShare()">
<div class="modal-box podcast-share-dialog" role="dialog" aria-modal="true" aria-labelledby="podcast-share-dialog-title">
<h3 id="podcast-share-dialog-title">{{ t.player_podcast_share_dialog_title }}</h3>
<p class="podcast-share-dialog-title" x-text="$store.podcasts.shareDialog.title"></p>
<p>{{ t.player_podcast_share_dialog_text }}</p>
<ul class="podcast-share-warnings">
<template x-for="(warning, index) in $store.podcasts.shareDialog.warnings" :key="index">
<li x-text="$store.podcasts.warningText(warning)"></li>
</template>
</ul>
<div class="podcast-share-url" x-text="$store.podcasts.shareDialog.feed_url"></div>
<div class="podcast-share-url" x-show="$store.podcasts.shareDialog.id_feed_url" x-text="$store.podcasts.shareDialog.id_feed_url"></div>
<p class="podcast-share-hint">{{ t.player_podcast_share_dialog_hint }}</p>
<div class="modal-footer">
<button class="modal-btn modal-btn-ghost" x-init="$nextTick(() => $el.focus())" @click="$store.podcasts.cancelShare()">{{ t.player_cancel }}</button>
<button class="modal-btn modal-btn-danger" @click="$store.podcasts.confirmShare()">{{ t.player_podcast_share_dialog_confirm }}</button>
</div>
</div>
</div>
</template>
<!-- Create / Rename Playlist Modal -->
<template x-if="$store.playlists.modal">
<div class="modal-overlay" @click.self="$store.playlists.modal = null">
+113
View File
@@ -75,6 +75,17 @@ const T = {
podcastFetchError: "{{ t.player_podcast_fetch_error }}",
podcastNextCheck: "{{ t.player_podcast_next_check }}",
podcastUnsubscribeConfirm: "{{ t.player_podcast_unsubscribe_confirm }}",
podcastSharePrivate: "{{ t.player_podcast_share_private }}",
podcastSharePublished: "{{ t.player_podcast_share_published }}",
podcastSharePublishing: "{{ t.player_podcast_share_publishing }}",
podcastShareDiscoveryOff: "{{ t.player_podcast_share_discovery_off }}",
podcastSharePending: "{{ t.player_podcast_share_pending }}",
podcastShareUnavailable: "{{ t.player_podcast_share_unavailable }}",
podcastWarningSecretQuery: "{{ t.player_podcast_warning_secret_query }}",
podcastWarningPrivateHost: "{{ t.player_podcast_warning_private_host }}",
podcastWarningEntropyQuery: "{{ t.player_podcast_warning_entropy_query }}",
podcastWarningEntropyPath: "{{ t.player_podcast_warning_entropy_path }}",
podcastWarningOther: "{{ t.player_podcast_warning_other }}",
podcastSeason: "{{ t.player_podcast_season }}",
podcastNoSeason: "{{ t.player_podcast_no_season }}",
podcastLeft: "{{ t.player_podcast_left }}",
@@ -3677,6 +3688,10 @@ document.addEventListener('alpine:init', () => {
refreshing: false,
refreshMessage: '',
actionError: '',
share: null,
sharing: false,
shareError: '',
shareDialog: null,
busy: {},
expanded: {},
_searchTimer: null,
@@ -3761,9 +3776,12 @@ document.addEventListener('alpine:init', () => {
this.sort = 'newest';
this.query = '';
this.expanded = {};
this.share = null;
this.shareDialog = null;
}
this.refreshMessage = '';
this.actionError = '';
this.shareError = '';
this.detailError = '';
this._enterView('podcast_detail', '#podcast?id=' + encodeURIComponent(podcastId), options);
this.loadDetail(podcastId);
@@ -3777,6 +3795,7 @@ document.addEventListener('alpine:init', () => {
const data = await this._json(`/api/podcasts/feeds/${podcastId}`);
if (token !== this._detailToken) return;
this.current = data.podcast;
this.share = data.share || null;
this.seasons = Array.isArray(data.seasons) ? data.seasons : [];
this.history = Array.isArray(data.history) ? data.history : [];
this.detailError = '';
@@ -3849,6 +3868,8 @@ document.addEventListener('alpine:init', () => {
try {
this.current = await this._json(`/api/podcasts/feeds/${podcast.podcast_id}/unsubscribe`, { method: 'POST' });
this.loadList();
// Unsubscribing also revokes sharing.
this.loadDetail(podcast.podcast_id);
} catch (error) {
this.actionError = error.message;
}
@@ -3861,11 +3882,103 @@ document.addEventListener('alpine:init', () => {
try {
this.current = await this._json(`/api/podcasts/feeds/${podcast.podcast_id}/subscribe`, { method: 'POST' });
this.loadList();
// A new subscription is private until shared again.
this.loadDetail(podcast.podcast_id);
} catch (error) {
this.actionError = error.message;
}
},
// Sharing in the federation: the account's synced decision; the
// server's node publishes the card. A feed URL that looks private
// (token in the query, member-feed host...) is published only after
// the user confirms exactly the URLs shown in the dialog.
toggleShare() {
const share = this.share;
if (!this.current || !share || this.sharing) return;
if (share.shared) return this._setShare(false);
if (Array.isArray(share.warnings) && share.warnings.length) return this.reviewShare();
return this._setShare(true);
},
reviewShare(share = this.share) {
const podcast = this.current;
if (!podcast || !share || !share.feed_url) return;
this.shareDialog = {
podcastId: podcast.podcast_id,
title: podcast.title,
warnings: Array.isArray(share.warnings) ? share.warnings : [],
feed_url: share.feed_url,
id_feed_url: share.id_feed_url || null,
};
},
cancelShare() {
this.shareDialog = null;
},
confirmShare() {
const dialog = this.shareDialog;
this.shareDialog = null;
if (!dialog || this.current?.podcast_id !== dialog.podcastId) return;
return this._setShare(true, { feed_url: dialog.feed_url, id_feed_url: dialog.id_feed_url });
},
async _setShare(shared, confirm = null) {
const podcastId = this.current?.podcast_id;
if (!podcastId || this.sharing) return;
this.sharing = true;
this.shareError = '';
try {
const body = { shared };
if (confirm) body.confirm = confirm;
const res = await fetch(`/api/podcasts/feeds/${podcastId}/share`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
let data = null;
try { data = await res.json(); } catch {}
if (this.current?.podcast_id !== podcastId) return;
if (res.status === 409 && data?.needs_confirmation && data.share) {
// The URLs changed (or were never confirmed): ask about
// what the server would publish now.
this.share = data.share;
this.reviewShare(data.share);
} else if (!res.ok) {
throw new Error(data?.error || T.podcastRequestFailed);
} else {
if (data?.podcast) this.current = data.podcast;
this.share = data?.share || this.share;
this.loadList();
}
} catch (error) {
if (this.current?.podcast_id === podcastId) this.shareError = error.message;
} finally {
this.sharing = false;
}
},
shareStatus() {
const share = this.share;
if (!share) return '';
if (!share.shared) return share.card_error ? T.podcastShareUnavailable : T.podcastSharePrivate;
if (share.pending_confirmation) return T.podcastSharePending;
if (share.discovery !== 'running') return T.podcastShareDiscoveryOff;
return share.published ? T.podcastSharePublished : T.podcastSharePublishing;
},
warningText(warning) {
const name = warning?.name || '';
switch (warning?.reason) {
case 'secret_query_parameter': return T.podcastWarningSecretQuery.replace('{name}', name);
case 'private_feed_host': return T.podcastWarningPrivateHost.replace('{host}', warning.host || '');
case 'high_entropy_query_value': return T.podcastWarningEntropyQuery.replace('{name}', name);
case 'high_entropy_path_segment': return T.podcastWarningEntropyPath;
default: return T.podcastWarningOther;
}
},
jamBlocked() {
// A Jam guest controls the host's queue: episodes are private.
return !!Alpine.store('devices')?.isControllingRemoteJam?.();
+24
View File
@@ -762,6 +762,7 @@
<div class="card-subtitle" x-text="podcast.author || ''"></div>
<div class="card-subtitle" x-text="$store.podcasts.podcastCounts(podcast)"></div>
<div class="card-subtitle podcast-unsubscribed-label" x-show="!podcast.subscribed" x-cloak>{{ t.player_podcast_unsubscribed }}</div>
<div class="card-subtitle podcast-shared-label" x-show="podcast.subscribed && podcast.shared" x-cloak>{{ t.player_podcast_shared_badge }}</div>
<div class="card-subtitle podcast-fetch-error"
x-show="podcast.fetch && podcast.fetch.last_error"
x-cloak
@@ -824,6 +825,17 @@
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 11-3-6.7L21 8"/><path d="M21 3v5h-5"/></svg>
<span x-text="$store.podcasts.refreshing ? '{{ t.player_podcast_refreshing }}' : '{{ t.player_podcast_refresh }}'"></span>
</button>
<button class="release-action-btn secondary podcast-share-toggle"
x-show="$store.podcasts.current.subscribed && $store.podcasts.share"
x-cloak
:class="{ active: $store.podcasts.share && $store.podcasts.share.shared }"
:aria-pressed="$store.podcasts.share && $store.podcasts.share.shared ? 'true' : 'false'"
:disabled="$store.podcasts.sharing || !$store.podcasts.share || (!$store.podcasts.share.shared && !$store.podcasts.share.can_share)"
:title="$store.podcasts.share && $store.podcasts.share.card_error ? '{{ t.player_podcast_share_unavailable }}' : ''"
@click="$store.podcasts.toggleShare()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.6" y1="13.5" x2="15.4" y2="17.5"/><line x1="15.4" y1="6.5" x2="8.6" y2="10.5"/></svg>
<span x-text="$store.podcasts.sharing ? '{{ t.player_podcast_sharing }}' : ($store.podcasts.share && $store.podcasts.share.shared ? '{{ t.player_podcast_unshare }}' : '{{ t.player_podcast_share }}')"></span>
</button>
<button class="release-action-btn secondary podcast-unsubscribe"
x-show="$store.podcasts.current.subscribed"
@click="$store.podcasts.unsubscribe()">
@@ -836,6 +848,18 @@
<span>{{ t.player_podcast_subscribe }}</span>
</button>
</div>
<div class="podcast-share-status"
x-show="$store.podcasts.current.subscribed && $store.podcasts.share"
x-cloak
:class="{ pending: $store.podcasts.share && $store.podcasts.share.pending_confirmation }">
<span x-text="$store.podcasts.shareStatus()"></span>
<button class="podcast-share-review"
type="button"
x-show="$store.podcasts.share && $store.podcasts.share.pending_confirmation"
:disabled="$store.podcasts.sharing"
@click="$store.podcasts.reviewShare()">{{ t.player_podcast_share_review }}</button>
</div>
<div class="podcast-message error" x-show="$store.podcasts.shareError" x-cloak x-text="$store.podcasts.shareError"></div>
<div class="podcast-message" x-show="$store.podcasts.refreshMessage" x-cloak x-text="$store.podcasts.refreshMessage"></div>
<div class="podcast-message error" x-show="$store.podcasts.actionError" x-cloak x-text="$store.podcasts.actionError"></div>
</div>
+50
View File
@@ -7097,6 +7097,56 @@ button.user-stat:hover {
text-align: center;
}
.podcast-unsubscribed-label { color: var(--text-subdued); }
.podcast-shared-label { color: var(--accent); }
.podcast-share-toggle.active {
border-color: var(--accent);
color: var(--accent);
}
.podcast-share-status {
font-size: 12px;
color: var(--text-secondary);
margin: 6px 0 4px;
max-width: 720px;
line-height: 1.45;
}
.podcast-share-status.pending { color: #f0b84d; }
.podcast-share-review {
margin-left: 8px;
background: transparent;
border: 1px solid currentColor;
border-radius: 12px;
color: inherit;
cursor: pointer;
font: inherit;
padding: 1px 8px;
}
.podcast-share-dialog { max-width: 520px; }
.podcast-share-dialog p {
color: var(--text-secondary);
font-size: 13px;
line-height: 1.5;
margin: 8px 0;
}
.podcast-share-dialog .podcast-share-dialog-title {
color: var(--text-primary);
font-weight: 600;
}
.podcast-share-warnings {
color: #f0b84d;
font-size: 13px;
margin: 4px 0 8px 18px;
}
.podcast-share-url {
background: var(--bg-elevated);
border-radius: 6px;
color: var(--text-primary);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px;
margin: 4px 0;
padding: 6px 8px;
word-break: break-all;
}
.podcast-share-dialog .podcast-share-hint { color: var(--text-subdued); }
.podcast-header-info { min-width: 0; }
.podcast-description {
color: var(--text-secondary);
+88 -2
View File
@@ -786,7 +786,7 @@ test('a mirrored Jam state never plays or saves an episode', async () => {
// Podcasts store
// ---------------------------------------------------------------------------
function podcastsStore(stores = {}) {
function podcastsStore(stores = {}, overrides = {}) {
const start = template.indexOf(" Alpine.store('podcasts', {");
assert.ok(start >= 0);
const open = template.indexOf('{', start);
@@ -800,9 +800,14 @@ function podcastsStore(stores = {}) {
podcastJamBlocked: 'jam blocked', podcastRequestFailed: 'request failed',
},
URLSearchParams, GUEST: false,
fetch: async (url, init = {}) => { calls.push({url, init}); return {ok: true, json: async () => ({})}; },
fetch: async (url, init = {}) => {
calls.push({url, init});
if (overrides.respond) return overrides.respond(url, init);
return {ok: true, json: async () => ({})};
},
Alpine: {store: name => stores[name]},
});
Object.assign(context.T, overrides.T || {});
vm.runInContext('this.store = ' + template.slice(open, end + 6) + ';', context);
return {store: context.store, calls};
}
@@ -839,6 +844,87 @@ test('the podcasts store formats episodes and builds list queries', () => {
assert.equal(store._episodeQuery(0), 'limit=50&offset=0');
});
test('sharing a feed URL that looks private asks first and sends back exactly the shown URLs', async () => {
const secret = 'https://members.example/feed.xml?token=8f3a9c2e7d1b4a6f';
const warnings = [{reason: 'secret_query_parameter', name: 'token'}];
const privateShare = {
shared: false, pending_confirmation: false, can_share: true, card_error: null, warnings,
feed_url: secret, id_feed_url: null, discovery: 'running', published: false,
};
const answers = [];
const {store, calls} = podcastsStore({}, {
T: {
podcastSharePrivate: 'private', podcastSharePublished: 'published', podcastSharePublishing: 'publishing',
podcastShareDiscoveryOff: 'discovery off', podcastSharePending: 'pending', podcastShareUnavailable: 'unavailable',
podcastWarningSecretQuery: 'parameter «{name}»', podcastWarningPrivateHost: 'host {host}',
podcastWarningEntropyQuery: 'value «{name}»', podcastWarningEntropyPath: 'path', podcastWarningOther: 'other',
},
respond: async () => answers.shift(),
});
store.current = {podcast_id: 'pod1:x', title: 'Members Only', subscribed: true};
store.share = privateShare;
store.loadList = () => {};
assert.equal(store.shareStatus(), 'private');
assert.equal(store.warningText(warnings[0]), 'parameter «token»');
assert.equal(store.warningText({reason: 'private_feed_host', host: 'patreon.com'}), 'host patreon.com');
assert.equal(store.warningText({reason: 'something_new'}), 'other');
// The toggle opens the dialog instead of sharing.
store.toggleShare();
assert.equal(calls.length, 0);
assert.deepEqual(JSON.parse(JSON.stringify(store.shareDialog)), {
podcastId: 'pod1:x', title: 'Members Only', warnings, feed_url: secret, id_feed_url: null,
});
store.cancelShare();
assert.equal(store.shareDialog, null);
assert.equal(calls.length, 0);
// The feed moved meanwhile: the server asks about the new URL.
const moved = Object.assign({}, privateShare, {feed_url: secret + '&v=2', id_feed_url: secret});
answers.push({ok: false, status: 409, json: async () => ({error: 'confirm', needs_confirmation: true, share: moved})});
store.toggleShare();
await store.confirmShare();
assert.equal(calls.length, 1);
assert.equal(calls[0].url, '/api/podcasts/feeds/pod1:x/share');
assert.equal(calls[0].init.headers['Content-Type'], 'application/json');
assert.deepEqual(JSON.parse(calls[0].init.body), {shared: true, confirm: {feed_url: secret, id_feed_url: null}});
assert.equal(store.shareDialog.feed_url, secret + '&v=2');
assert.equal(store.shareDialog.id_feed_url, secret);
assert.equal(store.shareError, '');
const published = Object.assign({}, moved, {shared: true, published: true});
answers.push({ok: true, status: 200, json: async () => ({podcast: {podcast_id: 'pod1:x', title: 'Members Only', subscribed: true, shared: true}, share: published})});
await store.confirmShare();
assert.deepEqual(JSON.parse(calls[1].init.body), {
shared: true, confirm: {feed_url: secret + '&v=2', id_feed_url: secret},
});
assert.equal(store.shareDialog, null);
assert.equal(store.shareStatus(), 'published');
assert.equal(store.sharing, false);
// Turning it off needs no confirmation.
answers.push({ok: true, status: 200, json: async () => ({podcast: store.current, share: privateShare})});
await store.toggleShare();
assert.deepEqual(JSON.parse(calls[2].init.body), {shared: false});
assert.equal(store.shareStatus(), 'private');
// States of the status line.
store.share = Object.assign({}, privateShare, {shared: true, pending_confirmation: true});
assert.equal(store.shareStatus(), 'pending');
store.share = Object.assign({}, privateShare, {shared: true, discovery: 'off'});
assert.equal(store.shareStatus(), 'discovery off');
store.share = Object.assign({}, privateShare, {shared: true});
assert.equal(store.shareStatus(), 'publishing');
// A public feed is shared directly; a failure is shown.
store.share = Object.assign({}, privateShare, {warnings: []});
answers.push({ok: false, status: 409, json: async () => ({error: 'not subscribed'})});
await store.toggleShare();
assert.deepEqual(JSON.parse(calls[3].init.body), {shared: true});
assert.equal(store.shareError, 'not subscribed');
assert.equal(store.shareDialog, null);
});
test('playing an episode from the list puts it next in the queue', () => {
const played = [];
const queue = {