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)