From fe8b441b5b6402b8917a2bb490cf1a3fc253de31 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 18 Nov 2023 12:32:35 +0100 Subject: [PATCH] Add hack to work around a pleroma bug --- toot/entities.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/toot/entities.py b/toot/entities.py index a330fa1..1549c9a 100644 --- a/toot/entities.py +++ b/toot/entities.py @@ -262,6 +262,18 @@ class Status: def original(self) -> "Status": return self.reblog or self + @staticmethod + def __toot_prepare__(obj: Dict) -> Dict: + # Pleroma has a bug where created_at is set to an empty string. + # To avoid marking created_at as optional, which would require work + # because we count on it always existing, set it to current datetime. + # Possible underlying issue: + # https://git.pleroma.social/pleroma/pleroma/-/issues/2851 + created_at = obj.get("created_at") + if not obj["created_at"]: + obj["created_at"] = datetime.now().astimezone().isoformat() + return obj + @dataclass class Report: