Merge pull request #88 from zotanmew/main

Add support for Iceshrimp
This commit is contained in:
Michael 2023-10-24 13:23:15 +01:00 committed by GitHub
commit f69eaed5a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -557,6 +557,11 @@ def parse_url(url, parsed_urls):
if match is not None: if match is not None:
parsed_urls[url] = match parsed_urls[url] = match
if url not in parsed_urls:
match = parse_mastodon_uri(url)
if match is not None:
parsed_urls[url] = match
if url not in parsed_urls: if url not in parsed_urls:
match = parse_pleroma_url(url) match = parse_pleroma_url(url)
if match is not None: if match is not None:
@ -601,6 +606,14 @@ def parse_mastodon_url(url):
return (match.group("server"), match.group("toot_id")) return (match.group("server"), match.group("toot_id"))
return None return None
def parse_mastodon_uri(uri):
"""parse a Mastodon URI and return the server and ID"""
match = re.match(
r"https://(?P<server>[^/]+)/users/(?P<username>[^/]+)/statuses/(?P<toot_id>[^/]+)", uri
)
if match is not None:
return (match.group("server"), match.group("toot_id"))
return None
def parse_pleroma_url(url): def parse_pleroma_url(url):
"""parse a Pleroma URL and return the server and ID""" """parse a Pleroma URL and return the server and ID"""
@ -1205,7 +1218,7 @@ def get_server_info(server, seen_hosts):
def set_server_apis(server): def set_server_apis(server):
# support for new server software should be added here # support for new server software should be added here
software_apis = { software_apis = {
'mastodonApiSupport': ['mastodon', 'pleroma', 'akkoma', 'pixelfed', 'hometown'], 'mastodonApiSupport': ['mastodon', 'pleroma', 'akkoma', 'pixelfed', 'hometown', 'iceshrimp'],
'misskeyApiSupport': ['misskey', 'calckey', 'firefish', 'foundkey'], 'misskeyApiSupport': ['misskey', 'calckey', 'firefish', 'foundkey'],
'lemmyApiSupport': ['lemmy'] 'lemmyApiSupport': ['lemmy']
} }