From d8ae6c1c75f1aaa4fc0d189103e10dbcbf4d432f Mon Sep 17 00:00:00 2001 From: Matthieu Fesselier Date: Wed, 24 Apr 2019 14:56:18 +0700 Subject: [PATCH] update: subscription for containers and resources --- djangoldp_notification/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/djangoldp_notification/models.py b/djangoldp_notification/models.py index 3adfe0d..ba1ca87 100644 --- a/djangoldp_notification/models.py +++ b/djangoldp_notification/models.py @@ -54,11 +54,12 @@ class Subscription(Model): # --- SUBSCRIPTION SYSTEM --- @receiver(post_save, dispatch_uid="callback_notif") def send_notification(sender, instance, **kwargs): - if sender != Notification and isinstance(sender, Model): + if sender != Notification and issubclass(sender, Model): threads = [] - url = settings.BASE_URL + Model.resource_id(instance) + '/' - for subscription in Subscription.objects.filter(object=url): - process = Thread(target=send_request, args=[subscription.inbox, url]) + urlContainer = settings.BASE_URL + Model.container_id(instance) + urlResource = settings.BASE_URL + Model.resource_id(instance) + 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() threads.append(process)