Add hack to work around a pleroma bug

This commit is contained in:
Ivan Habunek 2023-11-18 12:32:35 +01:00
parent 8d1edd5374
commit fe8b441b5b
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 12 additions and 0 deletions

View File

@ -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: