fix(webpush): only prompt user to allow notifications if enabled in user settings (#1552)

This commit is contained in:
TheCatLady
2021-05-03 23:40:32 -04:00
committed by GitHub
parent 6c9991d474
commit b05b177776
3 changed files with 12 additions and 4 deletions

View File

@@ -81,10 +81,16 @@ router.get('/status/appdata', (_req, res) => {
});
router.use('/user', isAuthenticated(), user);
router.get('/settings/public', async (_req, res) => {
router.get('/settings/public', async (req, res) => {
const settings = getSettings();
return res.status(200).json(settings.fullPublicSettings);
if (!req.user?.settings?.notificationTypes.webpush) {
return res
.status(200)
.json({ ...settings.fullPublicSettings, enablePushRegistration: false });
} else {
return res.status(200).json(settings.fullPublicSettings);
}
});
router.use(
'/settings',