Browse Source

Properly send webmentions after deleting an entry :3

tags/v1.10.0
Danielle McLean 1 year ago
parent
commit
bab7097fa3
Signed by: Danielle McLean <dani@00dani.me> GPG Key ID: 8EB789DDF3ABD240
2 changed files with 13 additions and 6 deletions
  1. +4
    -3
      entries/jobs.py
  2. +9
    -3
      micropub/views/delete.py

+ 4
- 3
entries/jobs.py View File

@@ -14,9 +14,10 @@ def ping_hub(*urls):


@job
def send_mentions(source):
result = webmention.findMentions(source)
for target in result['refs']:
def send_mentions(source, targets=None):
if targets is None:
targets = webmention.findMentions(source)['refs']
for target in targets:
status, endpoint = webmention.discoverEndpoint(target)
if endpoint is not None and status == 200:
webmention.sendWebmention(source, target, endpoint)

+ 9
- 3
micropub/views/delete.py View File

@@ -1,8 +1,9 @@
from django.http import HttpResponse
from django.urls import resolve, Resolver404
from urllib.parse import urlparse
from ronkyuu import webmention

from entries.jobs import ping_hub
from entries.jobs import ping_hub, send_mentions
from entries.models import Entry

from . import error
@@ -42,7 +43,12 @@ def delete(request):
if entry.author != request.token.user:
return error.forbid('entry belongs to another user')

urls = entry.affected_urls
perma = entry.absolute_url
pings = entry.affected_urls
mentions = webmention.findMentions(perma)['refs']

entry.delete()
ping_hub.delay(urls)

ping_hub.delay(*pings)
send_mentions.delay(perma, mentions)
return HttpResponse(status=204)

Loading…
Cancel
Save