mirror of
https://github.com/mjl-/mox.git
synced 2025-01-26 06:45:53 +03:00
on admin page, show warning when user hasn't enabled "check updates"
and send Accept-header when fetching changelog, so we can show an html version instead of json when requested by regular browsers.
This commit is contained in:
parent
d3590caa2e
commit
67c97c6499
4 changed files with 22 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -636,6 +636,19 @@
|
|||
}
|
||||
],
|
||||
"Returns": []
|
||||
},
|
||||
{
|
||||
"Name": "CheckUpdatesEnabled",
|
||||
"Docs": "CheckUpdatesEnabled returns whether checking for updates is enabled.",
|
||||
"Params": [],
|
||||
"Returns": [
|
||||
{
|
||||
"Name": "r0",
|
||||
"Typewords": [
|
||||
"bool"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Sections": [],
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue