2017-11-05 19:46:43 -05:00
|
|
|
import requests
|
|
|
|
from django.conf import settings
|
2017-11-05 19:04:22 -05:00
|
|
|
from django_rq import job
|
2017-11-06 05:08:02 -05:00
|
|
|
from ronkyuu import webmention
|
2017-11-05 19:04:22 -05:00
|
|
|
|
|
|
|
|
|
|
|
@job
|
|
|
|
def ping_hub(*urls):
|
2017-12-18 23:44:42 -05:00
|
|
|
for url in urls:
|
|
|
|
requests.post(settings.PUSH_HUB, data={
|
|
|
|
'hub.mode': 'publish',
|
|
|
|
'hub.url': url,
|
|
|
|
})
|
2017-11-06 05:08:02 -05:00
|
|
|
|
|
|
|
|
|
|
|
@job
|
2018-07-02 01:30:32 -04:00
|
|
|
def send_mentions(source, targets=None):
|
|
|
|
if targets is None:
|
|
|
|
targets = webmention.findMentions(source)['refs']
|
|
|
|
for target in targets:
|
2017-11-06 05:41:27 -05:00
|
|
|
status, endpoint = webmention.discoverEndpoint(target)
|
|
|
|
if endpoint is not None and status == 200:
|
|
|
|
webmention.sendWebmention(source, target, endpoint)
|