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.

jobs.py 612B

1234567891011121314151617181920212223
  1. import requests
  2. from django.conf import settings
  3. from django_rq import job
  4. from ronkyuu import webmention
  5. @job
  6. def ping_hub(*urls):
  7. for url in urls:
  8. requests.post(settings.PUSH_HUB, data={
  9. 'hub.mode': 'publish',
  10. 'hub.url': url,
  11. })
  12. @job
  13. def send_mentions(source, targets=None):
  14. if targets is None:
  15. targets = webmention.findMentions(source)['refs']
  16. for target in targets:
  17. status, endpoint = webmention.discoverEndpoint(target)
  18. if endpoint is not None and status == 200:
  19. webmention.sendWebmention(source, target, endpoint)