Add setting to enable opting out of PHONEHOME

Fixes #52
This commit is contained in:
Klaas van Schelven
2025-03-03 09:26:06 +01:00
parent 1571a4f87f
commit d400d98a02
4 changed files with 7 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ DEFAULTS = {
# Security:
"MINIMIZE_INFORMATION_EXPOSURE": False,
"PHONEHOME": True,
}

View File

@@ -143,6 +143,8 @@ BUGSINK = {
"KEEP_ENVELOPES": int(os.getenv("KEEP_ENVELOPES", 0)), # keep this many in the database; 0 means "don't keep"
"MINIMIZE_INFORMATION_EXPOSURE":
os.getenv("MINIMIZE_INFORMATION_EXPOSURE", "false").lower() in ("true", "1", "yes"),
"PHONEHOME": os.getenv("PHONEHOME", "true").lower() in ("true", "1", "yes"),
}

View File

@@ -62,6 +62,8 @@ def _phone_home():
# features in snappea, [b] we introduce a certain symmetry of measurement between the 2 setups, i.e. the choice of
# lazyness does not influence counting and [c] do I really want to get pings for sites where nobody visits home()?
# NOTE: each time this function is called, it will schedule a new task, even when the task would quickly return
# (nothing due, or configured to never send). We _could_ improve that, but doesn't seem performance-critical enough.
send_if_due.delay() # _phone_home() wrapper serves as a place for the comment above

View File

@@ -32,6 +32,8 @@ INTERVAL = 60 * 60 # phone-home once an hour
def send_if_due():
# considered: not sending if DEBUG=True. But why? Expectation is: I'm the sole user of that setting. Better send
# also, to keep symmetry, and indirectly check whether my own phone-home still works.
if not get_settings().PHONEHOME:
return
# Note on attempted_at / sent_at distinction: attempted_at is when we first tried to send the message, and sent_at
# is when we actually sent it. This allows us to try only once an hour, as well as track whether sending succeeded.