update profile bug fix: always populate object.updated field

for #376
pull/380/head
Ryan Barrett 2023-01-23 20:53:34 -08:00
rodzic e6889b4cf6
commit 0d0a4ed642
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 13 dodań i 9 usunięć

Wyświetl plik

@ -1009,7 +1009,10 @@ class WebmentionTest(testutil.TestCase):
'type': 'Update',
'id': 'http://localhost/r/https://orig/#update-2022-01-02T03:04:05+00:00',
'actor': 'http://localhost/orig',
'object': ACTOR_AS2_FULL,
'object': {
**ACTOR_AS2_FULL,
'updated': util.now().isoformat(),
},
'to': ['https://www.w3.org/ns/activitystreams#Public'],
}
@ -1019,6 +1022,7 @@ class WebmentionTest(testutil.TestCase):
got_update = json_loads(call[1]['data'])
del got_update['object']['publicKey']
self.assertEqual(expected_update, got_update)
activity = Activity.get_by_id(f'https://orig/ {inbox}')
self.assertEqual(['orig'], activity.domain)
self.assertEqual('out', activity.direction)

Wyświetl plik

@ -162,14 +162,14 @@ class Webmention(View):
if self.source_as2.get('type') == 'Create':
self.source_as2['type'] = 'Update'
if self.source_as2.get('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
self.source_as2.get('object', {}).setdefault(
'updated', util.now().isoformat())
if self.source_as2.get('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
self.source_as2.get('object', {}).setdefault(
'updated', util.now().isoformat())
if self.source_as2.get('type') == 'Follow':
# prefer AS2 id or url, if available