securitynotice system -> updatenotice system

This commit is contained in:
Wingy 2021-09-13 23:13:19 -04:00
parent 2286bbd21c
commit d7ba61e339
3 changed files with 15 additions and 9 deletions

View file

@ -90,14 +90,13 @@ app.listen(config.port, () => logger.success('express', `Express server started
})() })()
;(() => { ;(() => {
async function getSecurityNotices () { async function checkUpdates () {
try { try {
const res = await fetch('https://gitlab.com/wingysam/christmas-community/-/raw/security-notices/security-notices.json') const res = await fetch('https://raw.githubusercontent.com/Wingysam/Christmas-Community/master/package.json')
const data = await res.json() const data = await res.json()
_CC.securityNotice = data[_CC.package.version] _CC.updateNotice = data.version === _CC.package.version
if (_CC.securityNotice) console.error(_CC.securityNotice)
} catch (_) {} } catch (_) {}
} }
getSecurityNotices() checkUpdates()
setInterval(getSecurityNotices, 1000 * 60 * 60) // hour setInterval(checkUpdates, 1000 * 60 * 60) // hour
})() })()

View file

@ -1,8 +1,6 @@
- successes = req.flash('success'); - successes = req.flash('success');
- errors = req.flash('error'); - errors = req.flash('error');
p.has-text-danger.is-size-4.has-text-weight-bold#securityNotice= _CC.securityNotice
if successes if successes
each success in successes each success in successes
p.has-text-success= (success.toString().startsWith('[object ') ? JSON.stringify(success) : success.toString()) p.has-text-success= (success.toString().startsWith('[object ') ? JSON.stringify(success) : success.toString())

View file

@ -41,3 +41,12 @@ html(lang='en')
h1 #{config.siteTitle} h1 #{config.siteTitle}
include includes/messages.pug include includes/messages.pug
block content block content
if req.user && req.user.admin && _CC.updateNotice
.columns
.column
.column.is-narrow
.box
span.has-text-danger.is-size-4.has-text-weight-bold Christmas Community is out of date. There may be new features or bug fixes. Consider updating! :)
br
span (you can turn this off with <code>UPDATE_CHECK=false</code>)
span.has-text-info(style='float: right;') This message is only visible to admins