a Django-based indieweb.org site https://00dani.me/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

from django.http import HttpResponse
from ronkyuu import webmention
from entries.from_url import from_url
from entries.jobs import ping_hub, send_mentions
from . import error
def delete(request):
normalise = {
'application/json': lambda r: r.json.get('url'),
'application/x-www-form-urlencoded': lambda r: r.POST.get('url'),
if 'delete' not in request.token:
return error.bad_scope('delete')
if request.content_type not in normalise:
return error.unsupported_type(request.content_type)
url = normalise[request.content_type](request)
entry = from_url(url)
if isinstance(entry, HttpResponse):
return entry
if entry.author != request.token.user:
return error.forbid('entry belongs to another user')
perma = entry.absolute_url
pings = entry.affected_urls
mentions = webmention.findMentions(perma)['refs']
send_mentions.delay(perma, mentions)
return HttpResponse(status=204)