Skip to content
Snippets Groups Projects
Commit d317cb8b authored by Matthieu Fesselier's avatar Matthieu Fesselier
Browse files

update: improve sender detection

parent d8ae6c1c
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from oidc_provider.models import Token
from django.core.urlresolvers import NoReverseMatch
from djangoldp.fields import LDPUrlField
from djangoldp.models import Model
......@@ -54,10 +55,14 @@ class Subscription(Model):
# --- SUBSCRIPTION SYSTEM ---
@receiver(post_save, dispatch_uid="callback_notif")
def send_notification(sender, instance, **kwargs):
if sender != Notification and issubclass(sender, Model):
if sender != Notification:
threads = []
urlContainer = settings.BASE_URL + Model.container_id(instance)
urlResource = settings.BASE_URL + Model.resource_id(instance)
try:
urlContainer = settings.BASE_URL + Model.container_id(instance)
urlResource = settings.BASE_URL + Model.resource_id(instance)
except NoReverseMatch:
return
for subscription in Subscription.objects.filter(models.Q(object=urlResource)|models.Q(object=urlContainer)):
process = Thread(target=send_request, args=[subscription.inbox, urlResource])
process.start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment