Compare commits
13 Commits
dev
...
7ac2fd39da
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ac2fd39da | |||
| 4705d411d5 | |||
| 64bd7d56e5 | |||
| 446ec752b4 | |||
| aa3d065294 | |||
| ffc4b66601 | |||
| f1fc5eafc3 | |||
| 42398dad21 | |||
| d563d81584 | |||
| 380d0a8332 | |||
| 301bd7acbd | |||
| 05e25aa3d1 | |||
| ecae88af78 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -94,8 +94,6 @@ dist
|
||||
/android-app/**/build/
|
||||
/android-app/local.properties
|
||||
/android-app/gradle-local.properties
|
||||
# Android Play Store / release artifacts are generated locally or in CI.
|
||||
/android-app/**/*.aab
|
||||
# JVM Heap-Dumps sind lokale Diagnoseartefakte und dürfen nie ins Repository.
|
||||
*.hprof
|
||||
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
# Intentionally empty: retained because the CI scanner is invoked with --config.
|
||||
[[IgnoredVulns]]
|
||||
id = "GHSA-v3m3-f69x-jf25"
|
||||
ignoreUntil = 2026-12-31
|
||||
reason = "Temporary exception: Quill 2.0.3 is required by the current RichTextEditor implementation, and OSV currently reports no fixed version. Track upstream fix and remove this ignore once a patched release is available."
|
||||
|
||||
BIN
android-app/app/instantTest/release/app-instantTest-release.aab
Executable file
BIN
android-app/app/instantTest/release/app-instantTest-release.aab
Executable file
Binary file not shown.
BIN
android-app/app/local/release/app-local-release.aab
Executable file
BIN
android-app/app/local/release/app-local-release.aab
Executable file
Binary file not shown.
BIN
android-app/app/production/release/app-production-release.aab
Normal file
BIN
android-app/app/production/release/app-production-release.aab
Normal file
Binary file not shown.
@@ -283,7 +283,6 @@ data class PushTokenRequest(
|
||||
val token: String,
|
||||
val platform: String = "android",
|
||||
val appVersion: String? = null,
|
||||
val installationId: String? = null,
|
||||
)
|
||||
data class BirthdayDto(
|
||||
val name: String = "",
|
||||
|
||||
@@ -21,7 +21,7 @@ class HarheimerMessagingService : FirebaseMessagingService() {
|
||||
override fun onNewToken(token: String) {
|
||||
super.onNewToken(token)
|
||||
serviceScope.launch {
|
||||
pushTokenRepository.registerCurrentDevice()
|
||||
pushTokenRepository.registerToken(token)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ object HarheimerNotifications {
|
||||
"news", "news_expiring" -> Destinations.MemberNews.route
|
||||
"event", "events_today", "events_tomorrow" -> Destinations.Termine.route
|
||||
"team_matches" -> Destinations.Spielplan.route
|
||||
"qttr_list_updated", "ttr_change" -> Destinations.Qttr.route
|
||||
"birthdays" -> Destinations.MemberArea.route
|
||||
"contact_request" -> Destinations.CmsContactRequests.route
|
||||
"user_registration" -> Destinations.CmsBenutzer.route
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.harheimertc.repositories
|
||||
|
||||
import android.util.Log
|
||||
import com.google.firebase.installations.FirebaseInstallations
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import de.harheimertc.BuildConfig
|
||||
import de.harheimertc.data.ApiService
|
||||
@@ -16,18 +15,16 @@ class PushTokenRepository @Inject constructor(
|
||||
) {
|
||||
suspend fun registerCurrentDevice(): Result<Unit> = runCatching {
|
||||
val token = FirebaseMessaging.getInstance().token.await()
|
||||
val installationId = FirebaseInstallations.getInstance().id.await()
|
||||
registerToken(token, installationId).getOrThrow()
|
||||
registerToken(token).getOrThrow()
|
||||
}
|
||||
|
||||
suspend fun registerToken(token: String, installationId: String? = null): Result<Unit> = runCatching {
|
||||
suspend fun registerToken(token: String): Result<Unit> = runCatching {
|
||||
if (token.isBlank()) return@runCatching
|
||||
retryOnNetworkFailure {
|
||||
val response = api.registerPushToken(
|
||||
PushTokenRequest(
|
||||
token = token,
|
||||
appVersion = "${BuildConfig.VERSION_NAME}+${BuildConfig.VERSION_CODE}",
|
||||
installationId = installationId,
|
||||
),
|
||||
)
|
||||
if (!response.isSuccessful) {
|
||||
|
||||
@@ -8,8 +8,8 @@ LOCAL_API_BASE_URL=https://harheimertc.tsschulz.de/
|
||||
PRODUCTION_API_BASE_URL=https://harheimertc.de/
|
||||
|
||||
# Android app versioning for Play Store uploads
|
||||
ANDROID_VERSION_CODE=36
|
||||
ANDROID_VERSION_NAME=0.10.0
|
||||
ANDROID_VERSION_CODE=35
|
||||
ANDROID_VERSION_NAME=0.9.30
|
||||
|
||||
# Temporary hotfix: disable R8 minification for release to avoid Retrofit generic signature stripping.
|
||||
RELEASE_MINIFY_ENABLED=false
|
||||
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -5252,9 +5252,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/devalue": {
|
||||
"version": "5.9.2",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.2.tgz",
|
||||
"integrity": "sha512-po4PAY5c53tw5XMocSnf8A/5OHhbbUftpr93aEN6BBoAdntUmK7vu7wOATqvt7cXO7m1Cl4gMVn6p7n6n4mj0w==",
|
||||
"version": "5.9.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.0.tgz",
|
||||
"integrity": "sha512-RWrqdArjvPbsATEhOPUo6Wndc/iWnkWKlhIrdlF3zMMYo/c3CVtoaVAyLtWxz5h8nSlkHzxnzV2uLydPXmtF+A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dezalgo": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "harheimertc-website",
|
||||
"version": "1.8.10",
|
||||
"version": "1.8.9",
|
||||
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -68,7 +68,6 @@
|
||||
},
|
||||
"overrides": {
|
||||
"@peculiar/x509": "1.13.0",
|
||||
"devalue": "5.9.2",
|
||||
"esbuild": "0.28.1",
|
||||
"qs": "6.16.0"
|
||||
}
|
||||
|
||||
@@ -208,18 +208,11 @@
|
||||
>
|
||||
<div class="flex items-center mb-4">
|
||||
<div class="w-12 h-12 bg-teal-100 rounded-lg flex items-center justify-center group-hover:bg-teal-600 transition-colors">
|
||||
<RefreshCw
|
||||
:size="24"
|
||||
class="text-teal-600 group-hover:text-white"
|
||||
/>
|
||||
<RefreshCw :size="24" class="text-teal-600 group-hover:text-white" />
|
||||
</div>
|
||||
<h2 class="ml-4 text-xl font-semibold text-gray-900">
|
||||
myTischtennis
|
||||
</h2>
|
||||
<h2 class="ml-4 text-xl font-semibold text-gray-900">myTischtennis</h2>
|
||||
</div>
|
||||
<p class="text-gray-600">
|
||||
Vereinszugang und TTR-Synchronisierung
|
||||
</p>
|
||||
<p class="text-gray-600">Vereinszugang und TTR-Synchronisierung</p>
|
||||
</NuxtLink>
|
||||
|
||||
<!-- Benutzerverwaltung (Admin ODER Vorstand) -->
|
||||
|
||||
@@ -1,94 +1,33 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 py-10">
|
||||
<div class="max-w-2xl mx-auto px-4">
|
||||
<h1 class="text-3xl font-display font-bold text-gray-900">
|
||||
myTischtennis-Verbindung
|
||||
</h1>
|
||||
<p class="mt-2 text-gray-600">
|
||||
Vereinszugang für den geschützten Import aktueller TTR- und QTTR-Werte.
|
||||
</p>
|
||||
<form
|
||||
class="mt-8 bg-white rounded-xl shadow-lg p-6 space-y-5"
|
||||
@submit.prevent="save"
|
||||
>
|
||||
<h1 class="text-3xl font-display font-bold text-gray-900">myTischtennis-Verbindung</h1>
|
||||
<p class="mt-2 text-gray-600">Vereinszugang für den geschützten Import aktueller TTR- und QTTR-Werte.</p>
|
||||
<form class="mt-8 bg-white rounded-xl shadow-lg p-6 space-y-5" @submit.prevent="save">
|
||||
<div class="rounded-lg bg-amber-50 border border-amber-200 p-4 text-sm text-amber-900">
|
||||
Das Passwort wird verschlüsselt auf dem Server gespeichert und nie wieder angezeigt. Zugriff haben ausschließlich Admin und Vorstand.
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">myTischtennis-E-Mail</label>
|
||||
<input
|
||||
v-model.trim="form.email"
|
||||
type="email"
|
||||
required
|
||||
autocomplete="username"
|
||||
class="w-full rounded-lg border border-gray-300 px-3 py-2"
|
||||
>
|
||||
<input v-model.trim="form.email" type="email" required autocomplete="username" class="w-full rounded-lg border border-gray-300 px-3 py-2">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Passwort</label>
|
||||
<input
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
class="w-full rounded-lg border border-gray-300 px-3 py-2"
|
||||
>
|
||||
<input v-model="form.password" type="password" required autocomplete="current-password" class="w-full rounded-lg border border-gray-300 px-3 py-2">
|
||||
</div>
|
||||
<div class="grid sm:grid-cols-2 gap-4">
|
||||
<label class="block text-sm font-medium text-gray-700">Verband<input
|
||||
v-model.trim="form.association"
|
||||
required
|
||||
class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2"
|
||||
></label>
|
||||
<label class="block text-sm font-medium text-gray-700">Vereinsnummer<input
|
||||
v-model.trim="form.clubId"
|
||||
required
|
||||
class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2"
|
||||
></label>
|
||||
<label class="block text-sm font-medium text-gray-700">Verband<input v-model.trim="form.association" required class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2"></label>
|
||||
<label class="block text-sm font-medium text-gray-700">Vereinsnummer<input v-model.trim="form.clubId" required class="mt-1 w-full rounded-lg border border-gray-300 px-3 py-2"></label>
|
||||
</div>
|
||||
<p
|
||||
v-if="status.configured"
|
||||
class="text-sm text-gray-600"
|
||||
>
|
||||
Hinterlegt: {{ status.email }} · letzter erfolgreicher Abruf: {{ formattedLastImport }}
|
||||
</p>
|
||||
<p
|
||||
v-if="status.lastImportError"
|
||||
class="rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800"
|
||||
>
|
||||
<p v-if="status.configured" class="text-sm text-gray-600">Hinterlegt: {{ status.email }} · letzter erfolgreicher Abruf: {{ formattedLastImport }}</p>
|
||||
<p v-if="status.lastImportError" class="rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800">
|
||||
Letzter Abruf fehlgeschlagen: {{ status.lastImportError }}
|
||||
</p>
|
||||
<p
|
||||
v-if="message"
|
||||
class="text-sm"
|
||||
:class="error ? 'text-red-700' : 'text-green-700'"
|
||||
>
|
||||
{{ message }}
|
||||
</p>
|
||||
<p v-if="message" class="text-sm" :class="error ? 'text-red-700' : 'text-green-700'">{{ message }}</p>
|
||||
<div class="flex gap-3 flex-wrap">
|
||||
<button
|
||||
:disabled="busy"
|
||||
class="rounded-lg bg-primary-600 px-4 py-2 font-semibold text-white disabled:opacity-60"
|
||||
>
|
||||
Zugang speichern
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="busy || !status.configured"
|
||||
class="rounded-lg border border-primary-600 px-4 py-2 font-semibold text-primary-700 disabled:opacity-60"
|
||||
@click="runImport"
|
||||
>
|
||||
Jetzt abrufen
|
||||
</button>
|
||||
<button
|
||||
v-if="authStore.hasRole('admin')"
|
||||
type="button"
|
||||
:disabled="busy"
|
||||
class="rounded-lg border border-teal-600 px-4 py-2 font-semibold text-teal-700 disabled:opacity-60"
|
||||
@click="sendTestPush"
|
||||
>
|
||||
Push-Test an mich senden
|
||||
</button>
|
||||
<button :disabled="busy" class="rounded-lg bg-primary-600 px-4 py-2 font-semibold text-white disabled:opacity-60">Zugang speichern</button>
|
||||
<button type="button" :disabled="busy || !status.configured" class="rounded-lg border border-primary-600 px-4 py-2 font-semibold text-primary-700 disabled:opacity-60" @click="runImport">Jetzt abrufen</button>
|
||||
<button v-if="authStore.hasRole('admin')" type="button" :disabled="busy" class="rounded-lg border border-teal-600 px-4 py-2 font-semibold text-teal-700 disabled:opacity-60" @click="sendTestPush">Push-Test an mich senden</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
<div class="bg-white rounded-xl shadow-lg border border-gray-100 p-6">
|
||||
<div class="flex flex-wrap items-center gap-4 justify-between mb-4">
|
||||
<div class="flex flex-wrap items-end gap-x-4 gap-y-3">
|
||||
<div>
|
||||
<h2 class="text-xl font-semibold text-gray-900">
|
||||
Harheimer TC Rangliste
|
||||
@@ -22,31 +21,6 @@
|
||||
{{ data?.title || 'Andro-Rangliste' }} · {{ data?.rowCount || 0 }} Einträge
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="inline-flex rounded-md border border-gray-200 bg-gray-50 p-0.5 shadow-sm"
|
||||
role="group"
|
||||
aria-label="Rangliste sortieren nach"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1.5 text-sm font-semibold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2"
|
||||
:class="sortBy === 'qttr' ? 'bg-primary-600 text-white shadow-sm' : 'text-gray-700 hover:bg-white hover:text-primary-700'"
|
||||
:aria-pressed="sortBy === 'qttr'"
|
||||
@click="sortBy = 'qttr'"
|
||||
>
|
||||
QTTR
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded px-3 py-1.5 text-sm font-semibold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2"
|
||||
:class="sortBy === 'ttr' ? 'bg-primary-600 text-white shadow-sm' : 'text-gray-700 hover:bg-white hover:text-primary-700'"
|
||||
:aria-pressed="sortBy === 'ttr'"
|
||||
@click="sortBy = 'ttr'"
|
||||
>
|
||||
TTR
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
Aktualisiert: {{ formatDate(data?.importedAt) }}
|
||||
</div>
|
||||
@@ -72,7 +46,7 @@
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">
|
||||
Vereinsrang<br>(QTTR / TTR)
|
||||
Rang
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-gray-500">
|
||||
Spieler
|
||||
@@ -90,14 +64,12 @@
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100 bg-white">
|
||||
<tr
|
||||
v-for="row in sortedRows"
|
||||
:key="row.playerNumber || row.playerName"
|
||||
v-for="row in data?.rows || []"
|
||||
:key="`${row.rank}-${row.playerNumber || row.playerName}`"
|
||||
:class="isOwnRow(row.playerName) ? 'bg-primary-100' : ''"
|
||||
>
|
||||
<td class="px-4 py-3 text-sm text-gray-600">
|
||||
<span :title="clubRankTitle(row)">
|
||||
{{ formatClubRank(row) }}
|
||||
</span>
|
||||
{{ row.rank ?? '–' }}
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div :class="['font-medium', getPlayerNameClass(row)]">
|
||||
@@ -123,7 +95,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
|
||||
@@ -137,34 +109,6 @@ await authStore.checkAuth()
|
||||
const { data, pending, error } = await useFetch('/api/mitgliederbereich/qttr')
|
||||
|
||||
const currentUserName = computed(() => authStore.user?.name?.trim() || '')
|
||||
const sortBy = ref('qttr')
|
||||
|
||||
const sortedRows = computed(() => {
|
||||
const rows = [...(data.value?.rows || [])]
|
||||
const byName = (a, b) => String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de')
|
||||
const byRating = (key) => (a, b) => b[key] - a[key] || byName(a, b)
|
||||
|
||||
if (sortBy.value === 'ttr') {
|
||||
return rows.sort((a, b) => {
|
||||
const aMissing = a.currentTtr == null
|
||||
const bMissing = b.currentTtr == null
|
||||
if (aMissing !== bMissing) return aMissing ? 1 : -1
|
||||
return aMissing ? byName(a, b) : byRating('currentTtr')(a, b)
|
||||
})
|
||||
}
|
||||
|
||||
return rows.sort((a, b) => {
|
||||
const aMissing = a.currentQttr == null
|
||||
const bMissing = b.currentQttr == null
|
||||
if (aMissing !== bMissing) return aMissing ? 1 : -1
|
||||
if (!aMissing) return byRating('currentQttr')(a, b)
|
||||
|
||||
const aMissingTtr = a.currentTtr == null
|
||||
const bMissingTtr = b.currentTtr == null
|
||||
if (aMissingTtr !== bMissingTtr) return aMissingTtr ? 1 : -1
|
||||
return aMissingTtr ? byName(a, b) : byRating('currentTtr')(a, b)
|
||||
})
|
||||
})
|
||||
|
||||
function normalizeName(value) {
|
||||
return String(value || '').trim().toLowerCase().replace(/\s+/g, ' ')
|
||||
@@ -189,14 +133,6 @@ function isOwnRow(playerName) {
|
||||
return normalizeName(playerName) === current
|
||||
}
|
||||
|
||||
function formatClubRank(row) {
|
||||
return `${row.clubQttrRank ?? '–'} (${row.clubTtrRank ?? '–'})`
|
||||
}
|
||||
|
||||
function clubRankTitle(row) {
|
||||
return `QTTR-Platzierung im Verein: ${row.clubQttrRank ?? 'nicht verfügbar'}; TTR-Platzierung im Verein: ${row.clubTtrRank ?? 'nicht verfügbar'}`
|
||||
}
|
||||
|
||||
function getPlayerNameClass(row) {
|
||||
const minor = isMinor(row.birthdate)
|
||||
if (minor && isMaleGender(row.gender)) return 'text-blue-400'
|
||||
|
||||
@@ -37,26 +37,6 @@ function buildBirthdateLookup(entries) {
|
||||
return lookup
|
||||
}
|
||||
|
||||
function addClubRanks(rows) {
|
||||
const addRankFor = (valueKey, rankKey) => {
|
||||
rows
|
||||
.filter((row) => row[valueKey] != null)
|
||||
.sort((a, b) => b[valueKey] - a[valueKey] || String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de'))
|
||||
.forEach((row, index) => {
|
||||
row[rankKey] = index + 1
|
||||
})
|
||||
}
|
||||
|
||||
addRankFor('currentQttr', 'clubQttrRank')
|
||||
addRankFor('currentTtr', 'clubTtrRank')
|
||||
|
||||
return rows.sort((a, b) =>
|
||||
(a.clubQttrRank ?? Number.POSITIVE_INFINITY) - (b.clubQttrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| (a.clubTtrRank ?? Number.POSITIVE_INFINITY) - (b.clubTtrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de')
|
||||
)
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const token = getCookie(event, 'auth_token') || getHeader(event, 'authorization')?.replace(/^Bearer\s+/i, '')
|
||||
if (!token || !verifyToken(token)) {
|
||||
@@ -93,16 +73,16 @@ export default defineEventHandler(async (event) => {
|
||||
].flatMap(entry => [entry?.name, `${entry?.firstName || ''} ${entry?.lastName || ''}`.trim()]).map(normalizeName).filter(Boolean))
|
||||
const birthdateLookup = buildBirthdateLookup([...visibleManualMembers, ...visibleUsers])
|
||||
|
||||
const rankedRows = addClubRanks(Array.isArray(payload.rows) ? payload.rows.map(row => ({ ...row })) : [])
|
||||
|
||||
return {
|
||||
...payload,
|
||||
rows: rankedRows
|
||||
rows: Array.isArray(payload.rows)
|
||||
? payload.rows
|
||||
.filter(row => !hiddenNames.has(normalizeName(row.playerName)))
|
||||
.map((row) => ({
|
||||
...row,
|
||||
birthdate: birthdateLookup.get(normalizeName(row.playerName)) || row.birthdate || ''
|
||||
}))
|
||||
: []
|
||||
}
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') {
|
||||
|
||||
@@ -22,8 +22,7 @@ export default defineEventHandler(async (event) => {
|
||||
upsertPushToken(users[userIndex], {
|
||||
token: body.token,
|
||||
platform: body.platform || 'android',
|
||||
appVersion: body.appVersion || null,
|
||||
installationId: body.installationId || null
|
||||
appVersion: body.appVersion || null
|
||||
})
|
||||
await writeUsers(users)
|
||||
return { success: true, message: 'Push-Token gespeichert.' }
|
||||
|
||||
@@ -85,21 +85,16 @@ function pushTokensForUser(user) {
|
||||
: []
|
||||
}
|
||||
|
||||
export function upsertPushToken(user, { token, platform = 'android', appVersion = null, installationId = null }) {
|
||||
export function upsertPushToken(user, { token, platform = 'android', appVersion = null }) {
|
||||
const normalizedToken = String(token || '').trim()
|
||||
if (!normalizedToken) return user
|
||||
const normalizedInstallationId = String(installationId || '').trim().slice(0, 200) || null
|
||||
const now = new Date().toISOString()
|
||||
const tokens = Array.isArray(user.pushTokens) ? user.pushTokens : []
|
||||
// A Firebase token can rotate for the same app installation. Retain tokens
|
||||
// from other devices, but replace the previous token of this installation.
|
||||
const next = tokens.filter(entry => entry?.token !== normalizedToken &&
|
||||
(!normalizedInstallationId || entry?.installationId !== normalizedInstallationId))
|
||||
const next = tokens.filter(entry => entry?.token !== normalizedToken)
|
||||
next.push({
|
||||
token: normalizedToken,
|
||||
platform: String(platform || 'android').slice(0, 30),
|
||||
appVersion: appVersion ? String(appVersion).slice(0, 80) : null,
|
||||
installationId: normalizedInstallationId,
|
||||
updatedAt: now,
|
||||
createdAt: tokens.find(entry => entry?.token === normalizedToken)?.createdAt || now
|
||||
})
|
||||
@@ -334,19 +329,6 @@ export async function sendOwnTtrChangePush(changes = []) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function sendQttrListUpdatedPush({ importedAt, rowCount }) {
|
||||
return sendPushToUsers({
|
||||
title: 'QTTR-Liste aktualisiert',
|
||||
body: `Die aktuelle TTR- und QTTR-Liste wurde aktualisiert (${rowCount} Einträge).`,
|
||||
data: {
|
||||
type: 'qttr_list_updated',
|
||||
importedAt: importedAt || '',
|
||||
notificationId: notificationIdFor(`qttr-list:${importedAt || Date.now()}`)
|
||||
},
|
||||
failureLabel: 'FCM QTTR-Listen-Push'
|
||||
})
|
||||
}
|
||||
|
||||
export async function sendTestPushToUser(userId) {
|
||||
return sendPushToUsers({
|
||||
title: 'Harheimer TC: Push-Test',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import { getServerDataPath } from './paths.js'
|
||||
import { sendOwnTtrChangePush, sendQttrListUpdatedPush } from './push-notifications.js'
|
||||
import { sendOwnTtrChangePush } from './push-notifications.js'
|
||||
import { fetchClubRankings } from './mytischtennis-client.js'
|
||||
import { readMyTischtennisConnection, saveMyTischtennisConnection } from './mytischtennis-connection.js'
|
||||
|
||||
@@ -67,26 +67,6 @@ function normalizeGender(value) {
|
||||
return normalized || null
|
||||
}
|
||||
|
||||
function addClubRanks(rows) {
|
||||
const addRankFor = (valueKey, rankKey) => {
|
||||
rows
|
||||
.filter((row) => row[valueKey] != null)
|
||||
.sort((a, b) => b[valueKey] - a[valueKey] || String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de'))
|
||||
.forEach((row, index) => {
|
||||
row[rankKey] = index + 1
|
||||
})
|
||||
}
|
||||
|
||||
addRankFor('currentQttr', 'clubQttrRank')
|
||||
addRankFor('currentTtr', 'clubTtrRank')
|
||||
|
||||
return rows.sort((a, b) =>
|
||||
(a.clubQttrRank ?? Number.POSITIVE_INFINITY) - (b.clubQttrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| (a.clubTtrRank ?? Number.POSITIVE_INFINITY) - (b.clubTtrRank ?? Number.POSITIVE_INFINITY)
|
||||
|| String(a.playerName || '').localeCompare(String(b.playerName || ''), 'de')
|
||||
)
|
||||
}
|
||||
|
||||
function extractTableBlocks(html) {
|
||||
return [...String(html || '').matchAll(/<table\b[^>]*>[\s\S]*?<\/table>/gi)].map((match) => match[0])
|
||||
}
|
||||
@@ -210,7 +190,7 @@ export async function importQttrValues(options = {}) {
|
||||
throw new Error('QTTR-Tabelle ist leer oder unvollständig')
|
||||
}
|
||||
|
||||
const parsedRows = addClubRanks(rows.map((cells) => deriveQttrFields(headers, cells)))
|
||||
const parsedRows = rows.map((cells) => deriveQttrFields(headers, cells))
|
||||
const payload = {
|
||||
format: 'harheimertc.qttr.v1',
|
||||
importedAt: new Date().toISOString(),
|
||||
@@ -263,11 +243,7 @@ async function importAuthenticatedTtrValues(connection) {
|
||||
})
|
||||
}).filter(row => row.playerName && (row.currentTtr != null || row.currentQttr != null))
|
||||
|
||||
addClubRanks(rows)
|
||||
|
||||
if (!rows.length) throw new Error('Keine verwertbaren TTR-Werte in der myTischtennis-Rangliste gefunden.')
|
||||
const previousQttrSignature = qttrListSignature(previousPayload.rows)
|
||||
const nextQttrSignature = qttrListSignature(rows)
|
||||
const importedAt = new Date().toISOString()
|
||||
const payload = {
|
||||
format: 'harheimertc.qttr.v2', importedAt,
|
||||
@@ -286,21 +262,6 @@ async function importAuthenticatedTtrValues(connection) {
|
||||
: []
|
||||
})
|
||||
await sendOwnTtrChangePush(changes)
|
||||
if (previousQttrSignature && previousQttrSignature !== nextQttrSignature) {
|
||||
await sendQttrListUpdatedPush({ importedAt, rowCount: rows.length })
|
||||
}
|
||||
await saveMyTischtennisConnection({ ...connection, lastSuccessfulImportAt: importedAt, lastImportError: null })
|
||||
return { outputFile: OUTPUT_FILE, tableCount: 1, ...payload }
|
||||
}
|
||||
|
||||
function qttrListSignature(rows) {
|
||||
if (!Array.isArray(rows) || rows.length === 0) return ''
|
||||
return rows
|
||||
.map(row => [
|
||||
String(row?.playerName || '').trim().toLocaleLowerCase('de-DE'),
|
||||
row?.rank ?? '',
|
||||
row?.currentQttr ?? ''
|
||||
].join('|'))
|
||||
.sort()
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ describe('Config & Profil Endpoints', () => {
|
||||
|
||||
it('speichert Android-Push-Token am Benutzer', async () => {
|
||||
const event = createEvent({ headers: { authorization: 'Bearer android-token' } })
|
||||
mockSuccessReadBody({ token: 'fcm-token', platform: 'android', appVersion: '1.0+1', installationId: 'firebase-installation-id' })
|
||||
mockSuccessReadBody({ token: 'fcm-token', platform: 'android', appVersion: '1.0+1' })
|
||||
const users = [{ id: '1', email: 'max@test.de', roles: ['mitglied'] }]
|
||||
authUtils.verifyToken.mockReturnValue({ id: '1' })
|
||||
authUtils.getUserFromToken.mockResolvedValue(users[0])
|
||||
@@ -260,7 +260,7 @@ describe('Config & Profil Endpoints', () => {
|
||||
expect(authUtils.writeUsers).toHaveBeenCalledWith([
|
||||
expect.objectContaining({
|
||||
id: '1',
|
||||
pushTokens: [expect.objectContaining({ token: 'fcm-token', platform: 'android', appVersion: '1.0+1', installationId: 'firebase-installation-id' })]
|
||||
pushTokens: [expect.objectContaining({ token: 'fcm-token', platform: 'android', appVersion: '1.0+1' })]
|
||||
})
|
||||
])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user