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:
|
2023-08-10 02:52:37 -04:00
|
|
|
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:
|
2023-08-10 02:52:37 -04:00
|
|
|
targets = webmention.findMentions(source)["refs"]
|
2018-07-02 01:30:32 -04:00
|
|
|
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)
|