diff --git a/http/admin.go b/http/admin.go index 57dadc3..8f036ff 100644 --- a/http/admin.go +++ b/http/admin.go @@ -1520,3 +1520,8 @@ func (Admin) LogLevelSet(ctx context.Context, pkg string, levelStr string) { func (Admin) LogLevelRemove(ctx context.Context, pkg string) { mox.Conf.LogLevelRemove(pkg) } + +// CheckUpdatesEnabled returns whether checking for updates is enabled. +func (Admin) CheckUpdatesEnabled(ctx context.Context) bool { + return mox.Conf.Static.CheckUpdates +} diff --git a/http/admin.html b/http/admin.html index 70973e3..d6ae069 100644 --- a/http/admin.html +++ b/http/admin.html @@ -190,9 +190,10 @@ const formatSize = n => { } const index = async () => { - const [domains, queueSize] = await Promise.all([ + const [domains, queueSize, checkUpdatesEnabled] = await Promise.all([ await api.Domains(), await api.QueueSize(), + await api.CheckUpdatesEnabled(), ]) let fieldset, domain, account, localpart @@ -200,6 +201,7 @@ const index = async () => { const page = document.getElementById('page') dom._kids(page, crumbs('Mox Admin'), + checkUpdatesEnabled ? [] : dom.p(box(yellow, 'Warning: Checking for updates has not been enabled in mox.conf (CheckUpdates: true).', dom.br(), 'Make sure you stay up to date through another mechanism!', dom.br(), 'You have a responsibility to keep the internet-connected software you run up to date and secure!', dom.br(), 'See ', link('https://updates.xmox.nl/changelog'))), dom.p( dom.a('Accounts', attr({href: '#accounts'})), dom.br(), dom.a('Queue', attr({href: '#queue'})), ' ('+queueSize+')', dom.br(), diff --git a/http/adminapi.json b/http/adminapi.json index 462ce65..7d7812b 100644 --- a/http/adminapi.json +++ b/http/adminapi.json @@ -636,6 +636,19 @@ } ], "Returns": [] + }, + { + "Name": "CheckUpdatesEnabled", + "Docs": "CheckUpdatesEnabled returns whether checking for updates is enabled.", + "Params": [], + "Returns": [ + { + "Name": "r0", + "Typewords": [ + "bool" + ] + } + ] } ], "Sections": [], diff --git a/updates/updates.go b/updates/updates.go index 3e56f01..0198e1b 100644 --- a/updates/updates.go +++ b/updates/updates.go @@ -151,6 +151,7 @@ func FetchChangelog(ctx context.Context, baseURL string, base Version, pubKey [] if err != nil { return nil, fmt.Errorf("making request: %v", err) } + req.Header.Add("Accept", "application/json") resp, err := http.DefaultClient.Do(req) if resp == nil { resp = &http.Response{StatusCode: 0}