feat: Likes and reposts (v2.5.0)
Build Container / build (push) Successful in 6s

Micropub like-of/repost-of with optional comment; likes on /likes, off the
home page and feeds; reposts in the stream. Native favourites/boosts on
GoToSocial and likes/reposts/quotes on Bluesky when the target is on that
network, link posts for other reposts. Fix double slash in outgoing
webmention source URLs. ADR-068.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-10-31 20:16:21 -06:00
1 parent 0d3a5cd519
commit e8c1b03980
21 files changed
+621 -49

No files matched your search

+26 -4
View File
@@ -296,16 +296,21 @@ def extract_post_status(properties: dict) -> bool:
raise MicropubValidationError(f"Unsupported post-status: {status}")
def extract_in_reply_to(properties: dict) -> Optional[str]:
value = _first(properties.get("in-reply-to"))
def extract_url_property(properties: dict, name: str) -> Optional[str]:
"""A URL property (in-reply-to, like-of, repost-of): string or h-cite"""
value = _first(properties.get(name))
if isinstance(value, dict): # h-cite
value = _first((value.get("properties") or {}).get("url")) or value.get("value")
value = (value or "").strip() if isinstance(value, str) else ""
if value and not value.startswith(("http://", "https://")):
raise MicropubValidationError("in-reply-to must be an http(s) URL")
raise MicropubValidationError(f"{name} must be an http(s) URL")
return value or None
def extract_in_reply_to(properties: dict) -> Optional[str]:
return extract_url_property(properties, "in-reply-to")
def extract_photos(properties: dict) -> list[dict[str, str]]:
"""
Extract photo URLs and alt text from Micropub properties
@@ -516,7 +521,16 @@ def handle_create(data: dict, token_info: dict, files=None):
try:
properties = normalize_properties(data)
content = extract_content(properties)
like_of = extract_url_property(properties, "like-of")
repost_of = extract_url_property(properties, "repost-of")
if like_of and repost_of:
raise MicropubValidationError("A post can't be both a like and a repost")
# Likes and reposts may come without a comment (v2.5.0)
has_content = any(
(c.strip() if isinstance(c, str) else (c.get("text") or c.get("html") or "").strip())
for c in properties.get("content", []) if c
)
content = extract_content(properties) if has_content or not (like_of or repost_of) else ""
title = extract_title(properties)
tags = extract_tags(properties)
published_date = extract_published_date(properties)
@@ -537,6 +551,8 @@ def handle_create(data: dict, token_info: dict, files=None):
custom_slug=custom_slug,
tags=tags if tags else None,
in_reply_to=in_reply_to,
like_of=like_of,
repost_of=repost_of,
)
if photos:
@@ -705,6 +721,10 @@ def note_to_mf2(note, wanted: Optional[list] = None) -> dict:
props["category"] = [tag["display_name"] for tag in note.tags]
if getattr(note, "in_reply_to", None):
props["in-reply-to"] = [note.in_reply_to]
if getattr(note, "like_of", None):
props["like-of"] = [note.like_of]
if getattr(note, "repost_of", None):
props["repost-of"] = [note.repost_of]
photos = _note_photos(note)
if photos:
props["photo"] = [{"value": p["url"], "alt": p["alt"]} for p in photos]
@@ -768,6 +788,8 @@ def handle_query(args, token_info: dict):
{"type": "article", "name": "Article", "properties": ["name", "content"]},
{"type": "photo", "name": "Photo", "properties": ["photo"]},
{"type": "reply", "name": "Reply", "properties": ["in-reply-to", "content"]},
{"type": "like", "name": "Like", "properties": ["like-of"]},
{"type": "repost", "name": "Repost", "properties": ["repost-of", "content"]},
],
}), 200