~ihabunek/toot-discuss

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Add pleroma special case to get_instance_domain

Laura Aino Violetta Aléanor <lav@vampires.gay>
Details
Message ID
<20230426212716.2895-1-lav@vampires.gay>
DKIM signature
pass
Download raw message
Patch: +6 -0
See issue 347 <https://github.com/ihabunek/toot/issues/347>.
Basically, there is a discrepancy in what different server softwares
put in the "uri" field returned by the `instance` API endpoint. While
mastodon (and the mastodon API documentation) use this for the *domain
name*, pleroma and its forks (like akkoma) use it for the actual
URI. This commit adds a check to get_instance_domain, so that when the
instance is served by pleroma or a pleroma fork, the domain name is
extracted from the URI and returned. Previously, the whole URI was returned.
---
 toot/auth.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/toot/auth.py b/toot/auth.py
index 0ee2bac..3808bf7 100644
--- a/toot/auth.py
+++ b/toot/auth.py
@@ -3,6 +3,7 @@ import webbrowser

from builtins import input
from getpass import getpass
from urllib.parse import urlparse

from toot import api, config, DEFAULT_INSTANCE, User, App
from toot.exceptions import ApiError, ConsoleError
@@ -46,6 +47,11 @@ def get_instance_domain(base_url):
        f"running Mastodon version <yellow>{instance['version']}</yellow>"
    )

    # Pleroma and its forks return an actual URI here, rather than a
    # domain name like Mastodon.
    if "pleroma" in instance:
        return urlparse(instance["uri"]).netloc

    # NB: when updating to v2 instance endpoint, this field has been renamed to `domain`
    return instance["uri"]

-- 
2.39.2
Details
Message ID
<ad50d2c8-04f6-4dba-bcb1-9a9943efbaf1@app.fastmail.com>
In-Reply-To
<20230426212716.2895-1-lav@vampires.gay> (view parent)
DKIM signature
pass
Download raw message
Sorry I never responded to this email, it's been a crazy lately. I see you came up with an alternative solution with Dan. Thanks for your contribution!

Regards,
-- Ivan
Reply to thread Export thread (mbox)