web.poll_feed_task: default actor/author to user

pull/781/head
Ryan Barrett 2024-01-09 16:02:41 -08:00
rodzic 6dac6dd60d
commit 81e675f79b
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -1803,10 +1803,12 @@ class WebTest(TestCase):
'verb': 'post',
'id': 'https://user.com/post',
'url': 'https://user.com/post',
'actor': {'id': 'https://user.com/'},
'object':{
'objectType': 'note',
'id': 'https://user.com/post',
'url': 'https://user.com/post',
'author': {'id': 'https://user.com/'},
'content': 'I hereby ☕ post',
},
'feed_index': 0,
@ -1879,10 +1881,12 @@ class WebTest(TestCase):
'verb': 'post',
'id': url,
'url': url,
'actor': {'id': 'https://user.com/'},
'object':{
'objectType': 'note',
'id': url,
'url': url,
'author': {'id': 'https://user.com/'},
'content': f'I hereby ☕ post {id}',
'published': f'2012-12-0{day}T00:00:00+00:00',
},

6
web.py
Wyświetl plik

@ -659,6 +659,12 @@ def poll_feed_task():
published_last = None
published_deltas = [] # timedeltas between entry published times
for i, activity in enumerate(activities):
# default actor and author to user
activity.setdefault('actor', {}).setdefault('id', user.profile_id())
activity.setdefault('object', {})\
.setdefault('author', {})\
.setdefault('id', user.profile_id())
logger.info(f'Converted to AS1: {json_dumps(activity, indent=2)}')
published = activity.get('object', {}).get('published')