Fixes error when receiving Undo for unknown boost
This commit is contained in:
parent
848edd2972
commit
2548ba926a
|
@ -70,6 +70,9 @@ class Undo(Verb):
|
||||||
if self.object.type == "Follow":
|
if self.object.type == "Follow":
|
||||||
model = apps.get_model("bookwyrm.UserFollows")
|
model = apps.get_model("bookwyrm.UserFollows")
|
||||||
obj = self.object.to_model(model=model, save=False, allow_create=False)
|
obj = self.object.to_model(model=model, save=False, allow_create=False)
|
||||||
|
if not obj:
|
||||||
|
# if we don't have the object, we can't undo it. happens a lot with boosts
|
||||||
|
return
|
||||||
obj.delete()
|
obj.delete()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -563,6 +563,23 @@ class Inbox(TestCase):
|
||||||
}
|
}
|
||||||
views.inbox.activity_task(activity)
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
|
def test_handle_unboost_unknown_boost(self):
|
||||||
|
""" undo a boost """
|
||||||
|
activity = {
|
||||||
|
"type": "Undo",
|
||||||
|
"actor": "hi",
|
||||||
|
"id": "bleh",
|
||||||
|
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||||
|
"cc": ["https://example.com/user/mouse/followers"],
|
||||||
|
"object": {
|
||||||
|
"type": "Announce",
|
||||||
|
"id": "http://fake.com/unknown/boost",
|
||||||
|
"actor": self.remote_user.remote_id,
|
||||||
|
"object": self.status.remote_id,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
views.inbox.activity_task(activity)
|
||||||
|
|
||||||
def test_handle_add_book_to_shelf(self):
|
def test_handle_add_book_to_shelf(self):
|
||||||
""" shelving a book """
|
""" shelving a book """
|
||||||
work = models.Work.objects.create(title="work title")
|
work = models.Work.objects.create(title="work title")
|
||||||
|
|
Loading…
Reference in New Issue