feat: backfeed of responses to crossposts (v2.13.0)
Likes, reposts, quotes and replies to a note's GoToSocial, Bluesky and Threads copies are read back from the silos and stored as webmentions (ADR-073): age-based schedule to 90 days, pruning of withdrawn responses, #nobridge/#nobot opt-outs, admin backfill and Check now, Threads counts, a Quotes group, local avatar copies, and delete tombstones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6aaac982d5
commit
55ce6a1fdd
27 files changed
+1763
-40
No files matched your search
@@ -5,7 +5,7 @@ Handles authenticated admin functionality including dashboard, note creation,
|
||||
editing, and deletion. All routes require authentication.
|
||||
"""
|
||||
|
||||
from flask import Blueprint, flash, g, jsonify, redirect, render_template, request, url_for
|
||||
from flask import Blueprint, current_app, flash, g, jsonify, redirect, render_template, request, url_for
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
@@ -259,6 +259,7 @@ def edit_note_form(note_id: int):
|
||||
syndication_targets=get_targets().values(),
|
||||
syndications=syndications,
|
||||
syndication_enabled=enabled,
|
||||
backfeed_enabled=current_app.config.get("BACKFEED_ENABLED", False),
|
||||
)
|
||||
|
||||
|
||||
@@ -496,18 +497,24 @@ def webmentions():
|
||||
from starpunk.webmention_queries import list_webmentions
|
||||
|
||||
status_filter = request.args.get('status')
|
||||
origin_filter = request.args.get('origin') or None
|
||||
page = int(request.args.get('page', 1))
|
||||
|
||||
webmentions, total_pages = list_webmentions(
|
||||
status_filter=status_filter,
|
||||
page=page,
|
||||
per_page=25
|
||||
per_page=25,
|
||||
origin_filter=origin_filter,
|
||||
)
|
||||
|
||||
from starpunk import backfeed
|
||||
|
||||
return render_template(
|
||||
"admin/webmentions.html",
|
||||
webmentions=webmentions,
|
||||
status_filter=status_filter,
|
||||
origin_filter=origin_filter,
|
||||
backfeed=backfeed.status(),
|
||||
page=page,
|
||||
total_pages=total_pages,
|
||||
user_me=g.me
|
||||
@@ -674,6 +681,28 @@ def revoke_token(token_id):
|
||||
return redirect(url_for("admin.tokens"))
|
||||
|
||||
|
||||
@bp.route("/backfeed/backfill", methods=["POST"])
|
||||
@require_auth
|
||||
def backfeed_backfill():
|
||||
"""Check every crosspost once for responses, whatever its age (v2.13.0)"""
|
||||
from starpunk import backfeed
|
||||
|
||||
count = backfeed.start_backfill()
|
||||
flash(f"Backfill started: {count} crosspost(s) to check", "success")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
|
||||
|
||||
@bp.route("/syndication/<int:syndication_id>/check", methods=["POST"])
|
||||
@require_auth
|
||||
def check_syndication_responses(syndication_id):
|
||||
"""Check one crosspost's responses at the next worker pass (v2.13.0)"""
|
||||
from starpunk import backfeed
|
||||
|
||||
backfeed.check_now(syndication_id)
|
||||
flash("Responses will be checked shortly", "success")
|
||||
return redirect(request.referrer or url_for("admin.dashboard"))
|
||||
|
||||
|
||||
@bp.route("/syndication/<int:syndication_id>/retry", methods=["POST"])
|
||||
@require_auth
|
||||
def retry_syndication(syndication_id):
|
||||
|
||||
@@ -250,6 +250,20 @@ def media_file(path):
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/avatars/<name>")
|
||||
def avatar(name: str):
|
||||
"""A saved copy of a response author's avatar (v2.13.0, ADR-073)"""
|
||||
from pathlib import Path
|
||||
from starpunk.avatars import NAME_RE, folder
|
||||
|
||||
if not NAME_RE.match(name):
|
||||
abort(404)
|
||||
response = send_from_directory(folder(Path(current_app.config.get('DATA_PATH', 'data'))), name)
|
||||
# Named by the hash of the original URL; a changed avatar gets a new name
|
||||
response.headers['Cache-Control'] = 'public, max-age=604800'
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/")
|
||||
def index():
|
||||
"""
|
||||
|
||||
@@ -258,7 +258,10 @@ def receive_webmention():
|
||||
ON CONFLICT(source_url, target_url) DO UPDATE SET
|
||||
validation_status = 'pending',
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE webmentions.origin = 'webmention'
|
||||
""", (source, target, target_note_id))
|
||||
# (A backfed response with the same URLs is StarPunk's own copy of
|
||||
# what the silo said; a webmention doesn't overwrite it. v2.13.0)
|
||||
db.commit()
|
||||
|
||||
current_app.logger.info(
|
||||
|
||||
Reference in new issue
Block a user