From bd3066287f137c12c5567b0ee9414a8e80bc518e Mon Sep 17 00:00:00 2001 From: Her Email Date: Sat, 9 Dec 2023 23:22:03 -0500 Subject: [PATCH] post mark and mention the mastodon acc --- journal/models/mark.py | 7 ++++++- takahe/utils.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/journal/models/mark.py b/journal/models/mark.py index 5f1e1c76..ab001a36 100644 --- a/journal/models/mark.py +++ b/journal/models/mark.py @@ -233,7 +233,12 @@ class Mark: self.rating_grade = rating_grade # publish a new or updated ActivityPub post post_as_new = shelf_type != last_shelf_type or visibility != last_visibility - post = Takahe.post_mark(self, post_as_new) # this will update linked post + append = ( + f" \n@{self.owner.user.mastodon_acct}" + if visibility > 0 and share_to_mastodon + else "" + ) + post = Takahe.post_mark(self, post_as_new, append) # async boost to mastodon if post and share_to_mastodon: if settings.FORCE_CLASSIC_REPOST: diff --git a/takahe/utils.py b/takahe/utils.py index 90884bb8..972fbf3e 100644 --- a/takahe/utils.py +++ b/takahe/utils.py @@ -551,7 +551,7 @@ class Takahe: return post @staticmethod - def post_mark(mark, share_as_new_post: bool) -> Post | None: + def post_mark(mark, share_as_new_post: bool, append_content="") -> Post | None: from catalog.common import ItemCategory user = mark.owner.user @@ -569,7 +569,7 @@ class Takahe: pre_conetent = ( f'{mark.action_label}《{mark.item.display_title}》' ) - content = f"{stars}\n{mark.comment_text or ''}{tags}" + content = f"{stars} \n{mark.comment_text or ''}{tags}" data = { "object": { "tag": [mark.item.ap_object_ref], @@ -593,7 +593,7 @@ class Takahe: post = Takahe.post( mark.owner.pk, pre_conetent, - content, + content + append_content, v, data, existing_post.pk if existing_post else None,