update: improve sender detection
This commit is contained in:
parent
d8ae6c1c75
commit
d317cb8b5d
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user