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):
14 14
 
15 15
 
16 16
 @job
17
-def send_mentions(source):
18
-    result = webmention.findMentions(source)
19
-    for target in result['refs']:
17
+def send_mentions(source, targets=None):
18
+    if targets is None:
19
+        targets = webmention.findMentions(source)['refs']
20
+    for target in targets:
20 21
         status, endpoint = webmention.discoverEndpoint(target)
21 22
         if endpoint is not None and status == 200:
22 23
             webmention.sendWebmention(source, target, endpoint)

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

@@ -1,8 +1,9 @@
1 1
 from django.http import HttpResponse
2 2
 from django.urls import resolve, Resolver404
3 3
 from urllib.parse import urlparse
4
+from ronkyuu import webmention
4 5
 
5
-from entries.jobs import ping_hub
6
+from entries.jobs import ping_hub, send_mentions
6 7
 from entries.models import Entry
7 8
 
8 9
 from . import error
@@ -42,7 +43,12 @@ def delete(request):
42 43
     if entry.author != request.token.user:
43 44
         return error.forbid('entry belongs to another user')
44 45
 
45
-    urls = entry.affected_urls
46
+    perma = entry.absolute_url
47
+    pings = entry.affected_urls
48
+    mentions = webmention.findMentions(perma)['refs']
49
+
46 50
     entry.delete()
47
-    ping_hub.delay(urls)
51
+
52
+    ping_hub.delay(*pings)
53
+    send_mentions.delay(perma, mentions)
48 54
     return HttpResponse(status=204)

Loading…
Cancel
Save