fix: address the email-listing branch review

List each email once when the recipient join returns it twice. The proposal,
design and handover now say Emails exposes every saved email, including member
verification codes and form submissions, not only password emails. The design
names the single catch-all proxy, the later-SQL table sits after the 04 check,
and the seed header says the release package is frozen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-30 12:14:30 +08:00
1 parent b3c5395cfc
commit 4b090083fb
6 files changed
+22 -6

No files matched your search

@@ -16,9 +16,11 @@ import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Read-only view of the emails service-email has saved, so a temporary password can be passed on while no
@@ -52,7 +54,9 @@ public class AdminEmailService {
Map<String, Object> out = new LinkedHashMap<>(result == null ? Map.of() : result);
List<Map<String, Object>> rows = new ArrayList<>();
if (out.get("content") instanceof List<?> content) {
for (Object item : content) if (item instanceof Map<?, ?> row) rows.add(listRow(row));
// service-email's recipient filter is a join, so an email with two matching recipients arrives twice.
Set<Object> seen = new HashSet<>();
for (Object item : content) if (item instanceof Map<?, ?> row && seen.add(row.get("id"))) rows.add(listRow(row));
}
out.put("content", rows);
return out;
@@ -222,4 +222,12 @@ class AdminEmailServiceTest {
verify(rest).postForEntity(eq(PAGE), any(ParameterizedTypeReference.class), body.capture());
assertThat((Map<String, Object>) ((Map<String, Object>) body.getValue()).get("pageableRest")).containsEntry("size", 100);
}
@Test
void list_sameEmailTwiceFromTheRecipientJoin_isListedOnce() {
when(rest.postForEntity(eq(PAGE), any(ParameterizedTypeReference.class), any()))
.thenReturn(ResponseEntity.ok(Map.of("content", List.of(emailRow(7, "a@example.com"), emailRow(7, "a@example.com"), emailRow(6, "b@example.com")))));
List<Map<String, Object>> rows = (List<Map<String, Object>>) service.list("example.com", null, null, null, 0, 20).get("content");
assertThat(rows).extracting(r -> r.get("id")).containsExactly(7L, 6L);
}
}