diff --git a/src/sessions/mastodon/templates.py b/src/sessions/mastodon/templates.py index 1318f226..465d64c4 100644 --- a/src/sessions/mastodon/templates.py +++ b/src/sessions/mastodon/templates.py @@ -9,7 +9,7 @@ from . import utils, compose # This will be used for the edit template dialog. # Available variables for post objects. # safe_text will be the content warning in case a post contains one, text will always be the full text, no matter if has a content warning or not. -post_variables = ["date", "display_name", "screen_name", "source", "lang", "safe_text", "text", "image_descriptions", "visibility"] +post_variables = ["date", "display_name", "screen_name", "source", "lang", "safe_text", "text", "image_descriptions", "visibility", "pinned"] person_variables = ["display_name", "screen_name", "description", "followers", "following", "favorites", "posts", "created_at"] conversation_variables = ["users", "last_post"] notification_variables = ["display_name", "screen_name", "text", "date"] @@ -57,6 +57,7 @@ def render_post(post, template, settings, relative_times=False, offset_hours=0): $text: Toot text. This always displays the full text, even if there is a content warning present. $image_descriptions: Information regarding image descriptions added by twitter users. $visibility: post's visibility: public, not listed, followers only or direct. + $pinned: Wether the post is pinned or not (if not pinned, this will be blank). """ global post_variables available_data = dict(source="") @@ -88,6 +89,12 @@ def render_post(post, template, settings, relative_times=False, offset_hours=0): else: image_descriptions = process_image_descriptions(post.media_attachments) available_data.update(image_descriptions=image_descriptions) + # Process if the post is pinned + if post.pinned: + pinned = _("Pinned.") + else: + pinned = "" + available_data.update(pinned=pinned) result = Template(_(template)).safe_substitute(**available_data) return result