Finish implementing webhook delivery
This commit is contained in:
@@ -174,6 +174,7 @@ class NotificationRule(models.Model):
|
||||
url = models.CharField(max_length=1024, null=True, blank=True)
|
||||
interval = models.IntegerField(choices=INTERVAL_CHOICES, default=0)
|
||||
window = models.CharField(max_length=255, null=True, blank=True)
|
||||
amount = models.PositiveIntegerField(default=1, null=True, blank=True)
|
||||
enabled = models.BooleanField(default=True)
|
||||
data = models.TextField()
|
||||
match = models.JSONField(null=True, blank=True)
|
||||
@@ -197,6 +198,23 @@ class NotificationRule(models.Model):
|
||||
if isinstance(self.match, dict):
|
||||
return f"{sum(list(self.match.values()))}/{len(self.match)}"
|
||||
|
||||
def get_notification_settings(self):
|
||||
"""
|
||||
Get the notification settings for this rule.
|
||||
Notification rule settings take priority.
|
||||
"""
|
||||
user_settings = self.user.get_notification_settings()
|
||||
user_settings = user_settings.__dict__
|
||||
if self.priority is not None:
|
||||
user_settings["priority"] = str(self.priority)
|
||||
if self.topic is not None:
|
||||
user_settings["topic"] = self.topic
|
||||
if self.url is not None:
|
||||
user_settings["url"] = self.url
|
||||
if self.service is not None:
|
||||
user_settings["service"] = self.service
|
||||
return user_settings
|
||||
|
||||
|
||||
class NotificationSettings(models.Model):
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
||||
|
||||
Reference in New Issue
Block a user