From 1c4e703f6f12afa3bda141c09a3358fe8c96890e Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 7 Apr 2024 10:41:45 -0400 Subject: [PATCH] GTS does not support multiple redirect_uris --- mastodon/api.py | 5 ++++- mastodon/management/commands/mastodon_sites.py | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mastodon/api.py b/mastodon/api.py index 383bdf5b..163ada95 100644 --- a/mastodon/api.py +++ b/mastodon/api.py @@ -376,7 +376,10 @@ def get_or_create_fediverse_application(login_domain): app = MastodonApplication.objects.filter(domain_name__iexact=domain).first() if app: return app - allow_multiple_redir = True # TODO detect site supports multiple redirect uris + allow_multiple_redir = True + if "; Pixelfed" in server_version or server_version.startswith("0."): + # Pixelfed and GoToSocial don't support multiple redirect uris + allow_multiple_redir = False response = create_app(api_domain, allow_multiple_redir) if response.status_code != 200: logger.error( diff --git a/mastodon/management/commands/mastodon_sites.py b/mastodon/management/commands/mastodon_sites.py index 8dc9450a..44386e31 100644 --- a/mastodon/management/commands/mastodon_sites.py +++ b/mastodon/management/commands/mastodon_sites.py @@ -2,7 +2,7 @@ import pprint from django.core.management.base import BaseCommand -from mastodon.api import create_app +from mastodon.api import create_app, detect_server_info from mastodon.models import MastodonApplication @@ -20,7 +20,15 @@ class Command(BaseCommand): def handle(self, *args, **options): if options["refresh"]: for site in MastodonApplication.objects.exclude(disabled=True): + try: + _, _, server_version = detect_server_info(site.api_domain) + except Exception: + continue allow_multiple_redir = True + if "; Pixelfed" in server_version or server_version.startswith("0."): + allow_multiple_redir = False + if allow_multiple_redir: + continue try: response = create_app(site.api_domain, allow_multiple_redir) except Exception as e: