From 96528ada9017d444655e284db7d19d6b3f804521 Mon Sep 17 00:00:00 2001 From: freamon Date: Mon, 15 Apr 2024 22:06:50 +0100 Subject: [PATCH 1/4] Ignore Announces intended for Mastodon --- app/activitypub/routes.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index d84c5794..a9cf8d65 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -672,30 +672,16 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): ocp.cross_posts.remove(post.id) delete_post_or_comment(user_ap_id, community_ap_id, to_be_deleted_ap_id) activity_log.result = 'success' - elif request_json['object']['type'] == 'Page': # Editing a post - post = Post.query.filter_by(ap_id=request_json['object']['id']).first() - if post: - try: - update_post_from_activity(post, request_json) - except KeyError: - activity_log.result = 'exception' - db.session.commit() - return - activity_log.result = 'success' - else: - activity_log.exception_message = 'Post not found' - elif request_json['object']['type'] == 'Note': # Editing a reply - reply = PostReply.query.filter_by(ap_id=request_json['object']['id']).first() - if reply: - try: - update_post_reply_from_activity(reply, request_json) - except KeyError: - activity_log.result = 'exception' - db.session.commit() - return - activity_log.result = 'success' - else: - activity_log.exception_message = 'PostReply not found' + elif request_json['object']['type'] == 'Page': # Sent for Mastodon's benefit + activity_log.result = 'ignored' + activity_log.exception_message = 'Intended for Mastodon' + db.session.add(activity_log) + db.session.commit() + elif request_json['object']['type'] == 'Note': # Never sent? + activity_log.result = 'ignored' + activity_log.exception_message = 'Intended for Mastodon' + db.session.add(activity_log) + db.session.commit() elif request_json['object']['type'] == 'Update': # Editing a post or comment if request_json['object']['object']['type'] == 'Page': post = Post.query.filter_by(ap_id=request_json['object']['object']['id']).first() From 2547d9dc1fadd4223771e276057b210da6975c88 Mon Sep 17 00:00:00 2001 From: freamon Date: Mon, 15 Apr 2024 22:08:38 +0100 Subject: [PATCH 2/4] Fix minor typo in INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 1c896b18..f1095a55 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -79,7 +79,7 @@ sudo apt install tesseract-ocr * Clone PyFedi -```basg +```bash git clone https://codeberg.org/rimu/pyfedi.git ``` From 6f2ea27df74ed9d47ba4ac56207f9d5c8fb6b3ee Mon Sep 17 00:00:00 2001 From: freamon Date: Mon, 15 Apr 2024 22:11:15 +0100 Subject: [PATCH 3/4] Use Leave/Join in post_reply_edit for consistency with other areas --- app/templates/post/post_reply_edit.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/post/post_reply_edit.html b/app/templates/post/post_reply_edit.html index 5c3c2339..cd041e57 100644 --- a/app/templates/post/post_reply_edit.html +++ b/app/templates/post/post_reply_edit.html @@ -41,9 +41,9 @@
{% if current_user.is_authenticated and community_membership(current_user, post.community) %} - {{ _('Unsubscribe') }} + {{ _('Leave') }} {% else %} - {{ _('Subscribe') }} + {{ _('Join') }} {% endif %}
From 554f93d56a6f0e1c62513e83b7129e5fe3c79e4e Mon Sep 17 00:00:00 2001 From: freamon Date: Tue, 16 Apr 2024 00:06:54 +0100 Subject: [PATCH 4/4] One more fix for lemmy spoiler regex --- app/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils.py b/app/utils.py index f7d427cf..e1928bce 100644 --- a/app/utils.py +++ b/app/utils.py @@ -221,7 +221,7 @@ def markdown_to_html(markdown_text) -> str: if markdown_text: raw_html = markdown2.markdown(markdown_text, safe_mode=True, extras={'middle-word-em': False, 'tables': True, 'fenced-code-blocks': True, 'strike': True}) # replace lemmy spoiler tokens with appropriate html tags instead. (until possibly added as extra to markdown2) - re_spoiler = re.compile(r':{3} spoiler\s+?(\S.+?)(?:\n|

)(.+?)(?:\n|

):{3}', re.S) + re_spoiler = re.compile(r':{3}\s*?spoiler\s+?(\S.+?)(?:\n|

)(.+?)(?:\n|

):{3}', re.S) raw_html = re_spoiler.sub(r'

\1

\2

', raw_html) return allowlist_html(raw_html) else: