Commit ffc9ea71 authored by Jean-Baptiste's avatar Jean-Baptiste

update: auto accept follow request on job-offers

parent 957ed2d1
Pipeline #4974 passed with stage
in 28 seconds
from django.apps import AppConfig
from django.db.models.signals import post_save
from django.dispatch import receiver
class DjangoldpJobofferConfig(AppConfig):
name = 'djangoldp_joboffer'
......@@ -26,3 +26,22 @@ class JobOffer(Model):
def __str__(self):
return '{} ({})'.format(self.title, self.author.get_full_name())
try:
from djangoldp_activitypub.models import Follower
from django.db.models.signals import post_save
from django.dispatch import receiver
from djangoldp_activitypub.activities import AP
from urllib.parse import urlparse
@receiver(post_save, sender=Follower)
def on_follower(sender, instance, **kwargs):
if not instance.confirmed:
actor_url = urlparse(instance.local_id)
model = Model.resolve_id(actor_url.path)
if isinstance(model, JobOffer):
AP.accept(instance)
except ModuleNotFoundError:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment