mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-09 16:55:29 +00:00
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]
|
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 """
|
""" 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
|
if model: # a bonus check we can do if we already know the model
|
||||||
result = model.find_existing_by_remote_id(remote_id)
|
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
|
return result
|
||||||
|
|
||||||
item = model.activity_serializer(**data)
|
item = model.activity_serializer(**data)
|
||||||
|
if get_activity:
|
||||||
|
return item
|
||||||
|
|
||||||
# if we're refreshing, "result" will be set and we'll update it
|
# if we're refreshing, "result" will be set and we'll update it
|
||||||
return item.to_model(model=model, instance=result, save=save)
|
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 """
|
""" keep notes if they are replies to existing statuses """
|
||||||
if activity.type == "Announce":
|
if activity.type == "Announce":
|
||||||
try:
|
try:
|
||||||
boosted = activitypub.resolve_remote_id(activity.object, save=False)
|
boosted = activitypub.resolve_remote_id(
|
||||||
|
activity.object, get_activity=True
|
||||||
|
)
|
||||||
except activitypub.ActivitySerializerError:
|
except activitypub.ActivitySerializerError:
|
||||||
# if we can't load the status, definitely ignore it
|
# if we can't load the status, definitely ignore it
|
||||||
return True
|
return True
|
||||||
# keep the boost if we would keep the status
|
# 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
|
# keep if it if it's a custom type
|
||||||
if activity.type != "Note":
|
if activity.type != "Note":
|
||||||
|
|
Loading…
Reference in a new issue