PWA manager is now visible to all users
This commit is contained in:
@ -25,9 +25,20 @@ const Notification = async (req, res) => {
|
||||
if (req.method == 'GET') {
|
||||
res.statusCode = 200
|
||||
res.setHeader('Allow', 'POST')
|
||||
let subs = 0
|
||||
if (req.query && req.query.id) {
|
||||
const prisma = common.getPrismaClient();
|
||||
const publisher = await prisma.publisher.findUnique({
|
||||
where: { id: req.query.id },
|
||||
select: { pushSubscription: true }
|
||||
});
|
||||
subs = Array.isArray(publisher.pushSubscription) ? publisher.pushSubscription.length : (publisher.pushSubscription ? 1 : 0);
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
// send the public key in the response headers
|
||||
//res.setHeader('Content-Type', 'text/plain')
|
||||
res.end(process.env.NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY)
|
||||
res.send({ pk: process.env.NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY, subs })
|
||||
res.end()
|
||||
}
|
||||
if (req.method == 'PUT') {
|
||||
|
Reference in New Issue
Block a user