From 8b0507fa9cbf8b549558302afe623d77ae63e069 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Apr 2024 11:43:17 -0400 Subject: [PATCH] fix spoiler text when commenting episodes --- common/templates/_sidebar_anonymous.html | 2 +- locale/zh_Hans/LC_MESSAGES/django.po | 2 +- mastodon/api.py | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/templates/_sidebar_anonymous.html b/common/templates/_sidebar_anonymous.html index 46145442..32e86f34 100644 --- a/common/templates/_sidebar_anonymous.html +++ b/common/templates/_sidebar_anonymous.html @@ -26,7 +26,7 @@

欢迎 🙋🏻‍♀️ 🙋🏻 🙋🏻‍♂️

  如果有任何问题或建议,欢迎通过联邦宇宙Discord和我们联系。

-   点击这里登录。 +   点击这里注册或登录。

{% endif %} diff --git a/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po index 5311d261..df97422b 100644 --- a/locale/zh_Hans/LC_MESSAGES/django.po +++ b/locale/zh_Hans/LC_MESSAGES/django.po @@ -337,7 +337,7 @@ msgstr "收藏单" #: catalog/common/models.py:129 catalog/common/models.py:142 msgid "TV" -msgstr "电视" +msgstr "剧集" #: catalog/common/models.py:130 catalog/common/models.py:143 #: common/templates/_header.html:37 diff --git a/mastodon/api.py b/mastodon/api.py index 163ada95..3c384bfb 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -327,7 +327,7 @@ def detect_server_info(login_domain) -> tuple[str, str, str]: response = get(url, headers={"User-Agent": USER_AGENT}) except Exception as e: logger.warning(f"Error connecting {login_domain}: {e}") - raise Exception(f"无法连接 {login_domain}") + raise Exception(f"无法连接实例 {login_domain}") if response.status_code != 200: logger.warning(f"Error connecting {login_domain}: {response.status_code}") raise Exception(f"实例 {login_domain} 返回错误,代码: {response.status_code}") @@ -398,7 +398,7 @@ def get_or_create_fediverse_application(login_domain): app_id=data["id"], client_id=data["client_id"], client_secret=data["client_secret"], - vapid_key=data["vapid_key"] if "vapid_key" in data else "", + vapid_key=data.get("vapid_key", ""), ) return app @@ -518,10 +518,11 @@ def share_comment(comment): if user.preference.mastodon_append_tag else "" ) + spoiler_text, txt = get_spoiler_text(comment.text or "", comment.item) tpl = ShelfManager.get_action_template(ShelfType.PROGRESS, comment.item.category) content = ( _(tpl).format(item=comment.item.display_title) - + f"\n{comment.text}\n{comment.item.absolute_url}{tags}" + + f"\n{txt}\n{comment.item.absolute_url}{tags}" ) update_id = None if comment.metadata.get( @@ -532,7 +533,13 @@ def share_comment(comment): ) # might be re.match(r'.+/([^/]+)$', u) if Pleroma supports edit update_id = r[1] if r else None response = post_toot( - user.mastodon_site, content, visibility, user.mastodon_token, False, update_id + user.mastodon_site, + content, + visibility, + user.mastodon_token, + False, + update_id, + spoiler_text, ) if response is not None and response.status_code in [200, 201]: j = response.json()