From 5182bb92f3b72d6b5a356f75750a0518012ad729 Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Tue, 17 Jan 2023 11:16:14 -0800 Subject: [PATCH] Mastodon interop: fill in the updated field for Updates if it's missing Mastodon requires it: https://docs.joinmastodon.org/spec/activitypub/#supported-activities-for-statuses https://socialhub.activitypub.rocks/t/what-could-be-the-reason-that-my-update-activity-does-not-work/2893/4 https://github.com/mastodon/documentation/pull/1150 --- tests/test_webmention.py | 4 ++++ webmention.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/tests/test_webmention.py b/tests/test_webmention.py index 269e227..874729f 100644 --- a/tests/test_webmention.py +++ b/tests/test_webmention.py @@ -194,6 +194,9 @@ class WebmentionTest(testutil.TestCase): } self.as2_update = copy.deepcopy(self.as2_create) self.as2_update['type'] = 'Update' + # we should generate this if it's not already in mf2 because Mastodon + # requires it for updates + self.as2_update['object']['updated'] = util.now().isoformat() self.follow_html = """\ @@ -292,6 +295,7 @@ class WebmentionTest(testutil.TestCase): } self.update_as2 = copy.deepcopy(self.create_as2) self.update_as2['type'] = 'Update' + self.update_as2['object']['updated'] = util.now().isoformat() self.not_fediverse = requests_response("""\ diff --git a/webmention.py b/webmention.py index 783db36..fe10bd8 100644 --- a/webmention.py +++ b/webmention.py @@ -137,6 +137,13 @@ class Webmention(View): if source_activity.get('type') == 'Create': source_activity['type'] = 'Update' + # Mastodon requires the updated field for Updates, so + # generate it if it's not already there. + # https://docs.joinmastodon.org/spec/activitypub/#supported-activities-for-statuses + # https://socialhub.activitypub.rocks/t/what-could-be-the-reason-that-my-update-activity-does-not-work/2893/4 + # https://github.com/mastodon/documentation/pull/1150 + source_activity.get('object', {}).setdefault( + 'updated', util.now().isoformat()) if self.source_obj.get('verb') == 'follow': # prefer AS2 id or url, if available