summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-13 19:03:43 -0700
committerAndrew Godwin2022-11-13 19:03:43 -0700
commitb5cacb09e3a8e9f04bbf92d179f9c2c96ea05011 (patch)
treef6a47114661122c4248e0132f1f5ba32f7ab9786 /activities
parentddb3436275d3f02183f515c38cd3193cd1dfe2f4 (diff)
downloadtakahe-b5cacb09e3a8e9f04bbf92d179f9c2c96ea05011.tar.gz
takahe-b5cacb09e3a8e9f04bbf92d179f9c2c96ea05011.tar.bz2
takahe-b5cacb09e3a8e9f04bbf92d179f9c2c96ea05011.zip
Permit Mastodon's weird HTML through
Diffstat (limited to 'activities')
-rw-r--r--activities/admin.py6
-rw-r--r--activities/models/post.py15
2 files changed, 21 insertions, 0 deletions
diff --git a/activities/admin.py b/activities/admin.py
index d4603a4..947a596 100644
--- a/activities/admin.py
+++ b/activities/admin.py
@@ -7,6 +7,12 @@ from activities.models import FanOut, Post, PostInteraction, TimelineEvent
class PostAdmin(admin.ModelAdmin):
list_display = ["id", "state", "author", "created"]
raw_id_fields = ["to", "mentions"]
+ actions = ["force_fetch"]
+
+ @admin.action(description="Force Fetch")
+ def force_fetch(self, request, queryset):
+ for instance in queryset:
+ instance.debug_fetch()
@admin.register(TimelineEvent)
diff --git a/activities/models/post.py b/activities/models/post.py
index d847307..74b335b 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -274,3 +274,18 @@ class Post(StatorModel):
TimelineEvent.add_post(follow.source, post)
# Force it into fanned_out as it's not ours
post.transition_perform(PostStates.fanned_out)
+
+ def debug_fetch(self):
+ """
+ Fetches the Post from its original URL again and updates us with it
+ """
+ response = httpx.get(
+ self.object_uri,
+ headers={"Accept": "application/json"},
+ follow_redirects=True,
+ )
+ if 200 <= response.status_code < 300:
+ return self.by_ap(
+ canonicalise(response.json(), include_security=True),
+ update=True,
+ )