feat: restructure into XFlow monorepo with Nuxt 4, Modular Onion Monolith, Android client, and Desktop CLI
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { requireRole } from '~/server/utils/auth'
|
||||
import { pushSubscriptions } from '~/server/utils/db'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireRole(event, 'admin')
|
||||
const body = await readBody(event)
|
||||
const { title, message, userId } = body
|
||||
|
||||
const targets = userId
|
||||
? [pushSubscriptions.get(userId)].filter(Boolean)
|
||||
: Array.from(pushSubscriptions.values())
|
||||
|
||||
// In production, use web-push library with VAPID keys
|
||||
const results = targets.map((sub: any) => ({
|
||||
userId: sub.userId,
|
||||
sent: true,
|
||||
notification: { title, message, timestamp: new Date().toISOString() }
|
||||
}))
|
||||
|
||||
return { sent: results.length, results }
|
||||
})
|
||||
Reference in New Issue
Block a user