forked from mirrors/bookwyrm
Fixes ignore test for valid remote statuses
This commit is contained in:
parent
81bd3f5be8
commit
28dc67bf5c
2 changed files with 10 additions and 3 deletions
|
@ -248,7 +248,9 @@ def get_model_from_type(activity_type):
|
|||
return model[0]
|
||||
|
||||
|
||||
def resolve_remote_id(remote_id, model=None, refresh=False, save=True):
|
||||
def resolve_remote_id(
|
||||
remote_id, model=None, refresh=False, save=True, get_activity=False
|
||||
):
|
||||
""" take a remote_id and return an instance, creating if necessary """
|
||||
if model: # a bonus check we can do if we already know the model
|
||||
result = model.find_existing_by_remote_id(remote_id)
|
||||
|
@ -272,5 +274,8 @@ def resolve_remote_id(remote_id, model=None, refresh=False, save=True):
|
|||
return result
|
||||
|
||||
item = model.activity_serializer(**data)
|
||||
if get_activity:
|
||||
return item
|
||||
|
||||
# if we're refreshing, "result" will be set and we'll update it
|
||||
return item.to_model(model=model, instance=result, save=save)
|
||||
|
|
|
@ -123,12 +123,14 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
""" keep notes if they are replies to existing statuses """
|
||||
if activity.type == "Announce":
|
||||
try:
|
||||
boosted = activitypub.resolve_remote_id(activity.object, save=False)
|
||||
boosted = activitypub.resolve_remote_id(
|
||||
activity.object, get_activity=True
|
||||
)
|
||||
except activitypub.ActivitySerializerError:
|
||||
# if we can't load the status, definitely ignore it
|
||||
return True
|
||||
# keep the boost if we would keep the status
|
||||
return cls.ignore_activity(boosted.to_activity_dataclass())
|
||||
return cls.ignore_activity(boosted)
|
||||
|
||||
# keep if it if it's a custom type
|
||||
if activity.type != "Note":
|
||||
|
|
Loading…
Reference in a new issue