post mark and mention the mastodon acc

This commit is contained in:
Her Email 2023-12-09 23:22:03 -05:00 committed by Henri Dickson
parent 73a358c959
commit bd3066287f
2 changed files with 9 additions and 4 deletions

View file

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

View file

@ -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}<a href="{item_link}">《{mark.item.display_title}》</a>'
)
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,