Füge Funktion zum Abbrechen der Werbung hinzu: Implementiere cancelWooing in FalukantService und FalukantController, aktualisiere FamilyView für die Benutzeroberfläche und verbessere die Fehlermeldungen bei vorzeitigen Abbrüchen.

This commit is contained in:
Torsten Schulz (local)
2026-01-28 11:53:34 +01:00
parent 16f3d1a320
commit cbff7c130c
8 changed files with 119 additions and 7 deletions

View File

@@ -2733,6 +2733,33 @@ class FalukantService extends BaseService {
return { success: true, message: 'Marriage proposal accepted' };
}
async cancelWooing(hashedUserId) {
const user = await this.getFalukantUserByHashedId(hashedUserId);
if (!user || !user.character) {
throw new Error('User or character not found');
}
const relation = await Relationship.findOne({
where: { character1Id: user.character.id },
include: [{
model: RelationshipType,
as: 'relationshipType',
where: { tr: 'wooing' }
}]
});
if (!relation) {
throw new Error('noWooing');
}
// Require at least 24h between starting wooing (relation.createdAt) and cancelling
const earliestCancel = new Date(relation.createdAt.getTime() + 24 * 3600 * 1000);
if (Date.now() < earliestCancel.getTime()) {
const err = new PreconditionError('cancelTooSoon');
err.meta = { retryAt: earliestCancel.toISOString() };
throw err;
}
await relation.destroy();
return { success: true };
}
async getGifts(hashedUserId) {
// 1) Mein User & Character
const user = await this.getFalukantUserByHashedId(hashedUserId);