web UI sugar: parse bsky.app URLs into "x's post"

pull/915/head
Ryan Barrett 2024-03-04 19:27:50 -08:00
rodzic 9062572148
commit 11a480f1c2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ from Crypto.PublicKey import RSA
from flask import g, request
from google.cloud import ndb
from granary import as1, as2, atom, bluesky, microformats2
from granary.bluesky import BSKY_APP_URL_RE
from granary.source import html_to_text
from oauth_dropins.webutil import util
from oauth_dropins.webutil.appengine_info import DEBUG
@ -1200,6 +1201,14 @@ def fetch_objects(query, by=None, user=None):
content = '@' + fedi_url.group(2)
if fedi_url.group(4):
content += "'s post"
if not content:
if bsky_url := BSKY_APP_URL_RE.match(url):
if handle := bsky_url.group('id'): # or DID
content = '@' + handle
if bsky_url.group('tid'):
content += "'s post"
content = common.pretty_link(url, text=content, user=user)
obj.content = (obj_as1.get('content')