Drop FORGEJO_TOKEN requirement for update checking — repo is public

Forgejo's releases API and asset downloads both work unauthenticated
for a public repo. check_latest_release() no longer raises if
FORGEJO_TOKEN is blank; it only attaches the Authorization header when
one is actually set (e.g. if this repo ever goes private again).
This commit is contained in:
AI_Assistant 2026-08-22 13:35:12 +00:00
commit 4d55b8bfb0
No known key found for this signature in database

View file

@ -52,10 +52,11 @@ APP_VERSION = "0.1" # keep in sync with buildozer.spec's `version =` by hand
# Forgejo repo this app checks for updates against (ported from
# android-app-template — see that repo for the original writeup on each
# piece of this). Leave FORGEJO_TOKEN blank to disable update checking —
# the button still shows, but tells the user clearly that updates aren't
# configured rather than failing silently or crashing. Use a read-only
# token scoped to just this repo, never a general account token.
# piece of this). This repo is public, so FORGEJO_TOKEN is left blank —
# Forgejo's releases API and asset downloads both work unauthenticated
# for a public repo. Only set it if this repo ever goes private again;
# if so, use a read-only token scoped to just this repo, never a
# general account token.
FORGEJO_BASE_URL = "https://repo.tas-tech.net"
FORGEJO_OWNER = "tas-tech.net"
FORGEJO_REPO = "event-tracker"
@ -154,14 +155,9 @@ def check_latest_release():
"""
import certifi
if not FORGEJO_TOKEN:
raise RuntimeError(
"Update checking isn't configured — set FORGEJO_TOKEN at "
"the top of main.py."
)
url = f"{FORGEJO_BASE_URL}/api/v1/repos/{FORGEJO_OWNER}/{FORGEJO_REPO}/releases/latest"
req = urllib.request.Request(url, headers={"Authorization": f"token {FORGEJO_TOKEN}"})
headers = {"Authorization": f"token {FORGEJO_TOKEN}"} if FORGEJO_TOKEN else {}
req = urllib.request.Request(url, headers=headers)
ctx = ssl.create_default_context(cafile=certifi.where())
with urllib.request.urlopen(req, context=ctx, timeout=15) as resp:
data = json.load(resp)