Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode review markdown #383

Merged
merged 2 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions journal/models/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def ap_object(self):
"id": self.absolute_url,
"type": "Review",
"name": self.title,
"content": self.html_content,
# "content": self.html_content,
"content": self.body,
"mediaType": "text/markdown",
"published": self.created_time.isoformat(),
"updated": self.edited_time.isoformat(),
"attributedTo": self.owner.actor_uri,
Expand All @@ -51,9 +53,14 @@ def ap_object(self):

@classmethod
def update_by_ap_object(cls, owner, item, obj, post_id, visibility):
content = (
obj["content"]
if obj.get("mediaType") == "text/markdown"
else md(obj["content"])
)
d = {
"title": obj["name"],
"body": md(obj["content"].strip()),
"body": content,
"local": False,
"remote_id": obj["id"],
"visibility": visibility,
Expand Down
2 changes: 1 addition & 1 deletion users/models/apidentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def takahe_identity(self):
@property
def is_active(self):
return (
self.user and self.user.is_active and self.takahe_identity.deleted is None
self.user.is_active if self.user else self.takahe_identity.deleted is None
)

@property
Expand Down