diff --git a/djangoldp_notification/models.py b/djangoldp_notification/models.py index 3126394066fc1e62f347f321b4d276922e5e5a9a..b1109015c1f2b4e0480893e995278a8e0e45f22d 100644 --- a/djangoldp_notification/models.py +++ b/djangoldp_notification/models.py @@ -232,20 +232,7 @@ def send_request(target, object_iri, instance, created, serialize_object=False): "type": request_type } - # local inbox - if target.startswith(settings.SITE_URL): - user = Model.resolve_parent(target.replace(settings.SITE_URL, '')) - - # render the filters now, the resource is local - from djangoldp_notification.views import filter_object_is_permitted - - if not filter_object_is_permitted(user, json): - return - - Notification.objects.create(user=user, object=object_iri, type=request_type, author=author) - # external inbox - else: - ActivityQueueService.send_activity(target, json) + ActivityQueueService.send_activity(target, json) @receiver(post_save, sender=Notification) diff --git a/djangoldp_notification/tests/test_subscriptions.py b/djangoldp_notification/tests/test_subscriptions.py index eb9d6583bda9eca3c1b1012bcca20ad6d42d7ff1..a614a61881ee9fc00be742980fb40e9df49108a2 100644 --- a/djangoldp_notification/tests/test_subscriptions.py +++ b/djangoldp_notification/tests/test_subscriptions.py @@ -5,6 +5,7 @@ from django.conf import settings from django.test import override_settings from rest_framework.test import APITestCase, APIClient +from djangoldp.models import Activity from djangoldp_account.models import LDPUser from djangoldp_notification.models import Notification, Subscription @@ -24,15 +25,16 @@ class SubscriptionTestCase(APITestCase): self.user = self._get_random_user() self._auth_as_user(self.user) - @override_settings(SEND_BACKLINKS=True, DISABLE_OUTBOX=True) + # I can listen to changes on a container an receive a notification to a local inbox + @override_settings(SEND_BACKLINKS=True, DISABLE_OUTBOX='DEBUG') def test_can_subscribe_to_container(self): self.setUpLoggedInUser() users_container = "{}/users/".format(settings.SITE_URL) Subscription.objects.create(object=users_container, inbox=self.user.urlid + "inbox/") - self.assertEqual(self.user.inbox.count(), 0) + self.assertEqual(Activity.objects.count(), 0) new_user = self._get_random_user() - self.assertEqual(self.user.inbox.count(), 2) - notification = self.user.inbox.all()[0] - self.assertEqual(notification.object, new_user.urlid) + self.assertEqual(Activity.objects.count(), 2) + notification = Activity.objects.all()[0].to_activitystream() + self.assertEqual(notification['object'], new_user.urlid)