Manage followers from the API and web UI (phase 2, step 6)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 2m4s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 2m4s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
- /api/v1/federation: list followers and requests, approve (Accept), decline or remove (Reject), block (Block, and future follows are refused), list and remove blocks; settings report follower counts - The actor now reflects the user's real follow-approval setting and the followers collection its accepted count - Turning sharing off sends every follower a Reject and forgets them; while those are being delivered the actor stays fetchable with just its key (no name or bio) so other servers can verify them, and WebFinger already says not found - Web UI: a Followers page (requests with Approve/Decline, followers with Remove/Block behind a confirm step, blocked accounts with Unblock; remote names shown as plain text only), follower counts on the Sharing page, and a confirmation before turning sharing off when that would remove followers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
142dc13fea
commit
a90cd14f59
12 files changed
+1083
-18
No files matched your search
@@ -945,3 +945,11 @@ input {
|
||||
.save-row {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.follower-summary {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.confirm-off .button-row {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Followers · Scrobbler</title>
|
||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<script src="config.js"></script>
|
||||
<script type="module" src="js/followers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="site-header" id="site-header"></header>
|
||||
<main id="main">
|
||||
<h1 class="page-title">Followers</h1>
|
||||
<p class="lede">People on the fediverse who follow your listening. <a href="sharing.html">Sharing settings</a></p>
|
||||
<div id="messages"></div>
|
||||
<section aria-labelledby="requests-title" id="requests-section" hidden>
|
||||
<h2 id="requests-title" class="section-head">Follow requests</h2>
|
||||
<ul class="rows" id="requests"></ul>
|
||||
</section>
|
||||
<section aria-labelledby="followers-title">
|
||||
<h2 id="followers-title" class="section-head">Followers</h2>
|
||||
<ul class="rows" id="followers"></ul>
|
||||
</section>
|
||||
<section aria-labelledby="blocks-title" id="blocks-section" hidden>
|
||||
<h2 id="blocks-title" class="section-head">Blocked</h2>
|
||||
<ul class="rows" id="blocks"></ul>
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,143 @@
|
||||
import { api } from "./api.js";
|
||||
import { errorBox, formatDate, h, replace, timeAgo } from "./dom.js";
|
||||
import { signedInPage } from "./layout.js";
|
||||
|
||||
const messages = document.getElementById("messages");
|
||||
|
||||
await signedInPage("sharing.html");
|
||||
await refresh();
|
||||
|
||||
async function refresh() {
|
||||
let followers, blocks;
|
||||
try {
|
||||
[followers, blocks] = await Promise.all([api("/federation/followers"), api("/federation/blocks")]);
|
||||
} catch (error) {
|
||||
replace(
|
||||
messages,
|
||||
error.status === 404
|
||||
? h("p", { class: "notice" }, "This server doesn't share to the fediverse.")
|
||||
: errorBox(error.message),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const requests = followers.filter((f) => f.state === "pending");
|
||||
const accepted = followers.filter((f) => f.state === "accepted");
|
||||
|
||||
document.getElementById("requests-section").hidden = requests.length === 0;
|
||||
replace(document.getElementById("requests"), requests.map(requestRow));
|
||||
replace(
|
||||
document.getElementById("followers"),
|
||||
accepted.length
|
||||
? accepted.map(followerRow)
|
||||
: h("li", { class: "empty" }, "No followers yet. People can follow you by searching for your handle."),
|
||||
);
|
||||
document.getElementById("blocks-section").hidden = blocks.length === 0;
|
||||
replace(document.getElementById("blocks"), blocks.map(blockRow));
|
||||
}
|
||||
|
||||
// Remote names and handles are shown as plain text only.
|
||||
function who(person) {
|
||||
return h(
|
||||
"span",
|
||||
{},
|
||||
h("span", { class: "row-title" }, person.display_name || person.handle),
|
||||
person.display_name ? h("span", { class: "muted" }, ` ${person.handle}`) : null,
|
||||
);
|
||||
}
|
||||
|
||||
async function act(path, done) {
|
||||
try {
|
||||
await api(path, { method: "POST" });
|
||||
replace(messages, h("p", { class: "notice notice-ok", role: "status" }, done));
|
||||
} catch (error) {
|
||||
replace(messages, errorBox(error.message));
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
function requestRow(follower) {
|
||||
return h(
|
||||
"li",
|
||||
{},
|
||||
h(
|
||||
"div",
|
||||
{ class: "row-head" },
|
||||
who(follower),
|
||||
h(
|
||||
"div",
|
||||
{ class: "confirm" },
|
||||
h(
|
||||
"button",
|
||||
{ type: "button", class: "button", onclick: () => act(`/federation/followers/${follower.id}/approve`, `${follower.handle} now follows you.`) },
|
||||
"Approve",
|
||||
),
|
||||
h(
|
||||
"button",
|
||||
{ type: "button", class: "button button-quiet", onclick: () => act(`/federation/followers/${follower.id}/decline`, `Declined ${follower.handle}.`) },
|
||||
"Decline",
|
||||
),
|
||||
),
|
||||
),
|
||||
h("p", { class: "muted", title: formatDate(follower.since) }, `Asked ${timeAgo(follower.since)}`),
|
||||
);
|
||||
}
|
||||
|
||||
function followerRow(follower) {
|
||||
const actions = h("div", { class: "confirm" });
|
||||
const reset = () =>
|
||||
replace(
|
||||
actions,
|
||||
h("button", { type: "button", class: "button button-quiet", onclick: askRemove }, "Remove"),
|
||||
h("button", { type: "button", class: "button button-quiet", onclick: askBlock }, "Block"),
|
||||
);
|
||||
const confirm = (question, label, path, done) =>
|
||||
replace(
|
||||
actions,
|
||||
h("span", { class: "muted" }, question),
|
||||
h("button", { type: "button", class: "button button-danger", onclick: () => act(path, done) }, label),
|
||||
h("button", { type: "button", class: "button button-quiet", onclick: reset }, "Cancel"),
|
||||
);
|
||||
const askRemove = () =>
|
||||
confirm(
|
||||
"They can follow you again later.",
|
||||
"Remove follower",
|
||||
`/federation/followers/${follower.id}/remove`,
|
||||
`Removed ${follower.handle}.`,
|
||||
);
|
||||
const askBlock = () =>
|
||||
confirm(
|
||||
"They're removed and can't follow you again.",
|
||||
"Block",
|
||||
`/federation/followers/${follower.id}/block`,
|
||||
`Blocked ${follower.handle}.`,
|
||||
);
|
||||
reset();
|
||||
return h(
|
||||
"li",
|
||||
{},
|
||||
h("div", { class: "row-head" }, who(follower), actions),
|
||||
h("p", { class: "muted", title: formatDate(follower.since) }, `Following since ${timeAgo(follower.since)}`),
|
||||
);
|
||||
}
|
||||
|
||||
function blockRow(block) {
|
||||
const unblock = async () => {
|
||||
try {
|
||||
await api(`/federation/blocks/${block.id}`, { method: "DELETE" });
|
||||
replace(messages, h("p", { class: "notice notice-ok", role: "status" }, `Unblocked ${block.handle}.`));
|
||||
} catch (error) {
|
||||
replace(messages, errorBox(error.message));
|
||||
}
|
||||
await refresh();
|
||||
};
|
||||
return h(
|
||||
"li",
|
||||
{},
|
||||
h(
|
||||
"div",
|
||||
{ class: "row-head" },
|
||||
who(block),
|
||||
h("button", { type: "button", class: "button button-quiet", onclick: unblock }, "Unblock"),
|
||||
),
|
||||
);
|
||||
}
|
||||
+51
-2
@@ -1,5 +1,5 @@
|
||||
import { api, describeError } from "./api.js";
|
||||
import { errorBox, h, replace } from "./dom.js";
|
||||
import { errorBox, h, num, replace } from "./dom.js";
|
||||
import { signedInPage } from "./layout.js";
|
||||
|
||||
const form = document.getElementById("sharing");
|
||||
@@ -40,6 +40,10 @@ function fill(values) {
|
||||
}
|
||||
}
|
||||
document.getElementById("handle").textContent = values.handle;
|
||||
const summary = document.getElementById("follower-summary");
|
||||
const parts = [`${num(values.followers)} ${values.followers === 1 ? "follower" : "followers"}`];
|
||||
if (values.pending_followers) parts.push(`${num(values.pending_followers)} waiting for approval`);
|
||||
replace(summary, parts.join(", "), ". ", h("a", { href: "followers.html" }, "See followers"));
|
||||
replace(
|
||||
document.getElementById("profile-link"),
|
||||
"Your public profile page: ",
|
||||
@@ -52,8 +56,50 @@ function showHandle(on) {
|
||||
handlePanel.hidden = !on;
|
||||
}
|
||||
|
||||
// Turning sharing off removes every follower, so it's confirmed first.
|
||||
function confirmTurningOff(followerCount) {
|
||||
return new Promise((resolve) => {
|
||||
const box = document.getElementById("confirm-off");
|
||||
const done = (answer) => {
|
||||
box.hidden = true;
|
||||
resolve(answer);
|
||||
};
|
||||
replace(
|
||||
box,
|
||||
h(
|
||||
"p",
|
||||
{},
|
||||
`Turning sharing off removes your ${num(followerCount)} ${followerCount === 1 ? "follower" : "followers"}. `,
|
||||
"Each is told, and they'd have to follow you again if you turn it back on.",
|
||||
),
|
||||
h(
|
||||
"div",
|
||||
{ class: "button-row" },
|
||||
h("button", { type: "button", class: "button button-danger", onclick: () => done(true) }, "Turn off sharing"),
|
||||
h(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
class: "button button-quiet",
|
||||
onclick: () => {
|
||||
form.elements.enabled.checked = true;
|
||||
showHandle(true);
|
||||
done(false);
|
||||
},
|
||||
},
|
||||
"Keep sharing",
|
||||
),
|
||||
),
|
||||
);
|
||||
box.hidden = false;
|
||||
box.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
});
|
||||
}
|
||||
|
||||
async function save(event) {
|
||||
event.preventDefault();
|
||||
const turningOff = settings.enabled && !form.elements.enabled.checked;
|
||||
if (turningOff && settings.followers > 0 && !(await confirmTurningOff(settings.followers))) return;
|
||||
const button = form.querySelector("button[type=submit]");
|
||||
const changes = {
|
||||
enabled: form.elements.enabled.checked,
|
||||
@@ -70,8 +116,11 @@ async function save(event) {
|
||||
replace(messages);
|
||||
try {
|
||||
const saved = await api("/federation/settings", { method: "PATCH", body: changes });
|
||||
settings = saved;
|
||||
fill(saved);
|
||||
status.textContent = saved.enabled ? `Saved. You're sharing as ${saved.handle}.` : "Saved. Sharing is off.";
|
||||
status.textContent = saved.enabled
|
||||
? `Saved. You're sharing as ${saved.handle}.`
|
||||
: "Saved. Sharing is off, and your followers have been told.";
|
||||
} catch (error) {
|
||||
status.textContent = "";
|
||||
replace(messages, errorBox(describeError(error)));
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<p class="display-status">Your fediverse handle</p>
|
||||
<p class="approve-app handle" id="handle"></p>
|
||||
<p class="muted">People can follow you by searching for this in their app. It can't be changed once people follow you.</p>
|
||||
<p class="notice">Following arrives in a coming update. Until then people can find your profile, and follows wait as requests.</p>
|
||||
<p class="follower-summary" id="follower-summary"></p>
|
||||
</div>
|
||||
|
||||
<fieldset class="choices">
|
||||
@@ -74,6 +74,7 @@
|
||||
<p class="muted" id="profile-link"></p>
|
||||
</fieldset>
|
||||
|
||||
<div class="notice notice-error confirm-off" id="confirm-off" role="alertdialog" aria-live="assertive" hidden></div>
|
||||
<div class="button-row save-row">
|
||||
<button class="button" type="submit">Save sharing settings</button>
|
||||
<span class="muted" id="save-status" role="status"></span>
|
||||
|
||||
Reference in new issue
Block a user