forked from 00dani/lemoncurry
Properly send webmentions after deleting an entry :3
This commit is contained in:
parent
fa8419976d
commit
bab7097fa3
2 changed files with 13 additions and 6 deletions
|
@ -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…
Reference in a new issue