kopia lustrzana https://github.com/snarfed/bridgy-fed
user page bug fix for 133d640f1d
rodzic
f67cecd8f9
commit
ea1f3dce49
45
models.py
45
models.py
|
@ -1271,33 +1271,32 @@ def fetch_objects(query, by=None, user=None):
|
||||||
'content': 'their profile',
|
'content': 'their profile',
|
||||||
'url': id,
|
'url': id,
|
||||||
})
|
})
|
||||||
elif url:
|
elif url and not content:
|
||||||
# heuristics for sniffing URLs and converting them to more friendly
|
# heuristics for sniffing URLs and converting them to more friendly
|
||||||
# phrases and user handles.
|
# phrases and user handles.
|
||||||
# TODO: standardize this into granary.as2 somewhere?
|
# TODO: standardize this into granary.as2 somewhere?
|
||||||
if not content:
|
from activitypub import FEDI_URL_RE
|
||||||
from activitypub import FEDI_URL_RE
|
from atproto import COLLECTION_TO_TYPE, did_to_handle
|
||||||
from atproto import COLLECTION_TO_TYPE, did_to_handle
|
|
||||||
|
|
||||||
if match := FEDI_URL_RE.match(url):
|
if match := FEDI_URL_RE.match(url):
|
||||||
content = '@' + match.group(2)
|
content = '@' + match.group(2)
|
||||||
if match.group(4):
|
if match.group(4):
|
||||||
content += "'s post"
|
content += "'s post"
|
||||||
elif match := BSKY_APP_URL_RE.match(url):
|
elif match := BSKY_APP_URL_RE.match(url):
|
||||||
id = match.group('id')
|
id = match.group('id')
|
||||||
if id.startswith('did:'):
|
if id.startswith('did:'):
|
||||||
id = ATdid_to_handle(id) or id
|
id = did_to_handle(id) or id
|
||||||
content = '@' + id
|
content = '@' + id
|
||||||
if match.group('tid'):
|
if match.group('tid'):
|
||||||
content += "'s post"
|
content += "'s post"
|
||||||
elif match := AT_URI_PATTERN.match(url):
|
elif match := AT_URI_PATTERN.match(url):
|
||||||
id = match.group('repo')
|
id = match.group('repo')
|
||||||
if id.startswith('did:'):
|
if id.startswith('did:'):
|
||||||
id = did_to_handle(id) or id
|
id = did_to_handle(id) or id
|
||||||
content = '@' + id
|
content = '@' + id
|
||||||
if coll := match.group('collection'):
|
if coll := match.group('collection'):
|
||||||
content += f"'s {COLLECTION_TO_TYPE.get(coll) or 'post'}"
|
content += f"'s {COLLECTION_TO_TYPE.get(coll) or 'post'}"
|
||||||
url = bluesky.at_uri_to_web_url(url)
|
url = bluesky.at_uri_to_web_url(url)
|
||||||
|
|
||||||
content = common.pretty_link(url, text=content, user=user)
|
content = common.pretty_link(url, text=content, user=user)
|
||||||
|
|
||||||
|
|
15
protocol.py
15
protocol.py
|
@ -353,6 +353,21 @@ class Protocol:
|
||||||
|
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def bridged_web_url_for(self, user):
|
||||||
|
"""Returns the web URL for a user's bridged profile in this protocol.
|
||||||
|
|
||||||
|
For example, for Web user ``alice.com``, :meth:`ATProto.bridged_web_url_for`
|
||||||
|
returns ``https://bsky.app/profile/alice.com.web.brid.gy``
|
||||||
|
|
||||||
|
Args:
|
||||||
|
proto (str or Protocol)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str, or None if there isn't a canonical URL
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def actor_key(cls, obj):
|
def actor_key(cls, obj):
|
||||||
"""Returns the :class:`User`: key for a given object's author or actor.
|
"""Returns the :class:`User`: key for a given object's author or actor.
|
||||||
|
|
Ładowanie…
Reference in New Issue