From d1372e44535dbae35fb84f56141a7bdd5294828c Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 16 Jun 2024 16:04:50 -0400 Subject: [PATCH] fix remove target 500 --- journal/models/common.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/journal/models/common.py b/journal/models/common.py index 7e7f575f..137e12c8 100644 --- a/journal/models/common.py +++ b/journal/models/common.py @@ -129,9 +129,16 @@ class Piece(PolymorphicModel, UserOwnedObjectMixin): ) def get_mastodon_repost_url(self): - return (self.metadata or {}).get("shared_link") + return ( + (self.metadata or {}).get("shared_link") + if hasattr(self, "metadata") + else None + ) def set_mastodon_repost_url(self, url: str | None): + if not hasattr(self, "metadata"): + logger.warning("metadata field not found") + return metadata = self.metadata or {} if metadata.get("shared_link", None) == url: return