Working webmentions
parent
229feb23db
commit
1b3c76ee2f
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.source import markdownify
|
||||||
from app.uploads import upload_to_attachment
|
from app.uploads import upload_to_attachment
|
||||||
from app.utils import opengraph
|
from app.utils import opengraph
|
||||||
|
from app.utils import webmentions
|
||||||
|
|
||||||
AnyboxObject = models.InboxObject | models.OutboxObject
|
AnyboxObject = models.InboxObject | models.OutboxObject
|
||||||
|
|
||||||
|
@ -372,6 +373,21 @@ async def send_create(
|
||||||
for rcp in recipients:
|
for rcp in recipients:
|
||||||
await new_outgoing_activity(db_session, rcp, outbox_object.id)
|
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
|
return note_id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ def _send_actor_update_if_needed(db_session: Session) -> None:
|
||||||
for rcp in {
|
for rcp in {
|
||||||
follower.actor.shared_inbox_url or follower.actor.inbox_url
|
follower.actor.shared_inbox_url or follower.actor.inbox_url
|
||||||
for follower in followers
|
for follower in followers
|
||||||
} + {
|
} | {
|
||||||
row.recipient
|
row.recipient
|
||||||
for row in db_session.execute(
|
for row in db_session.execute(
|
||||||
select(func.distinct(models.OutgoingActivity.recipient).label("recipient"))
|
select(func.distinct(models.OutgoingActivity.recipient).label("recipient"))
|
||||||
|
@ -124,7 +124,7 @@ def _send_actor_update_if_needed(db_session: Session) -> None:
|
||||||
async def new_outgoing_activity(
|
async def new_outgoing_activity(
|
||||||
db_session: AsyncSession,
|
db_session: AsyncSession,
|
||||||
recipient: str,
|
recipient: str,
|
||||||
outbox_object_id: int | None,
|
outbox_object_id: int | None = None,
|
||||||
inbox_object_id: int | None = None,
|
inbox_object_id: int | None = None,
|
||||||
webmention_target: str | None = None,
|
webmention_target: str | None = None,
|
||||||
) -> models.OutgoingActivity:
|
) -> models.OutgoingActivity:
|
||||||
|
|
|
@ -157,7 +157,7 @@
|
||||||
|
|
||||||
<div class="actor-box h-card p-author">
|
<div class="actor-box h-card p-author">
|
||||||
<div class="icon-box">
|
<div class="icon-box">
|
||||||
<img src="{{ actor.resized_icon_url }}" class="actor-icon">
|
<img src="{{ actor.resized_icon_url }}" class="actor-icon u-photo">
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ actor.url }}" class="u-url" style="">
|
<a href="{{ actor.url }}" class="u-url" style="">
|
||||||
<div><strong>{{ actor.display_name | clean_html(actor) | safe }}</strong></div>
|
<div><strong>{{ actor.display_name | clean_html(actor) | safe }}</strong></div>
|
||||||
|
|
Loading…
Reference in New Issue