Enhance gift sending logic: Implement retry mechanism for 'tooOften' error in FalukantService and update error handling in FamilyView to display retry time.

This commit is contained in:
Torsten Schulz (local)
2026-01-26 16:45:13 +01:00
parent ca614f6cc2
commit 955ea1a9ed
5 changed files with 29 additions and 6 deletions

View File

@@ -2868,7 +2868,10 @@ class FalukantService extends BaseService {
limit: 1
});
if (lastGift && (lastGift.createdAt.getTime() + 3_600_000) > Date.now()) {
throw new PreconditionError('tooOften');
const retryAt = new Date(lastGift.createdAt.getTime() + 3_600_000);
const err = new PreconditionError('tooOften');
err.meta = { retryAt: retryAt.toISOString() };
throw err;
}
const gift = await PromotionalGift.findOne({
where: { id: giftId },