修正邮件接收时间和发件人展示
This commit is contained in:
@@ -44,6 +44,7 @@ class AgentBusSourceMessageAdapterTest {
|
||||
"external_url": "https://media.example.test/booking.pdf"
|
||||
}
|
||||
],
|
||||
"received_at": "2026-07-09T05:56:56Z",
|
||||
"source": {
|
||||
"channel": "email",
|
||||
"external_message_id": "outlook-message-001",
|
||||
@@ -65,6 +66,7 @@ class AgentBusSourceMessageAdapterTest {
|
||||
assertThat(command.externalConversationId()).isEqualTo("outlook-conversation-001");
|
||||
assertThat(command.providerFrameId()).isEqualTo("frame-agentbus-001");
|
||||
assertThat(command.providerSessionId()).isEqualTo("session-agentbus-001");
|
||||
assertThat(command.sourceReceivedAt()).isEqualTo(Instant.parse("2026-07-09T05:56:56Z"));
|
||||
assertThat(command.sourceSentAt()).isEqualTo(Instant.parse("2026-07-06T08:00:00Z"));
|
||||
assertThat(command.senderIdentifier()).isEqualTo("guest@example.test");
|
||||
assertThat(command.subject()).isEqualTo("Booking change");
|
||||
@@ -78,4 +80,40 @@ class AgentBusSourceMessageAdapterTest {
|
||||
assertThat(command.mediaItems().get(1).mediaType()).isEqualTo("ATTACHMENT");
|
||||
assertThat(command.mediaItems().get(1).fileName()).isEqualTo("booking.pdf");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPreferValidSourceReceivedAtAndFallbackToPayloadReceivedAt() throws Exception {
|
||||
JsonNode sourceReceivedFrame = objectMapper.readTree("""
|
||||
{
|
||||
"id": "frame-agentbus-002",
|
||||
"payload": {
|
||||
"received_at": "2026-07-09T05:56:56Z",
|
||||
"source": {
|
||||
"channel": "email",
|
||||
"external_message_id": "outlook-message-002",
|
||||
"received_at": "2026-07-09T05:50:00Z"
|
||||
}
|
||||
}
|
||||
}
|
||||
""");
|
||||
JsonNode invalidSourceReceivedFrame = objectMapper.readTree("""
|
||||
{
|
||||
"id": "frame-agentbus-003",
|
||||
"payload": {
|
||||
"received_at": "2026-07-09T05:56:56Z",
|
||||
"source": {
|
||||
"channel": "email",
|
||||
"external_message_id": "outlook-message-003",
|
||||
"received_at": "bad-time"
|
||||
}
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
CaptureSourceMessageCommand sourceCommand = adapter.toCaptureCommand("HOTEL-TEST", sourceReceivedFrame);
|
||||
CaptureSourceMessageCommand fallbackCommand = adapter.toCaptureCommand("HOTEL-TEST", invalidSourceReceivedFrame);
|
||||
|
||||
assertThat(sourceCommand.sourceReceivedAt()).isEqualTo(Instant.parse("2026-07-09T05:50:00Z"));
|
||||
assertThat(fallbackCommand.sourceReceivedAt()).isEqualTo(Instant.parse("2026-07-09T05:56:56Z"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class SourceMessageCaptureServiceImplTest {
|
||||
assertThat(summary.externalMessageId()).isEqualTo("mail-m001-001");
|
||||
assertThat(summary.externalConversationId()).isEqualTo("conversation-m001");
|
||||
assertThat(summary.captureStatus()).isEqualTo("RECEIVED");
|
||||
assertThat(summary.senderSummary()).isEqualTo("g***@example.test");
|
||||
assertThat(summary.senderSummary()).isEqualTo("guest@example.test");
|
||||
assertThat(summary.subject()).isEqualTo("Booking change request");
|
||||
assertThat(summary.safeSnippet()).contains("Please change the arrival date");
|
||||
assertThat(summary.safeSnippet()).doesNotContain("13800138000");
|
||||
@@ -187,6 +187,40 @@ class SourceMessageCaptureServiceImplTest {
|
||||
assertThat(inbox.getSafeErrorSummary()).contains("重复投递 payload");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPersistSourceReceivedAtAndExposeFullSenderIdentifier() {
|
||||
CaptureSourceMessageCommand command = new CaptureSourceMessageCommand(
|
||||
"HOTEL-TEST",
|
||||
"AGENTBUS",
|
||||
"EMAIL",
|
||||
"mail-source-received-time-001",
|
||||
"conversation-source-received-time",
|
||||
"frame-source-received-time-001",
|
||||
"session-source-received-time",
|
||||
Instant.parse("2026-07-09T05:56:56Z"),
|
||||
Instant.parse("2026-07-09T05:55:00Z"),
|
||||
"guest@example.test",
|
||||
"Source received time",
|
||||
"Please check received time.",
|
||||
"<html>Please check received time.</html>",
|
||||
"{\"received_at\":\"2026-07-09T05:56:56Z\",\"source\":{\"external_message_id\":\"mail-source-received-time-001\"}}",
|
||||
"agentbus-outlook-v1",
|
||||
List.of()
|
||||
);
|
||||
|
||||
SourceMessageCaptureResult result = captureService.capture(command);
|
||||
|
||||
SourceMessageSummaryResponse summary = queryService.getSummary(result.inboxId()).orElseThrow();
|
||||
assertThat(summary.receivedAt().toInstant()).isEqualTo(Instant.parse("2026-07-09T05:56:56Z"));
|
||||
assertThat(summary.sourceSentAt().toInstant()).isEqualTo(Instant.parse("2026-07-09T05:55:00Z"));
|
||||
assertThat(summary.senderSummary()).isEqualTo("guest@example.test");
|
||||
|
||||
SourceMessageInboxEntity inbox = inboxMapper.selectById(result.inboxId());
|
||||
assertThat(inbox.getReceivedAt()).isEqualTo(LocalDateTime.parse("2026-07-09T05:56:56"));
|
||||
assertThat(inbox.getCreatedAt()).isNotEqualTo(inbox.getReceivedAt());
|
||||
assertThat(inbox.getUpdatedAt()).isEqualTo(inbox.getCreatedAt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPersistFailedInboxWhenExternalMessageIdIsMissing() {
|
||||
CaptureSourceMessageCommand command = new CaptureSourceMessageCommand(
|
||||
@@ -319,7 +353,7 @@ class SourceMessageCaptureServiceImplTest {
|
||||
false,
|
||||
LocalDateTime.parse("2026-07-06T09:50:00"),
|
||||
LocalDateTime.parse("2026-07-06T09:50:00"),
|
||||
"g***@example.test",
|
||||
"guest@example.test",
|
||||
"Race delivery",
|
||||
"Race body"
|
||||
);
|
||||
@@ -373,7 +407,7 @@ class SourceMessageCaptureServiceImplTest {
|
||||
true,
|
||||
LocalDateTime.parse("2026-07-06T10:00:00"),
|
||||
LocalDateTime.parse("2026-07-06T10:00:00"),
|
||||
"g***@example.test",
|
||||
"guest@example.test",
|
||||
"Duplicate diagnostic fail",
|
||||
"Original body"
|
||||
);
|
||||
|
||||
@@ -91,7 +91,7 @@ class ReservationFrontendQueryControllerTest {
|
||||
.andExpect(jsonPath("$.items[0].readonly_reason_code").value("PROCESSABLE"))
|
||||
.andExpect(jsonPath("$.items[0].source_message_id").value(source.inboxId().toString()))
|
||||
.andExpect(jsonPath("$.items[0].source_subject").value("Frontend Query List Smoke"))
|
||||
.andExpect(jsonPath("$.items[0].source_sender_summary").value("g***@example.test"))
|
||||
.andExpect(jsonPath("$.items[0].source_sender_summary").value("guest@example.test"))
|
||||
.andExpect(jsonPath("$.items[0].source_received_at").value(matchesPattern(UTC_INSTANT_PATTERN)))
|
||||
.andExpect(jsonPath("$.items[0].external_conversation_id")
|
||||
.value("thread-mail-frontend-task-list-001"))
|
||||
@@ -193,7 +193,7 @@ class ReservationFrontendQueryControllerTest {
|
||||
.andExpect(jsonPath("$.tasks[0].task_status").value("COMPLETED"))
|
||||
.andExpect(jsonPath("$.tasks[0].source_message_id").value(source.inboxId().toString()))
|
||||
.andExpect(jsonPath("$.tasks[0].source_subject").value("Frontend Query Detail Smoke"))
|
||||
.andExpect(jsonPath("$.tasks[0].source_sender_summary").value("g***@example.test"))
|
||||
.andExpect(jsonPath("$.tasks[0].source_sender_summary").value("guest@example.test"))
|
||||
.andExpect(jsonPath("$.tasks[0].source_received_at").value(matchesPattern(UTC_INSTANT_PATTERN)))
|
||||
.andExpect(jsonPath("$.tasks[0].external_conversation_id")
|
||||
.value("thread-mail-frontend-order-detail-001"))
|
||||
|
||||
@@ -702,7 +702,7 @@ class SuperAgentTaskResultControllerTest {
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.task_card_type").value("NEW_BOOKING"))
|
||||
.andExpect(jsonPath("$.source_subject").value("M002 SuperAgent intake"))
|
||||
.andExpect(jsonPath("$.source_sender_summary").value("g***@example.test"))
|
||||
.andExpect(jsonPath("$.source_sender_summary").value("guest@example.test"))
|
||||
.andExpect(jsonPath("$.source_received_at").value(matchesPattern(UTC_INSTANT_PATTERN)))
|
||||
.andExpect(jsonPath("$.external_conversation_id").value("thread-mail-detail-matrix-001"))
|
||||
.andExpect(jsonPath("$.conversation_message_count").value(1))
|
||||
|
||||
Reference in New Issue
Block a user