From 4c1d2ab1bbcab55f77f0f005cb046919a6c0a06b Mon Sep 17 00:00:00 2001 From: sadnub Date: Sat, 9 Apr 2022 23:56:04 -0400 Subject: [PATCH] fix agent not getting alert template when policies change --- api/tacticalrmm/automation/models.py | 2 ++ api/tacticalrmm/clients/models.py | 12 ++++++++++-- api/tacticalrmm/core/models.py | 8 ++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/api/tacticalrmm/automation/models.py b/api/tacticalrmm/automation/models.py index f11b6953..20ae6a03 100644 --- a/api/tacticalrmm/automation/models.py +++ b/api/tacticalrmm/automation/models.py @@ -45,6 +45,8 @@ class Policy(BaseAuditModel): if old_policy: if old_policy.alert_template != self.alert_template: cache_agents_alert_template.delay() + elif old_policy.active != self.active and self.alert_template: + cache_agents_alert_template.delay() def __str__(self) -> str: return self.name diff --git a/api/tacticalrmm/clients/models.py b/api/tacticalrmm/clients/models.py index 3ca00738..67322622 100644 --- a/api/tacticalrmm/clients/models.py +++ b/api/tacticalrmm/clients/models.py @@ -56,7 +56,11 @@ class Client(BaseAuditModel): # check if polcies have changed and initiate task to reapply policies if so if old_client: - if old_client.alert_template != self.alert_template: + if ( + old_client.alert_template != self.alert_template + or old_client.workstation_policy != self.workstation_policy + or old_client.server_policy != self.server_policy + ): cache_agents_alert_template.delay() class Meta: @@ -129,7 +133,11 @@ class Site(BaseAuditModel): # check if polcies have changed and initiate task to reapply policies if so if old_site: - if old_site.alert_template != self.alert_template: + if ( + old_site.alert_template != self.alert_template + or old_site.workstation_policy != self.workstation_policy + or old_site.server_policy != self.server_policy + ): cache_agents_alert_template.delay() class Meta: diff --git a/api/tacticalrmm/core/models.py b/api/tacticalrmm/core/models.py index ae3e532f..039661d6 100644 --- a/api/tacticalrmm/core/models.py +++ b/api/tacticalrmm/core/models.py @@ -107,8 +107,12 @@ class CoreSettings(BaseAuditModel): old_settings = type(self).objects.get(pk=self.pk) if self.pk else None super(BaseAuditModel, self).save(*args, **kwargs) - if old_settings and old_settings.alert_template != self.alert_template: - cache_agents_alert_template.delay() + if old_settings: + if ( + old_settings.alert_template != self.alert_template + or old_settings.policy != self.policy + ): + cache_agents_alert_template.delay() def __str__(self) -> str: return "Global Site Settings"