Adding https url search for add-remote communities

This commit is contained in:
Alan Roberts 2024-09-04 13:55:23 -04:00
parent 5ecb66988b
commit e5af8398b7
2 changed files with 12 additions and 3 deletions

View file

@ -12,7 +12,7 @@ from sqlalchemy import or_, desc, text
from app import db, constants, cache from app import db, constants, cache
from app.activitypub.signature import RsaKeys, post_request, default_context, post_request_in_background 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.chat.util import send_message
from app.community.forms import SearchRemoteCommunity, CreateDiscussionForm, CreateImageForm, CreateLinkForm, \ from app.community.forms import SearchRemoteCommunity, CreateDiscussionForm, CreateImageForm, CreateLinkForm, \
ReportCommunityForm, \ ReportCommunityForm, \
@ -123,9 +123,12 @@ def add_remote():
... ...
elif '@' in address: elif '@' in address:
new_community = search_for_community('!' + 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: else:
message = Markup( message = Markup(
'Type address in the format !community@server.name. Search on <a href="https://lemmyverse.net/communities">Lemmyverse.net</a> to find some.') 'Accepted address formats: !community@server.name or https://server.name/{c|m}/community. Search on <a href="https://lemmyverse.net/communities">Lemmyverse.net</a> to find some.')
flash(message, 'error') flash(message, 'error')
if new_community is None: if new_community is None:
if g.site.enable_nsfw: if g.site.enable_nsfw:

View file

@ -11,7 +11,13 @@
<div class="card mt-5"> <div class="card mt-5">
<div class="card-body p-6"> <div class="card-body p-6">
<div class="card-title">{{ _('Search') }}</div> <div class="card-title">{{ _('Search') }}</div>
<p>Type address in the format !community@server.name. Search on <a href="https://lemmyverse.net/communities" target='_blank'>Lemmyverse.net</a> to find some.</p> <p>Accepted address formats: </p>
<ul>
<li>!community@server.name</li>
<li>https://server.name/c/community (lemmy)</li>
<li>https://server.name/m/magazine (kbin/mbin)</li>
</ul>
<p>Search on <a href="https://lemmyverse.net/communities" target='_blank'>Lemmyverse.net</a> to find some.</p>
{{ render_form(form) }} {{ render_form(form) }}
</div> </div>
</div> </div>