Merge pull request #17084 from overleaf/dp-mongoose-callback-system-message-manager

Promisify SystemMessageManager and SystemMessageManagerTests

GitOrigin-RevId: b8fafdfdba817160c1b18cf7eb0270a27adf114c
This commit is contained in:
David
2024-02-19 09:43:28 +00:00
committed by Copybot
parent 6287a3f358
commit 29483271b8
5 changed files with 76 additions and 80 deletions
@@ -8,23 +8,19 @@ const ProjectController = {
// gracefully handle requests from anonymous users
return res.json([])
}
SystemMessageManager.getMessages((err, messages) => {
if (err) {
next(err)
} else {
if (!Settings.siteIsOpen) {
// Override all messages with notice for admins when site is closed.
messages = [
{
content:
'SITE IS CLOSED TO PUBLIC. OPEN ONLY FOR SITE ADMINS. DO NOT EDIT PROJECTS.',
_id: 'protected', // prevents hiding message in frontend
},
]
}
res.json(messages || [])
}
})
let messages = SystemMessageManager.getMessages()
if (!Settings.siteIsOpen) {
// Override all messages with notice for admins when site is closed.
messages = [
{
content:
'SITE IS CLOSED TO PUBLIC. OPEN ONLY FOR SITE ADMINS. DO NOT EDIT PROJECTS.',
_id: 'protected', // prevents hiding message in frontend
},
]
}
res.json(messages || [])
},
}