Feedback-Window
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 50s

This commit is contained in:
Torsten Schulz (local)
2026-06-09 07:57:36 +02:00
parent f0142d5682
commit 16465fafc8
9 changed files with 208 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
import User from '../models/User.js';
import { sendMobileFeedbackEmail } from '../services/emailService.js';
const clean = (value, max = 4000) => String(value ?? '').trim().slice(0, max);
export const sendMobileFeedback = async (req, res) => {
try {
const message = clean(req.body?.message, 5000);
if (!message) {
return res.status(400).json({ error: 'message_required' });
}
const user = req.user?.id ? await User.findByPk(req.user.id) : null;
await sendMobileFeedbackEmail({
message,
screen: clean(req.body?.screen, 200),
clubId: req.body?.clubId ?? null,
appVersion: clean(req.body?.appVersion, 80),
platform: clean(req.body?.platform, 80) || 'Android',
backendBaseUrl: clean(req.body?.backendBaseUrl, 300),
user: user ? { id: user.id, username: user.username, email: user.email } : { id: req.user?.id },
});
return res.status(200).json({ success: true });
} catch (error) {
console.error('[sendMobileFeedback] - error:', error);
return res.status(500).json({ error: 'internalerror' });
}
};