From e5af8398b7496dd2ea196cd9b6e42784cc3e5eb7 Mon Sep 17 00:00:00 2001 From: Alan Roberts Date: Wed, 4 Sep 2024 13:55:23 -0400 Subject: [PATCH] Adding https url search for add-remote communities --- app/community/routes.py | 7 +++++-- app/templates/community/add_remote.html | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/community/routes.py b/app/community/routes.py index 46c297c3..d9ce698c 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -12,7 +12,7 @@ from sqlalchemy import or_, desc, text from app import db, constants, cache from app.activitypub.signature import RsaKeys, post_request, default_context, post_request_in_background -from app.activitypub.util import notify_about_post, make_image_sizes, resolve_remote_post +from app.activitypub.util import notify_about_post, make_image_sizes, resolve_remote_post, extract_domain_and_actor from app.chat.util import send_message from app.community.forms import SearchRemoteCommunity, CreateDiscussionForm, CreateImageForm, CreateLinkForm, \ ReportCommunityForm, \ @@ -123,9 +123,12 @@ def add_remote(): ... elif '@' in address: new_community = search_for_community('!' + address) + elif address.startswith('https://'): + server, community = extract_domain_and_actor(address) + new_community = search_for_community('!' + community + '@' + server) else: message = Markup( - 'Type address in the format !community@server.name. Search on Lemmyverse.net to find some.') + 'Accepted address formats: !community@server.name or https://server.name/{c|m}/community. Search on Lemmyverse.net to find some.') flash(message, 'error') if new_community is None: if g.site.enable_nsfw: diff --git a/app/templates/community/add_remote.html b/app/templates/community/add_remote.html index 3e61544a..a79894b2 100644 --- a/app/templates/community/add_remote.html +++ b/app/templates/community/add_remote.html @@ -11,7 +11,13 @@
{{ _('Search') }}
-

Type address in the format !community@server.name. Search on Lemmyverse.net to find some.

+

Accepted address formats:

+
    +
  • !community@server.name
  • +
  • https://server.name/c/community (lemmy)
  • +
  • https://server.name/m/magazine (kbin/mbin)
  • +
+

Search on Lemmyverse.net to find some.

{{ render_form(form) }}