Admin: Reiter E-Mail-Speicher, Abo mit Produkt; Schnittstelle fürs Ticketsystem

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Fable 5.1 committed 2026-09-29 14:37:42 +00:00
1 parent 19f9c747a2
commit 63d3bb11bf
10 files changed
+525 -4

No files matched your search

+19
View File
@@ -1,5 +1,7 @@
import { Router } from 'express'
import { requireAppwriteStaff } from '../../middleware/appwriteStaff.js'
import { PRODUCT_KEYS } from '../../services/products.js'
import { ACTIVE_STATUSES, getCurrentSubscription } from '../../services/stripeBilling.js'
import {
createCustomerWithPortalAccess,
deleteCustomerWithPortalAccess,
@@ -41,6 +43,23 @@ router.patch('/:customerId', async (req, res) => {
}
})
// Schnittstelle fuers Ticketsystem (Task 13): Produkt und Stand des Abos eines Kunden. WOMS liest daraus,
// ob der Kunde ein Wartungs-Abo hat (Arbeitszeit-Kontingent). Altbestand ohne productKey gilt als
// Wartungs-Abo (wie offers.js/takeoverCredits.js); ohne Abo productKey null.
router.get('/:customerId/abo', async (req, res) => {
try {
const sub = await getCurrentSubscription(req.params.customerId)
if (!sub) return res.json({ productKey: null, active: false })
return res.json({
productKey: PRODUCT_KEYS.includes(sub.productKey) ? sub.productKey : 'wartung',
active: ACTIVE_STATUSES.has(sub.status),
})
} catch (err) {
const status = err.status || 500
return res.status(status).json({ error: err.message || 'Abo konnte nicht geladen werden' })
}
})
router.delete('/:customerId', async (req, res) => {
try {
return res.json(await deleteCustomerWithPortalAccess(req.params.customerId))