Properly send webmentions after deleting an entry :3

pull/1/head
Danielle McLean 4 years ago
parent fa8419976d
commit bab7097fa3
Signed by: 00dani
GPG Key ID: 8EB789DDF3ABD240
  1. 7
      entries/jobs.py
  2. 12
      micropub/views/delete.py

@ -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)

@ -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