From 63b437e9d942b412facaa49d1ee0b3eb7f3a876f Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Pasquier <contact@jbpasquier.eu>
Date: Thu, 1 Oct 2020 11:40:46 +0200
Subject: [PATCH] fix: no nested subscriptions on the user model

---
 djangoldp_notification/models.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/djangoldp_notification/models.py b/djangoldp_notification/models.py
index 337e888..1fc0cec 100644
--- a/djangoldp_notification/models.py
+++ b/djangoldp_notification/models.py
@@ -2,6 +2,7 @@ import logging
 
 import requests
 from django.conf import settings
+from django.contrib.auth import get_user_model
 from django.core.mail import send_mail
 from django.core.exceptions import ObjectDoesNotExist
 from django.db import models
@@ -77,6 +78,10 @@ def create_nested_subscribers(sender, instance, created, **kwargs):
             local = Model.resolve(instance.object.replace(settings.SITE_URL, ''))[0]
             nested_fields = Model.get_meta(local, 'nested_fields', [])
 
+            # Don't create nested subscriptions for user model (Notification loop issue)
+            if local._meta.model_name == get_user_model()._meta.model_name:
+                return
+
             for nested_field in nested_fields:
                 try:
                     field = local._meta.get_field(nested_field)
-- 
GitLab