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:
parent
d7e5569dda
commit
4d55b8bfb0
1 changed files with 7 additions and 11 deletions
|
|
@ -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
|
# Forgejo repo this app checks for updates against (ported from
|
||||||
# android-app-template — see that repo for the original writeup on each
|
# android-app-template — see that repo for the original writeup on each
|
||||||
# piece of this). Leave FORGEJO_TOKEN blank to disable update checking —
|
# piece of this). This repo is public, so FORGEJO_TOKEN is left blank —
|
||||||
# the button still shows, but tells the user clearly that updates aren't
|
# Forgejo's releases API and asset downloads both work unauthenticated
|
||||||
# configured rather than failing silently or crashing. Use a read-only
|
# for a public repo. Only set it if this repo ever goes private again;
|
||||||
# token scoped to just this repo, never a general account token.
|
# 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_BASE_URL = "https://repo.tas-tech.net"
|
||||||
FORGEJO_OWNER = "tas-tech.net"
|
FORGEJO_OWNER = "tas-tech.net"
|
||||||
FORGEJO_REPO = "event-tracker"
|
FORGEJO_REPO = "event-tracker"
|
||||||
|
|
@ -154,14 +155,9 @@ def check_latest_release():
|
||||||
"""
|
"""
|
||||||
import certifi
|
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"
|
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())
|
ctx = ssl.create_default_context(cafile=certifi.where())
|
||||||
with urllib.request.urlopen(req, context=ctx, timeout=15) as resp:
|
with urllib.request.urlopen(req, context=ctx, timeout=15) as resp:
|
||||||
data = json.load(resp)
|
data = json.load(resp)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue