fix(qr): inactive answer for malformed codes, undated events, switched-off badge, reset-pending sessions
A code of the wrong shape now shows "no longer active" instead of failing, My QR codes skips events with no end date and marks switched-off codes, and a session waiting on a password reset can still open a QR page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
c6c220265f
commit
d532bdcda4
10 files changed
+59
-6
No files matched your search
+3
-3
@@ -77,11 +77,11 @@ public class RegistrationLinkService {
|
||||
.map(EventSalesperson::getEventUuid).toList();
|
||||
if (uuids.isEmpty()) return List.of();
|
||||
return eventRepository.findByCompanyIdAndUuidIn(req.companyId(), uuids).stream()
|
||||
.filter(e -> e.getEnabled() == GeneralEnum.FlagYesNo.Y && !e.getDateEnd().toLocalDate().isBefore(today))
|
||||
.sorted(Comparator.comparing(Event::getDateStart))
|
||||
.filter(e -> e.getEnabled() == GeneralEnum.FlagYesNo.Y && e.getDateEnd() != null && !e.getDateEnd().toLocalDate().isBefore(today))
|
||||
.sorted(Comparator.comparing(Event::getDateStart, Comparator.nullsLast(Comparator.naturalOrder())))
|
||||
.map(e -> {
|
||||
RegistrationLink l = personal(req.companyId(), e.getUuid(), req.userId());
|
||||
return new MineRow(String.valueOf(e.getUuid()), e.getName(), e.getDateStart().toLocalDate().toString(),
|
||||
return new MineRow(String.valueOf(e.getUuid()), e.getName(), e.getDateStart() == null ? null : e.getDateStart().toLocalDate().toString(),
|
||||
e.getDateEnd().toLocalDate().toString(), e.getLocation(), l.getToken(), l.isEnabled());
|
||||
}).toList();
|
||||
}
|
||||
|
||||
+18
@@ -213,6 +213,24 @@ class RegistrationLinkServiceTest {
|
||||
verify(linkRepository, never()).save(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mineSkipsUndatedEndAndSortsUndatedStartLast() {
|
||||
EventSalesperson r1 = new EventSalesperson(); r1.setEventUuid(1L);
|
||||
EventSalesperson r2 = new EventSalesperson(); r2.setEventUuid(2L);
|
||||
EventSalesperson r3 = new EventSalesperson(); r3.setEventUuid(3L);
|
||||
when(eventSalespersonRepository.findByCompanyIdAndUserId(COMPANY, 7L)).thenReturn(List.of(r1, r2, r3));
|
||||
Event noStart = event(1L, COMPANY, "NoStart", null, LocalDateTime.of(2026, 12, 12, 18, 0), GeneralEnum.FlagYesNo.Y);
|
||||
Event noEnd = event(2L, COMPANY, "NoEnd", LocalDateTime.of(2026, 12, 3, 9, 0), null, GeneralEnum.FlagYesNo.Y);
|
||||
Event dated = event(3L, COMPANY, "Dated", LocalDateTime.of(2026, 12, 5, 9, 0), LocalDateTime.of(2026, 12, 6, 9, 0), GeneralEnum.FlagYesNo.Y);
|
||||
when(eventRepository.findByCompanyIdAndUuidIn(eq(COMPANY), anyCollection())).thenReturn(List.of(noStart, noEnd, dated));
|
||||
when(linkRepository.findFirstByEventUuidAndSalespersonUserIdOrderByIdAsc(anyLong(), eq(7L))).thenReturn(Optional.of(link(7L, "T", true)));
|
||||
|
||||
List<RegistrationLinkService.MineRow> out = service.mine(new RegistrationLinkService.MineRequest(COMPANY, 7L, "2026-12-01"));
|
||||
|
||||
assertThat(out).extracting(RegistrationLinkService.MineRow::eventName).containsExactly("Dated", "NoStart");
|
||||
assertThat(out.get(1).startDate()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void mineListsOnlyEnabledNotEndedTeamEventsOrderedByStartAndCreatesMissingLinks() {
|
||||
EventSalesperson r1 = new EventSalesperson(); r1.setEventUuid(1L);
|
||||
|
||||
Reference in new issue
Block a user