mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2025-06-05 21:59:23 +02:00
Working webmentions
This commit is contained in:
16
app/boxes.py
16
app/boxes.py
@ -34,6 +34,7 @@ from app.outgoing_activities import new_outgoing_activity
|
||||
from app.source import markdownify
|
||||
from app.uploads import upload_to_attachment
|
||||
from app.utils import opengraph
|
||||
from app.utils import webmentions
|
||||
|
||||
AnyboxObject = models.InboxObject | models.OutboxObject
|
||||
|
||||
@ -372,6 +373,21 @@ async def send_create(
|
||||
for rcp in recipients:
|
||||
await new_outgoing_activity(db_session, rcp, outbox_object.id)
|
||||
|
||||
# If the note is public, check if we need to send any webmentions
|
||||
if visibility == ap.VisibilityEnum.PUBLIC:
|
||||
possible_targets = opengraph._urls_from_note(note)
|
||||
logger.info(f"webmentions possible targert {possible_targets}")
|
||||
for target in possible_targets:
|
||||
webmention_endpoint = await webmentions.discover_webmention_endpoint(target)
|
||||
logger.info(f"{target=} {webmention_endpoint=}")
|
||||
if webmention_endpoint:
|
||||
await new_outgoing_activity(
|
||||
db_session,
|
||||
webmention_endpoint,
|
||||
outbox_object_id=outbox_object.id,
|
||||
webmention_target=target,
|
||||
)
|
||||
|
||||
return note_id
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user