Bugfixes im Dating und im Profil
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
Some checks failed
Host-Based Deploy (Java 21 Fix) / build-and-run (push) Has been cancelled
This commit is contained in:
@@ -529,15 +529,41 @@
|
||||
if (!text) return;
|
||||
input.value = '';
|
||||
try {
|
||||
await fetch('/social/messages', {
|
||||
const res = await fetch('/social/messages', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ receiverId: activePartnerId, text })
|
||||
});
|
||||
if (res.status === 403) {
|
||||
let reason = '';
|
||||
try { const body = await res.json(); reason = body.reason; } catch (_) {}
|
||||
if (reason === 'FIRST_MESSAGE_RESTRICTED') {
|
||||
showThreadNotice('Du kannst diese Person nur anschreiben, wenn ihr befreundet seid, ein Match habt oder du ein Pro-Abo hast.');
|
||||
} else if (reason === 'BLOCKED') {
|
||||
showThreadNotice('Diese Konversation ist nicht mehr möglich.');
|
||||
} else {
|
||||
showThreadNotice('Nachricht konnte nicht gesendet werden.');
|
||||
}
|
||||
// Text wieder zurücksetzen, damit der User ihn nicht verliert
|
||||
input.value = text;
|
||||
return;
|
||||
}
|
||||
await pollNewMessages();
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
function showThreadNotice(msg) {
|
||||
const existing = document.getElementById('threadNotice');
|
||||
if (existing) existing.remove();
|
||||
const notice = document.createElement('div');
|
||||
notice.id = 'threadNotice';
|
||||
notice.style.cssText = 'background:rgba(180,0,60,0.12);border:1px solid rgba(180,0,60,0.35);border-radius:8px;padding:0.75rem 1rem;font-size:0.88rem;color:var(--color-text);margin:0.5rem 0;line-height:1.45;';
|
||||
notice.textContent = msg;
|
||||
const container = document.getElementById('threadMessages');
|
||||
container.appendChild(notice);
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
|
||||
document.getElementById('msgInput').addEventListener('keydown', e => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); sendMsg(); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user