Compare commits

...
6 Commits
Author SHA1 Message Date
Phil 81c730813c Merge branch 'fix/v2.13.3-count-opted-out' for v2.13.3 release
Build Container / build (push) Successful in 8m35s
2026-11-10 13:19:18 -07:00
PhilandClaude Opus 5.5 113f28aff1 fix: count opted-out likes and reposts without naming them (v2.13.3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:16:19 -07:00
Phil 76b81d6ad9 Merge branch 'fix/v2.13.2-reaction-counts' for v2.13.2 release
Build Container / build (push) Successful in 8m34s
2026-11-10 13:11:30 -07:00
PhilandClaude Opus 5.5 44f77a3adf feat: likes and reposts as a counts line with hover lists, web actions (v2.13.2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:11:29 -07:00
Phil b247de011d Merge branch 'fix/v2.13.1-avatar-fetch' for v2.13.1 release
Build Container / build (push) Successful in 8m33s
2026-11-10 12:56:11 -07:00
PhilandClaude Opus 5.5 65fc246d55 fix: save avatars from own GoToSocial and Bluesky PDSes (v2.13.1)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:56:04 -07:00
14 changed files with 398 additions and 114 deletions

No files matched your search

+24
View File
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [2.13.3] - 2026-11-10
### Changed
- Likes and reposts by people who opted out of backfeed (`#nobridge` or `#nobot` in their profile, or Bluesky's "don't show me to logged-out users" label) are counted in a note's totals, without their name or avatar ("+1 on Bluesky"). Before, they were left out entirely, so totals were lower than on the silo
## [2.13.2] - 2026-11-10
### Changed
- Likes, reposts and bookmarks are no longer rows of faces under "Responses". A note shows one line of counts under the post (♥ likes, 🔁 reposts, 💬 replies, bookmarks), and hovering or tapping a count lists who, with where each came from. Threads' anonymous counts are part of the totals ("+1 on Threads"), so the separate "On Threads" line is gone. The Responses section now holds replies, quotes and mentions
- Web actions (https://indieweb.org/webactions): each like, repost and reply count is an `<indie-action>` for the note, with links to do the same on the note's crossposts ("Like on Bluesky · GoToSocial · Threads"). The icons show even before anyone has responded, when the note has crossposts
### Fixed
- Avatars that GoToSocial hasn't cached (it redirects to the original server) are saved; the redirect is followed through the safe fetcher
## [2.13.1] - 2026-11-10
### Fixed
- Avatars from your own GoToSocial server are saved again. When StarPunk reaches it through the same proxy, its name resolves to an internal address, which the safe fetcher refused. That one server (`GOTOSOCIAL_URL`) is now fetched directly, as crossposting already does
- Bluesky avatars are saved again. Bluesky's image CDN refuses some servers' IPv4 addresses (HTTP 403), so avatars are now downloaded from the account's own server (`com.atproto.sync.getBlob`)
## [2.13.0] - 2026-11-10
Backfeed: responses to crossposts come back to the note (ADR-073).
+21
View File
@@ -223,6 +223,27 @@ Threads 2 (replies, insights), plus extra pages.
While at it, the Threads client moves from `graph.threads.net` to
`graph.threads.com`, the host Meta's current documentation uses.
## Amendments (v2.13.2, 2026-11-10)
- **Display.** Likes, reposts and bookmarks are a line of counts under the
note instead of facepiles in the Responses section. Hovering or focusing
a count lists the people (as `u-like` / `u-repost` / `u-bookmark`
h-cites) and the silo each came from. Threads' anonymous counts are added
to the totals ("+N on Threads") instead of a separate line (Decision 7).
- **Web actions.** Each like, repost and reply count is an
`<indie-action do="…" with="<permalink>">` whose fallback is a link to
the same action on each crosspost. No web-action polyfill is loaded;
handlers such as browser extensions can use the markup.
## Amendments (v2.13.3, 2026-11-10)
- **Opted-out people are counted.** Their likes, reposts and quotes are
still not stored or named (Decision 5), but each check records how many
there were on the copy's `syndications` row (`likes_count`,
`reposts_count`, `quotes_count`, the columns Threads' counts use), and
the counts line adds them to the totals as "N on <silo>". Totals then
match the silo.
## Consequences
- Responses on all three silos show on the note within 15 minutes for new
+13 -1
View File
@@ -21,7 +21,7 @@ is in `../architecture/`; decisions are in `../decisions/` (ADRs).
## Contents
[v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [hotfix](#hotfix)
[v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [v2.13.1](#v2131) · [v2.13.2](#v2132) · [v2.13.3](#v2133) · [hotfix](#hotfix)
## v1.0.0
@@ -426,6 +426,18 @@ OIDC admin login and built-in IndieAuth server.
- [2026-11-10-backfeed.md](v2.13.0/2026-11-10-backfeed.md) - Backfeed of responses to crossposts (ADR-073), avatar cache, delete tombstones
## v2.13.1
- [2026-11-10-avatar-fetch.md](v2.13.1/2026-11-10-avatar-fetch.md) - Avatars from the own GoToSocial server and from Bluesky PDSes
## v2.13.2
- [2026-11-10-reaction-counts.md](v2.13.2/2026-11-10-reaction-counts.md) - Likes/reposts as a counts line with hover lists; web actions
## v2.13.3
- [2026-11-10-count-opted-out.md](v2.13.3/2026-11-10-count-opted-out.md) - Opted-out people's likes and reposts counted without names
## hotfix
Not a release folder.
@@ -0,0 +1,33 @@
# v2.13.1: Avatar fetching in production
## Problem
After deploying v2.13.0, backfeed stored responses but no avatar was saved:
- GoToSocial avatars (`https://social.../fileserver/...`):
`SSRFBlockedError: Blocked request to private IP: 172.20.0.5`. Inside the
container the GoToSocial host resolves to the reverse proxy's internal
address (the deployment's hairpin `extra_hosts` entry).
- Bluesky avatars (`https://cdn.bsky.app/img/avatar/...`): HTTP 403 from
BunnyCDN. From the server, the CDN answers 403 over IPv4 and 200 over
IPv6; the container has no IPv6 route. From elsewhere IPv4 works.
## Fix (`starpunk/avatars.py`, `_download`)
- The host of `GOTOSOCIAL_URL` is fetched with a plain HTTP client (no
redirects, 1 MB limit), as `MastodonClient` already talks to it. Every
other host still goes through `safe_get`, so private addresses stay
blocked.
- `cdn.bsky.app/img/<kind>/plain/<did>/<cid>` URLs are fetched from the
account's PDS with `com.atproto.sync.getBlob`; the PDS comes from the DID
document (`plc.directory` for `did:plc`, `/.well-known/did.json` for
`did:web`). Both requests use `safe_get`. The cache file is still named
after the original URL.
## Verification
- `tests/test_backfeed.py::test_avatars_from_own_gotosocial_and_bluesky_pds`:
own GoToSocial on a private address is fetched, a Bluesky CDN URL is
fetched from its PDS, another private address is still refused.
- Checked against the real PLC directory and a bsky.network PDS.
- From the production server: getBlob over IPv4 returns the image (200).
@@ -0,0 +1,32 @@
# v2.13.2: Reaction counts and web actions
## Why
With backfeed live, notes showed "5 Likes" and "1 Repost" headings over
rows of faces (blank until avatars were saved), plus a separate
"On Threads: 1 like" line. The owner asked for the usual presentation: a
flat count under the post, with who on hover. Web actions
(https://indieweb.org/webactions) fit the same line.
## What changed
- `templates/partials/responses.html`: `facepile` and `silo_counts` are
replaced by `reactions` / `reaction`. Each count is a focusable
`.reaction` with an SVG icon; its `.reaction-who` card lists the people
(avatar, name, silo) inside a scrollable `.reaction-people`, Threads'
anonymous counts, and an `<indie-action>` with links to the crossposts.
The reply count has no people list (replies are listed below).
- `templates/note.html`: the counts line follows the note's footer; the
Responses section shows only when there are replies, quotes or mentions.
- `static/css/style.css`: facepile styles replaced by `.reactions`; the card
opens on `:hover` and `:focus-within` (tap on touch screens).
- `starpunk/avatars.py`: a redirect from the own GoToSocial server (media it
hasn't cached) is followed through `safe_get`.
## Verification
- `tests/test_backfeed.py` (24 tests): totals include Threads' anonymous
count, `<indie-action>` and crosspost links present; redirected avatar
saved. Microformats, template and route tests pass.
- Rendered locally in headless Chromium in dark and light themes with the
like and reply cards open.
@@ -0,0 +1,22 @@
# v2.13.3: Count opted-out people without naming them
## Why
A note's Bluesky copy had 1 like on Bluesky and 0 on the note. The liker's
account has the `!no-unauthenticated` label, so backfeed skipped them
(ADR-073 Decision 5). Every other Bluesky copy's like and repost counts
matched what StarPunk had stored.
## Change
`backfeed.hidden_counts(harvest)`: the silo's own counts when it gives no
names (Threads), else the number of opted-out likes, reposts and quotes in
the harvest. `check()` stores it on the copy's `syndications` row, and the
counts line (v2.13.2) already adds those columns to the totals as
"N on <silo>". Opted-out people are still not stored.
## Verification
`tests/test_backfeed.py::test_people_who_opt_out_are_counted_not_named`:
label, `#nobot` and `#nobridge` opt-outs counted (2 likes, 1 repost), not
stored, not named on the page; totals include them.
+1 -1
View File
@@ -4,7 +4,7 @@
**Last Updated**: 2026-11-03 (v2.10.1)
StarPunk uses [Semantic Versioning 2.0.0](https://semver.org/):
`MAJOR.MINOR.PATCH`, currently **2.13.0**. Every release is a git tag
`MAJOR.MINOR.PATCH`, currently **2.13.3**. Every release is a git tag
`vX.Y.Z` and a `CHANGELOG.md` entry. Where the number is stored and how to
write the changelog entry is in
[version-implementation-guide.md](version-implementation-guide.md); the
+2 -2
View File
@@ -465,5 +465,5 @@ def create_app(config=None):
# Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details
__version__ = "2.13.0"
__version_info__ = (2, 13, 0)
__version__ = "2.13.3"
__version_info__ = (2, 13, 3)
+80 -7
View File
@@ -24,6 +24,9 @@ logger = logging.getLogger(__name__)
SIZE = 96
MAX_BYTES = 1024 * 1024
# Bluesky avatar on its CDN: .../img/<kind>/plain/<did>/<cid>[@jpeg]
BSKY_CDN_RE = re.compile(
r"^https://cdn\.bsky\.app/img/[a-z_]+/plain/(did:(?:plc|web):[A-Za-z0-9._:%-]+)/([a-z2-7]+)(?:@\w+)?$")
NAME_RE = re.compile(r"^[0-9a-f]{64}\.webp$")
CLEANUP_EVERY = 7 * 24 * 3600
@@ -56,14 +59,8 @@ def fetch(data_path, url: Optional[str], site_url: str) -> bool:
return True
from PIL import Image
from starpunk.webmention_ssrf import safe_get, user_agent
try:
result = safe_get(url, headers={"User-Agent": user_agent(site_url)},
max_bytes=MAX_BYTES, max_redirects=5, timeout=10.0, truncate=False)
if result.status_code >= 400:
raise ValueError(f"HTTP {result.status_code}")
with Image.open(io.BytesIO(result.content)) as image:
with Image.open(io.BytesIO(_download(url, site_url))) as image:
image.load()
image = image.convert("RGBA" if "A" in image.getbands() else "RGB")
side = min(image.size)
@@ -80,6 +77,82 @@ def fetch(data_path, url: Optional[str], site_url: str) -> bool:
return False
def _own_instance_host() -> Optional[str]:
"""Host of the GoToSocial server StarPunk posts to (it may resolve to an internal address)"""
from urllib.parse import urlparse
from flask import current_app
return urlparse(current_app.config.get("GOTOSOCIAL_URL") or "").hostname
def _get(url: str, headers: dict) -> bytes:
"""GET a public URL through the SSRF-safe fetcher"""
from starpunk.webmention_ssrf import safe_get
result = safe_get(url, headers=headers, max_bytes=MAX_BYTES, max_redirects=5,
timeout=10.0, truncate=False)
if result.status_code >= 400:
raise ValueError(f"HTTP {result.status_code}")
return result.content
def _pds(did: str, headers: dict) -> str:
"""The PDS that hosts a Bluesky account, from its DID document"""
if did.startswith("did:plc:"):
doc_url = f"https://plc.directory/{did}"
else: # did:web:<host>
doc_url = f"https://{did[len('did:web:'):]}/.well-known/did.json"
import json
for service in json.loads(_get(doc_url, headers)).get("service") or []:
if service.get("id", "").endswith("#atproto_pds") and service.get("serviceEndpoint"):
return service["serviceEndpoint"].rstrip("/")
raise ValueError(f"no PDS for {did}")
def _download(url: str, site_url: str) -> bytes:
"""
The avatar's bytes (v2.13.1):
- from StarPunk's own GoToSocial directly, as the crossposting client
does: behind the same proxy it resolves to an internal address, which
the SSRF-safe fetcher refuses;
- Bluesky CDN avatars from the account's PDS (com.atproto.sync.getBlob),
because the CDN refuses some servers' IPv4 addresses;
- anything else through the SSRF-safe fetcher.
"""
from urllib.parse import quote, urlparse
import httpx
from starpunk import webmention_ssrf
from starpunk.webmention_ssrf import user_agent
headers = {"User-Agent": user_agent(site_url)}
own = _own_instance_host()
if own and urlparse(url).hostname == own:
with httpx.Client(timeout=10.0, transport=webmention_ssrf.TRANSPORT) as http:
with http.stream("GET", url, headers=headers) as response:
if response.is_redirect:
# GoToSocial sends media it hasn't cached to the original
# server: that one is fetched like any outside URL (v2.13.2)
from urllib.parse import urljoin
return _get(urljoin(url, response.headers["location"]), headers)
if response.status_code >= 400:
raise ValueError(f"HTTP {response.status_code}")
data = b""
for chunk in response.iter_bytes():
data += chunk
if len(data) > MAX_BYTES:
raise ValueError("too large")
return data
match = BSKY_CDN_RE.match(url)
if match:
did, cid = match.groups()
url = (f"{_pds(did, headers)}/xrpc/com.atproto.sync.getBlob"
f"?did={quote(did, safe=':')}&cid={cid}")
return _get(url, headers)
def fill_missing(db_path, data_path, site_url: str, limit: int = 20) -> int:
"""Save avatars of shown responses that have no copy yet. Returns how many were tried."""
conn = sqlite3.connect(db_path)
+19 -3
View File
@@ -64,7 +64,9 @@ class Harvest:
"""What one check found. complete=False: some list was cut short."""
responses: List[Response]
complete: bool = True
counts: Optional[Dict[str, int]] = None # Threads likes/reposts/quotes
# Likes/reposts/quotes shown only as numbers: all of them on Threads
# (its API doesn't say who); elsewhere, those by people who opted out
counts: Optional[Dict[str, int]] = None
# --- Text -----------------------------------------------------------------
@@ -243,11 +245,25 @@ def _display_state(db, note_id: int) -> list:
)]
def hidden_counts(harvest: Harvest) -> Dict[str, int]:
"""
Likes, reposts and quotes to show only as numbers: the silo's own counts
when it gives no names (Threads), else those by people who opted out
(v2.13.3: they're counted, not named)
"""
if harvest.counts is not None:
return harvest.counts
hidden = [r.kind for r in harvest.responses if _opted_out(r)]
return {k: hidden.count(kind) for k, kind in
(("likes", "like"), ("reposts", "repost"), ("quotes", "quote"))}
def store(db, note_id: int, target_url: str, origin: str, harvest: Harvest) -> None:
"""
Upsert a check's responses for one note and silo. With a complete
harvest, that silo's responses for the note that weren't found are
marked invalid. Responses from people who opted out are removed.
marked invalid. Responses from people who opted out are removed (they
are counted instead, see `hidden_counts`).
"""
from starpunk.webmention_processor import _snippet
@@ -358,7 +374,7 @@ def check(row, target) -> None:
site = current_app.config["SITE_URL"].rstrip("/")
harvest = target.client.responses(row["remote_id"], row["remote_url"] or "")
store(db, row["note_id"], f"{site}/note/{row['note_slug']}", row["target"], harvest)
_store_counts(db, row["id"], harvest.counts)
_store_counts(db, row["id"], hidden_counts(harvest))
def process_due(limit: int = 3) -> int:
+27 -52
View File
@@ -343,63 +343,38 @@ small { display: block; margin-top: var(--spacing-xs); color: var(--color-text-l
color: var(--color-text-light);
}
/* Backfed responses and silo counts (v2.13.0) */
.webmention-via,
.silo-counts {
/* Backfed responses (v2.13.0) */
.webmention-via {
font-size: 0.875rem;
color: var(--color-text-light);
}
/* Facepile */
.facepile {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.facepile .face {
display: block;
width: 32px;
height: 32px;
border-radius: 50%;
overflow: hidden;
border: 2px solid var(--color-bg);
margin-left: -8px;
}
.facepile .face:first-child {
margin-left: 0;
}
.facepile .face > .h-card,
.facepile .face > .h-card > a {
display: block;
width: 100%;
height: 100%;
}
.facepile .face img {
width: 100%;
height: 100%;
object-fit: cover;
}
.facepile .face-initial {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
font-size: 14px;
font-weight: bold;
color: white;
}
.facepile .face-overflow {
margin-left: var(--spacing-xs);
font-size: 0.875rem;
color: var(--color-text-light);
/* Likes, reposts and bookmarks: counts with a hover list (v2.13.2) */
.reactions { display: flex; flex-wrap: wrap; gap: var(--spacing-md); margin-top: var(--spacing-sm); color: var(--color-text-light); font-size: 0.875rem; }
.reaction { position: relative; display: inline-flex; align-items: center; gap: 0.3rem; padding-bottom: 0.4rem; cursor: default; }
.reaction > svg { width: 1rem; height: 1rem; flex: none; }
.reaction:hover, .reaction:focus-within { color: var(--color-text); }
.reaction-like:hover > svg, .reaction-like:focus-within > svg { color: #e0245e; }
.reaction-repost:hover > svg, .reaction-repost:focus-within > svg { color: #17bf63; }
.reaction-who {
display: none; position: absolute; left: 0; top: 100%; z-index: 10;
flex-direction: column; gap: 0.4rem; min-width: 13rem; max-width: 20rem;
padding: var(--spacing-sm); background: var(--color-bg-alt); border: 1px solid var(--color-border);
border-radius: var(--border-radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.reaction:hover .reaction-who, .reaction:focus-within .reaction-who { display: flex; }
.reaction-title { font-weight: 600; color: var(--color-text); }
.reaction-people { display: flex; flex-direction: column; gap: 0.35rem; max-height: 14rem; overflow-y: auto; }
.reaction-person { display: flex; align-items: center; gap: 0.4rem; min-width: 0; line-height: 1.3; }
.reaction-person .h-card { display: flex; min-width: 0; }
.reaction-person .h-card a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--color-text); min-width: 0; }
.reaction-person .p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reaction-person img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.reaction-person .webmention-via { margin-left: auto; padding-left: 0.5rem; white-space: nowrap; }
.reaction-anon { color: var(--color-text-light); }
.reaction-elsewhere { display: block; margin-top: 0.15rem; padding-top: 0.4rem; border-top: 1px solid var(--color-border); color: var(--color-text-light); }
.reaction-elsewhere:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.reaction-elsewhere a { color: var(--color-link); }
/* Generic Mentions */
.webmention-mention {
+5 -24
View File
@@ -78,12 +78,15 @@
{% endif %}
</footer>
{{ responses.reactions(likes, reposts, replies, bookmarks, syndications, absolute_url_for('public.note', slug=note.slug)) }}
<nav class="note-nav">
<a href="/">← All notes</a>
</nav>
{# Webmentions section (v1.6.0 Phase 5) - only shown if approved webmentions exist #}
{% if webmentions %}
{# Webmentions section (v1.6.0 Phase 5): replies, quotes and mentions.
Likes, reposts and bookmarks are the counts line above (v2.13.2). #}
{% if replies or quotes or mentions %}
<section class="webmentions">
<h2>Responses</h2>
@@ -94,27 +97,6 @@
</div>
{% endif %}
{% if likes %}
<div class="webmention-group webmention-likes">
<h3>{{ likes|length }} {{ 'Like' if likes|length == 1 else 'Likes' }}</h3>
{{ responses.facepile(likes, 'u-like') }}
</div>
{% endif %}
{% if reposts %}
<div class="webmention-group webmention-reposts">
<h3>{{ reposts|length }} {{ 'Repost' if reposts|length == 1 else 'Reposts' }}</h3>
{{ responses.facepile(reposts, 'u-repost') }}
</div>
{% endif %}
{% if bookmarks %}
<div class="webmention-group webmention-bookmarks">
<h3>{{ bookmarks|length }} {{ 'Bookmark' if bookmarks|length == 1 else 'Bookmarks' }}</h3>
{{ responses.facepile(bookmarks, 'u-bookmark') }}
</div>
{% endif %}
{% if quotes %}
<div class="webmention-group webmention-quotes">
<h3>{{ quotes|length }} {{ 'Quote' if quotes|length == 1 else 'Quotes' }}</h3>
@@ -130,6 +112,5 @@
{% endif %}
</section>
{% endif %}
{{ responses.silo_counts(syndications) }}
</article>
{% endblock %}
+58 -23
View File
@@ -41,22 +41,6 @@
</article>
{%- endmacro %}
{# Likes, reposts or bookmarks as a facepile; prop is u-like / u-repost / u-bookmark.
Faces past `shown` are hidden on screen but kept for parsers. #}
{% macro facepile(items, prop, shown=8) %}
<div class="facepile">
{% for wm in items %}
<span class="face {{ prop }} h-cite"{% if loop.index > shown %} hidden{% endif %}>
{{ author_card(wm, photo_size=32, show_name=False) }}
<a class="u-url" href="{{ response_url(wm) }}" hidden>{{ response_time(wm) }}</a>
</span>
{% endfor %}
{% if items|length > shown %}
<span class="face-overflow">+{{ items|length - shown }} others</span>
{% endif %}
</div>
{%- endmacro %}
{# A post that mentions this note without replying; also quote posts (v2.13.0) #}
{% macro mention(wm) %}
<div class="webmention webmention-mention u-mention h-cite">
@@ -68,12 +52,63 @@
</div>
{%- endmacro %}
{# Like, repost and quote counts a silo reports without saying who (Threads,
v2.13.0). Plain text: these aren't people, so no u-like / h-cite. #}
{% macro silo_counts(syndications) %}
{% for s in syndications or [] if s.likes_count or s.reposts_count or s.quotes_count %}
{% set parts = [] %}
{% for n, one, many in [(s.likes_count, 'like', 'likes'), (s.reposts_count, 'repost', 'reposts'), (s.quotes_count, 'quote', 'quotes')] if n %}{% set _ = parts.append(n ~ ' ' ~ (one if n == 1 else many)) %}{% endfor %}
<p class="silo-counts">On {{ s.name }}: {{ parts|join(' · ') }}</p>
{# Likes, reposts, replies and bookmarks: one line of counts under the note,
like other sites (v2.13.2). Hovering or focusing a count lists who, and
offers the same action on the note's crossposts. Each action is an
<indie-action> (https://indieweb.org/webactions) with those silo links as
its fallback, so web action handlers can take over. Counts without names
(all of Threads; elsewhere people who opted out, v2.13.3) are added to the
total. The people stay in the
markup as u-like / u-repost / u-bookmark h-cites. #}
{% set ICONS = {
'like': '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>',
'repost': '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 1l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><path d="M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>',
'reply': '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 8.6 8.6 0 0 1-3.9-.9L3 21l1.9-5.1A8.4 8.4 0 0 1 12 3.1a8.4 8.4 0 0 1 9 8.4z"/></svg>',
'bookmark': '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 2h12a1 1 0 0 1 1 1v19l-7-4-7 4V3a1 1 0 0 1 1-1z"/></svg>',
} %}
{% set VERBS = {'like': 'Like', 'repost': 'Repost', 'reply': 'Reply'} %}
{% macro reaction(kind, items, prop, anon, one, many, copies=[], permalink='', people=True) %}
{% set ns = namespace(total=items|length) %}
{% for name, n in anon %}{% set ns.total = ns.total + n %}{% endfor %}
{% set verb = VERBS.get(kind) %}
{% if ns.total or (verb and copies) %}
<span class="reaction reaction-{{ kind }}" tabindex="0">
{{ ICONS[kind]|safe }}{% if ns.total %}<span class="reaction-count">{{ ns.total }}</span>{% endif %}<span class="visually-hidden"> {{ ns.total }} {{ one if ns.total == 1 else many }}</span>
<span class="reaction-who" role="tooltip">
{% if ns.total %}<span class="reaction-title">{{ ns.total }} {{ one if ns.total == 1 else many }}</span>{% endif %}
{% if (people and items) or anon %}
<span class="reaction-people">
{% if people %}
{% for wm in items %}
<span class="reaction-person {{ prop }} h-cite">{{ author_card(wm, photo_size=20) }}{% if wm.via %}<span class="webmention-via">{{ wm.via }}</span>{% endif %}<a class="u-url" href="{{ response_url(wm) }}" hidden>{{ response_time(wm) }}</a></span>
{% endfor %}
{% endif %}
{% for name, n in anon %}<span class="reaction-anon">{{ '+' if items and people else '' }}{{ n }} on {{ name }}</span>{% endfor %}
</span>
{% endif %}
{% if verb and copies %}
<indie-action class="reaction-elsewhere" do="{{ kind }}" with="{{ permalink }}">{{ verb }} on {% for s in copies %}<a href="{{ s.remote_url }}" rel="noopener">{{ s.name }}</a>{% if not loop.last %} · {% endif %}{% endfor %}</indie-action>
{% endif %}
</span>
</span>
{% endif %}
{%- endmacro %}
{% macro reactions(likes, reposts, replies, bookmarks, syndications, permalink) %}
{% set anon_likes, anon_reposts = [], [] %}
{% for s in syndications or [] %}
{% if s.likes_count %}{% set _ = anon_likes.append((s.name, s.likes_count)) %}{% endif %}
{% if s.reposts_count %}{% set _ = anon_reposts.append((s.name, s.reposts_count)) %}{% endif %}
{% endfor %}
{% set copies = (syndications or [])|selectattr('remote_url')|list %}
{% if copies or likes or reposts or replies or bookmarks or anon_likes or anon_reposts %}
<div class="reactions">
{{ reaction('like', likes or [], 'u-like', anon_likes, 'like', 'likes', copies, permalink) }}
{{ reaction('repost', reposts or [], 'u-repost', anon_reposts, 'repost', 'reposts', copies, permalink) }}
{# Replies are listed in full below; here just the count and where to reply #}
{{ reaction('reply', replies or [], '', [], 'reply', 'replies', copies, permalink, people=False) }}
{{ reaction('bookmark', bookmarks or [], 'u-bookmark', [], 'bookmark', 'bookmarks') }}
</div>
{% endif %}
{%- endmacro %}
+61 -1
View File
@@ -334,7 +334,11 @@ def test_note_page_shows_backfed_responses_quotes_and_counts(app, client, web):
page = app.test_client().get(f"/note/{note.slug}").get_data(as_text=True)
assert "via GoToSocial" in page
assert "1 Quote" in page and "Look at this" in page
assert 'class="silo-counts">On GoToSocial: 12 likes · 1 repost<' in page
# Likes and reposts are a counts line (v2.13.2): named likes plus the silo's anonymous count
assert '<span class="reaction-count">13</span>' in page and "+12 on GoToSocial" in page
assert '<span class="reaction-count">1</span>' in page
assert f'<indie-action class="reaction-elsewhere" do="like" with="{SITE}/note/{note.slug}">' in page
assert f'Like on <a href="{COPY}"' in page
assert 'src="/avatars/' in page and 'src="https://cdn.example/a.png"' not in page
@@ -562,3 +566,59 @@ def test_threads_avatar_kept_while_its_copy_exists(app, client, web):
client.harvest = Harvest([again])
run(app)
assert rows(app, note.id)[0]["author_photo"] == "https://cdn.example/p.jpg?sig=1"
def test_avatars_from_own_gotosocial_and_bluesky_pds(app, web, monkeypatch):
"""v2.13.1: own GoToSocial may resolve to a private address; Bluesky CDN avatars come from the PDS"""
did, cid = "did:plc:abc123", "bafkreiabc"
web.files[f"{GTS}/fileserver/a/avatar.png"] = png()
web.files[f"https://plc.directory/{did}"] = json.dumps(
{"service": [{"id": "#atproto_pds", "serviceEndpoint": "https://pds.example"}]}).encode()
web.files[f"https://pds.example/xrpc/com.atproto.sync.getBlob?did={did}&cid={cid}"] = png("blue")
real_resolve = resolve
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo",
lambda host, *a, **k: [(2, 1, 6, "", ("172.20.0.5", 0))]
if host == "social.example" else real_resolve(host))
data = app.config["DATA_PATH"]
with app.app_context():
assert avatars.fetch(data, f"{GTS}/fileserver/a/avatar.png", SITE)
assert avatars.fetch(data, f"https://cdn.bsky.app/img/avatar/plain/{did}/{cid}@jpeg", SITE)
# Other private addresses stay blocked
web.files["https://internal.example/a.png"] = png()
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo",
lambda host, *a, **k: [(2, 1, 6, "", ("10.0.0.5", 0))])
assert not avatars.fetch(data, "https://internal.example/a.png", SITE)
def test_own_gotosocial_redirect_to_remote_avatar_is_followed(app, web, monkeypatch):
"""v2.13.2: GoToSocial redirects uncached remote media to the original server"""
class Redirecting(FakeWeb):
def __call__(self, request):
url = f"{request.url.scheme}://{request.headers['host']}{request.url.raw_path.decode()}"
if url == f"{GTS}/fileserver/x/avatar.jpeg":
return httpx.Response(302, headers={"location": "https://remote.example/avatar.jpeg"})
return super().__call__(request)
fake = Redirecting()
fake.files["https://remote.example/avatar.jpeg"] = png()
monkeypatch.setattr("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(fake))
with app.app_context():
assert avatars.fetch(app.config["DATA_PATH"], f"{GTS}/fileserver/x/avatar.jpeg", SITE)
def test_people_who_opt_out_are_counted_not_named(app, client):
"""v2.13.3: likes and reposts by people who opted out add to the totals anonymously"""
note, sid = crossposted(app)
shy = like(5, opted_out=True)
client.harvest = Harvest([like(1), shy, like(6, bio="#nobot"),
Response(kind="repost", source_url=f"{COPY}#reposted-by-7", remote_id="7",
author_name="Quiet", author_bio="#nobridge")])
run(app)
with app.app_context():
s = get_db(app).execute("SELECT likes_count, reposts_count FROM syndications WHERE id = ?",
(sid,)).fetchone()
assert (s["likes_count"], s["reposts_count"]) == (2, 1)
assert [r["source_url"] for r in rows(app, note.id)] == [like(1).source_url]
page = app.test_client().get(f"/note/{note.slug}").get_data(as_text=True)
assert '<span class="reaction-count">3</span>' in page and "+2 on GoToSocial" in page
assert "Liker 5" not in page and "Quiet" not in page