forked from mirrors/bookwyrm
Fixes celery error encountering Article type activities
This commit is contained in:
parent
17864da8a2
commit
fd43b56d31
2 changed files with 31 additions and 3 deletions
|
@ -43,7 +43,7 @@ def naive_parse(activity_objects, activity_json, serializer=None):
|
||||||
serializer = activity_objects[activity_type]
|
serializer = activity_objects[activity_type]
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
# we know this exists and that we can't handle it
|
# we know this exists and that we can't handle it
|
||||||
if activity_type in ["Question"]:
|
if activity_type in ["Question", "Article"]:
|
||||||
return None
|
return None
|
||||||
raise ActivitySerializerError(err)
|
raise ActivitySerializerError(err)
|
||||||
|
|
||||||
|
|
|
@ -208,14 +208,42 @@ class InboxCreate(TestCase):
|
||||||
self.assertEqual(book_list.description, "summary text")
|
self.assertEqual(book_list.description, "summary text")
|
||||||
self.assertEqual(book_list.remote_id, "https://example.com/list/22")
|
self.assertEqual(book_list.remote_id, "https://example.com/list/22")
|
||||||
|
|
||||||
def test_create_unsupported_type(self, *_):
|
def test_create_unsupported_type_question(self, *_):
|
||||||
"""ignore activities we know we can't handle"""
|
"""ignore activities we know we can't handle"""
|
||||||
activity = self.create_json
|
activity = self.create_json
|
||||||
activity["object"] = {
|
activity["object"] = {
|
||||||
"id": "https://example.com/status/887",
|
"id": "https://example.com/status/887",
|
||||||
"type": "Question",
|
"type": "Question",
|
||||||
}
|
}
|
||||||
# just observer how it doesn't throw an error
|
# just observe how it doesn't throw an error
|
||||||
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
|
def test_create_unsupported_type_article(self, *_):
|
||||||
|
""" special case in unsupported type because we do know what it is"""
|
||||||
|
activity = self.create_json
|
||||||
|
activity["object"] = {
|
||||||
|
"id": "https://example.com/status/887",
|
||||||
|
"type": "Article",
|
||||||
|
"name": "hello",
|
||||||
|
"published": "2021-04-29T21:27:30.014235+00:00",
|
||||||
|
"attributedTo": "https://example.com/user/mouse",
|
||||||
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
|
"sensitive": False,
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
}
|
||||||
|
# just observe how it doesn't throw an error
|
||||||
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
|
def test_create_unsupported_type_unknown(self, *_):
|
||||||
|
"""Something truly unexpected should throw an error"""
|
||||||
|
activity = self.create_json
|
||||||
|
activity["object"] = {
|
||||||
|
"id": "https://example.com/status/887",
|
||||||
|
"type": "Blaaaah",
|
||||||
|
}
|
||||||
|
# error this time
|
||||||
|
with self.assertRaises(ActivitySerializerError):
|
||||||
views.inbox.activity_task(activity)
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
def test_create_unknown_type(self, *_):
|
def test_create_unknown_type(self, *_):
|
||||||
|
|
Loading…
Reference in a new issue