MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / handle_network_access_update

Function handle_network_access_update

core/signals.py:12–39  ·  view source on GitHub ↗

Invalidate cache and sync notifications when network access settings change.

(sender, instance, **kwargs)

Source from the content-addressed store, hash-verified

10
11@receiver(post_save, sender=CoreSettings)
12def handle_network_access_update(sender, instance, **kwargs):
13 """Invalidate cache and sync notifications when network access settings change."""
14 if instance.key == NETWORK_ACCESS_KEY:
15 from django.core.cache import cache
16 from core.developer_notifications import sync_developer_notifications
17 import logging
18
19 logger = logging.getLogger(__name__)
20
21 # Invalidate all notification condition caches
22 try:
23 cache.delete_pattern('dev_notif_condition_*')
24 logger.info("Invalidated notification condition cache due to network access settings update")
25 except Exception as e:
26 logger.warning(f"Failed to delete cache pattern: {e}")
27 # Fallback: try to clear entire cache (if delete_pattern not supported)
28 try:
29 cache.clear()
30 except Exception:
31 pass
32
33 # Re-sync developer notifications to re-evaluate conditions
34 # (websocket notification is sent by sync_developer_notifications)
35 try:
36 sync_developer_notifications()
37 logger.info("Re-synced developer notifications after network access settings update")
38 except Exception as e:
39 logger.error(f"Failed to sync developer notifications: {e}")

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected