Skip to content

Commit

Permalink
feat: adding a notification limit and making it work with DEMO_INSTANCE
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed Mar 24, 2024
1 parent 60bc85a commit d4ddfc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/api_app/monitoring/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ def send_webhook(self, alert_data):

alert_body = {
"message": f"Alert {self.Alert.name} triggered for { text } {hash_}",
"notification_limit_details": {
"limit": self.Alert.smart_contract.owner_organization.notification_limit,
"current": Notification.objects.filter(
alert=self.Alert, notification_type="send_webhook"
).count(),
},
text: self.transaction.compile_to_dict(),
}

Expand Down
4 changes: 3 additions & 1 deletion backend/api_app/monitoring/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

@receiver(post_save, sender=SmartContract)
def smart_contract_post_save(sender, instance, created, **kwargs):
if created and not demo_instance:
# the following takes care of all the monitoring
# if created and not demo_instance:
if created:
# do on create
monitoring_task = MonitoringTasks.objects.create(
SmartContract=instance,
Expand Down

0 comments on commit d4ddfc4

Please sign in to comment.