From d7ba61e339f586096a0280c4e26c292fc8e479a9 Mon Sep 17 00:00:00 2001 From: Wingy Date: Mon, 13 Sep 2021 23:13:19 -0400 Subject: [PATCH] securitynotice system -> updatenotice system --- index.js | 11 +++++------ views/includes/messages.pug | 2 -- views/layout.pug | 11 ++++++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 213a771..09b6f88 100644 --- a/index.js +++ b/index.js @@ -90,14 +90,13 @@ app.listen(config.port, () => logger.success('express', `Express server started })() ;(() => { - async function getSecurityNotices () { + async function checkUpdates () { 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() - _CC.securityNotice = data[_CC.package.version] - if (_CC.securityNotice) console.error(_CC.securityNotice) + _CC.updateNotice = data.version === _CC.package.version } catch (_) {} } - getSecurityNotices() - setInterval(getSecurityNotices, 1000 * 60 * 60) // hour + checkUpdates() + setInterval(checkUpdates, 1000 * 60 * 60) // hour })() diff --git a/views/includes/messages.pug b/views/includes/messages.pug index 3ff24d9..8a25684 100644 --- a/views/includes/messages.pug +++ b/views/includes/messages.pug @@ -1,8 +1,6 @@ - successes = req.flash('success'); - errors = req.flash('error'); -p.has-text-danger.is-size-4.has-text-weight-bold#securityNotice= _CC.securityNotice - if successes each success in successes p.has-text-success= (success.toString().startsWith('[object ') ? JSON.stringify(success) : success.toString()) diff --git a/views/layout.pug b/views/layout.pug index 480b27e..213ed92 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -40,4 +40,13 @@ html(lang='en') else if title !== false h1 #{config.siteTitle} include includes/messages.pug - block content \ No newline at end of file + 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 UPDATE_CHECK=false) + span.has-text-info(style='float: right;') This message is only visible to admins \ No newline at end of file