Merge stable version before large change #16
@ -7,6 +7,12 @@
|
||||
<label class="font-bold">Beschrijving</label>
|
||||
<textarea v-model="form.description" required="true" class="input mb-5" />
|
||||
|
||||
<label class="font-bold">Groep</label>
|
||||
<select v-model="form.topic" required="true" class="input mb-5">
|
||||
<option value="all">Iedereen</option>
|
||||
<option value="test">Test</option>
|
||||
</select>
|
||||
|
||||
<div class="w-full flex flex-wrap justify-between">
|
||||
<input :disabled="disableButtons" type="submit" value="Stuur Bericht" class="btn w-full sm:w-40 mb-1">
|
||||
<button @click="router.back()" class="hover:underline font-bold w-full sm:w-max sm:ml-auto">Annuleer</button>
|
||||
@ -33,6 +39,7 @@ const disableButtons = ref(false)
|
||||
const form = ref({
|
||||
title: '',
|
||||
description: '',
|
||||
topic: ''
|
||||
})
|
||||
|
||||
const sendNews = async () => {
|
||||
@ -44,7 +51,7 @@ const sendNews = async () => {
|
||||
|
||||
const { error } = await useFetch('/api/sendmessage', {
|
||||
method: 'post',
|
||||
body: { title: form.value.title, body: form.value.description, token: idToken }
|
||||
body: { title: form.value.title, body: form.value.description, token: idToken, topic: form.value.topic }
|
||||
})
|
||||
|
||||
if (error.value) {
|
||||
|
@ -3,11 +3,13 @@ import { getAuth } from 'firebase-admin/auth'
|
||||
import { getMessaging } from 'firebase-admin/messaging'
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const { token, body, title } = await readBody(event);
|
||||
const { token, body, title, topic } = await readBody(event);
|
||||
|
||||
if (!token) throw createError({ statusCode: 400, statusMessage: 'no-token'})
|
||||
if (!body) throw createError({ statusCode: 400, statusMessage: 'no-body'})
|
||||
if (!title) throw createError({ statusCode: 400, statusMessage: 'no-title'})
|
||||
if (!topic) throw createError({ statusCode: 400, statusMessage: 'no-topic'})
|
||||
|
||||
|
||||
let decodedToken = null;
|
||||
|
||||
@ -42,7 +44,7 @@ export default defineEventHandler(async event => {
|
||||
icon: '/ios/256.png'
|
||||
}
|
||||
},
|
||||
topic: 'test',
|
||||
topic: topic,
|
||||
apns: {
|
||||
payload: {
|
||||
aps: {
|
||||
|
Loading…
Reference in New Issue
Block a user