mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(ses): add v2 GetMessageInsights (#4157)
* feat(ses): add v2 GetMessageInsights Serves the per-recipient event timeline for a sent message. The timeline is derived at send time from the events SesRecipientEvents classifies for the send, the same classification that drives configuration-set event publishing and identity notifications, then stored on the SentEmail record, so the read path is a plain lookup and no new event store is needed. SentEmail also gains the EmailTags the operation returns, and a raw send now stores its parsed MIME subject, when present, as a simple send does. Insights additionally report DELIVERY for an ordinary recipient so a plain send does not look stuck at SEND; a suppressed recipient never gets DELIVERY, since it is dropped before the relay, and a message the content scan rejected ends every recipient's timeline at REJECT. What gets published is unchanged. Probed against real SES in us-east-1: the operation is gated on Virtual Deliverability Manager and reports that before it looks at the message id, a missing message names the account alongside the id, Isp carries the literal UNKNOWN_ISP when the provider cannot be identified, BounceType is the upper-case enum member, and an account-suppressed recipient is reported with BounceSubType ON_ACCOUNT_SUPPRESSION_LIST and SES's own suppression text as the diagnostic, the upper snake spelling this operation uses where the published events say OnAccountSuppressionList. Floci deliberately records the mailbox-simulator sends and the multi-recipient mail that VDM drops, because dropping both would leave insights permanently empty, and returns one entry per envelope recipient where an AWS response carries at most one. * test(ses): pin the message-insights VDM gate to one account The gate reads the account VDM attributes, which are account-scoped like every other SES store, but no test said so: the isolation test enables VDM for both of its accounts. An account that never enabled it now has to meet the gate while others in the same region are past it. * feat(ses): report a content-rejected raw send in message insights The raw send path classified its recipients with a hardcoded false, because the content scan did not exist on this branch's base. It does now, so the real scan result reaches the timeline: a rejected raw send reports SEND then REJECT instead of a delivery it never had. Its stored tags follow the same rule the published events already use, the request's own tags only, so tags read off a refused message's headers cannot resurface through GetMessageInsights.
This commit is contained in:
1 parent
a0cb86cc13
commit
e947b6a2a1
17 files changed
+1328
-4
No files matched your search
@@ -40,6 +40,7 @@ import io.github.hectorvent.floci.services.ses.SesCvetController;
|
||||
import io.github.hectorvent.floci.services.ses.SesDedicatedIpController;
|
||||
import io.github.hectorvent.floci.services.ses.SesIdentityController;
|
||||
import io.github.hectorvent.floci.services.ses.SesImportJobController;
|
||||
import io.github.hectorvent.floci.services.ses.SesInsightsController;
|
||||
import io.github.hectorvent.floci.services.ses.SesSendController;
|
||||
import io.github.hectorvent.floci.services.ses.SesSuppressionController;
|
||||
import io.github.hectorvent.floci.services.ses.SesTagController;
|
||||
@@ -300,9 +301,10 @@ public class ResolvedServiceCatalog {
|
||||
Set.of(SesAccountController.class, SesConfigurationSetController.class,
|
||||
SesContactController.class, SesCvetController.class,
|
||||
SesDedicatedIpController.class, SesIdentityController.class,
|
||||
SesSendController.class, SesSuppressionController.class,
|
||||
SesTagController.class, SesTemplateController.class,
|
||||
SesImportJobController.class, SesTenantController.class)),
|
||||
SesInsightsController.class, SesSendController.class,
|
||||
SesSuppressionController.class, SesTagController.class,
|
||||
SesTemplateController.class, SesImportJobController.class,
|
||||
SesTenantController.class)),
|
||||
descriptor("es", "opensearch", config.services().opensearch().enabled(), true,
|
||||
"opensearch", storageMode(config.storage().services().opensearch().mode(), config.storage().mode()),
|
||||
config.storage().services().opensearch().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
|
||||
|
||||
@@ -259,7 +259,7 @@ final class SesEventPayload {
|
||||
+ event.cause().name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private static String bounceDiagnosticCode(String recipient, boolean suppressed) {
|
||||
static String bounceDiagnosticCode(String recipient, boolean suppressed) {
|
||||
if (suppressed) {
|
||||
return ACCOUNT_SUPPRESSION_DIAGNOSTIC;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.ses.model.AccountVdmAttributes;
|
||||
import io.github.hectorvent.floci.services.ses.model.EmailInsights;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsBounce;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsComplaint;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsEvent;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsEventDetails;
|
||||
import io.github.hectorvent.floci.services.ses.model.MessageTag;
|
||||
import io.github.hectorvent.floci.services.ses.model.SentEmail;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* SES V2 message insights ({@code /v2/email/insights/{MessageId}/}), the read side of the
|
||||
* per-recipient timelines {@link SesMessageInsights} derives at send time.
|
||||
*
|
||||
* <p>Two behaviours are probe-confirmed against real SES (2026-09-21, us-east-1). The operation is
|
||||
* gated on Virtual Deliverability Manager and the gate is checked before the message id, so an
|
||||
* unparseable id in a VDM-disabled region still reports the VDM error. A message that is absent
|
||||
* reports the account id alongside the id.
|
||||
*/
|
||||
@Path("/v2/email")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class SesInsightsController {
|
||||
|
||||
private static final String VDM_DISABLED_MESSAGE =
|
||||
"To use this feature you must enable Virtual Deliverability Manager";
|
||||
|
||||
private final SesSentEmailService sentEmailService;
|
||||
private final SesAccountService accountService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public SesInsightsController(SesSentEmailService sentEmailService, SesAccountService accountService,
|
||||
RegionResolver regionResolver, ObjectMapper objectMapper) {
|
||||
this.sentEmailService = sentEmailService;
|
||||
this.accountService = accountService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/insights/{messageId}")
|
||||
public Response getMessageInsights(@Context HttpHeaders headers,
|
||||
@PathParam("messageId") String messageId) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
requireVdmEnabled(region);
|
||||
SentEmail email = sentEmailService.find(region, messageId)
|
||||
.orElseThrow(() -> new AwsException("NotFoundException",
|
||||
"Message <" + messageId + "> not found for account <"
|
||||
+ regionResolver.getAccountId() + ">", 404));
|
||||
return Response.ok(render(email)).build();
|
||||
}
|
||||
|
||||
private void requireVdmEnabled(String region) {
|
||||
Optional<AccountVdmAttributes> vdm = accountService.findAccountVdmAttributes(region);
|
||||
if (vdm.isEmpty() || !vdm.get().vdmEnabled()) {
|
||||
throw new AwsException("NotFoundException", VDM_DISABLED_MESSAGE, 404);
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectNode render(SentEmail email) {
|
||||
ObjectNode result = objectMapper.createObjectNode();
|
||||
result.put("MessageId", email.getMessageId());
|
||||
if (email.getSource() != null) {
|
||||
result.put("FromEmailAddress", email.getSource());
|
||||
}
|
||||
if (email.getSubject() != null) {
|
||||
result.put("Subject", email.getSubject());
|
||||
}
|
||||
ArrayNode tags = result.putArray("EmailTags");
|
||||
for (MessageTag tag : orEmpty(email.getEmailTags())) {
|
||||
ObjectNode node = tags.addObject();
|
||||
node.put("Name", tag.name());
|
||||
node.put("Value", tag.value());
|
||||
}
|
||||
ArrayNode insights = result.putArray("Insights");
|
||||
for (EmailInsights recipient : orEmpty(email.getInsights())) {
|
||||
insights.add(renderRecipient(recipient));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ObjectNode renderRecipient(EmailInsights recipient) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("Destination", recipient.destination());
|
||||
if (recipient.isp() != null) {
|
||||
node.put("Isp", recipient.isp());
|
||||
}
|
||||
ArrayNode events = node.putArray("Events");
|
||||
for (InsightsEvent event : orEmpty(recipient.events())) {
|
||||
events.add(renderEvent(event));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode renderEvent(InsightsEvent event) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
if (event.timestamp() != null) {
|
||||
node.put("Timestamp", event.timestamp().toEpochMilli() / 1000.0);
|
||||
}
|
||||
node.put("Type", event.type());
|
||||
InsightsEventDetails details = event.details();
|
||||
if (details == null) {
|
||||
return node;
|
||||
}
|
||||
ObjectNode rendered = objectMapper.createObjectNode();
|
||||
InsightsBounce bounce = details.bounce();
|
||||
if (bounce != null) {
|
||||
ObjectNode node2 = rendered.putObject("Bounce");
|
||||
putIfPresent(node2, "BounceType", bounce.bounceType());
|
||||
putIfPresent(node2, "BounceSubType", bounce.bounceSubType());
|
||||
putIfPresent(node2, "DiagnosticCode", bounce.diagnosticCode());
|
||||
}
|
||||
InsightsComplaint complaint = details.complaint();
|
||||
if (complaint != null) {
|
||||
ObjectNode node2 = rendered.putObject("Complaint");
|
||||
putIfPresent(node2, "ComplaintSubType", complaint.complaintSubType());
|
||||
putIfPresent(node2, "ComplaintFeedbackType", complaint.complaintFeedbackType());
|
||||
}
|
||||
if (!rendered.isEmpty()) {
|
||||
node.set("Details", rendered);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private static void putIfPresent(ObjectNode node, String field, String value) {
|
||||
if (value != null) {
|
||||
node.put(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> List<T> orEmpty(List<T> values) {
|
||||
return values == null ? List.of() : values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.github.hectorvent.floci.services.ses.SesRecipientEvent.Cause;
|
||||
import io.github.hectorvent.floci.services.ses.model.EmailInsights;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsBounce;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsComplaint;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsEvent;
|
||||
import io.github.hectorvent.floci.services.ses.model.InsightsEventDetails;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Derives the per-recipient event timelines that {@code GetMessageInsights} serves from the events
|
||||
* {@link SesRecipientEvents#classify} produced for the send, so the simulator and suppression
|
||||
* semantics have the same home as event publishing.
|
||||
*
|
||||
* <p>Insights add one thing publishing does not: {@code DELIVERY} for an ordinary recipient that
|
||||
* was neither suppressed nor a simulator address, so a plain send does not look stuck at
|
||||
* {@code SEND}. Floci hands such a message to the SMTP relay or drops it, and either way nothing
|
||||
* downstream can report a real outcome.
|
||||
*
|
||||
* <p>Floci tracks more messages than real SES does, deliberately. AWS documents that Virtual
|
||||
* Deliverability Manager ignores mail sent to the mailbox simulator, mail with more than one
|
||||
* recipient, and mail from a delegate sender. Both of the first two would gut the operation here:
|
||||
* simulator addresses are the only sends Floci can derive bounce and complaint events for, and
|
||||
* dropping multi-recipient mail would leave most local test traffic invisible. Floci therefore
|
||||
* records every send and returns one entry per recipient, where an AWS response in practice carries
|
||||
* exactly one. Both exclusions are probe-confirmed (2026-09-21): three simulator sends and one
|
||||
* two-recipient send were still absent from GetMessageInsights an hour later, while a
|
||||
* single-recipient send made in the middle of that window was already being served, which rules
|
||||
* out a merely slow indexing pipeline.
|
||||
*/
|
||||
final class SesMessageInsights {
|
||||
|
||||
// Events within one recipient's timeline are one millisecond apart, the finest step the
|
||||
// epoch-seconds rendering keeps, so a client that sorts by timestamp keeps the order SES would
|
||||
// have produced while no event is stamped later than the send call that returns them. A single
|
||||
// instant for every event, which is what the data really supports, would make the ordering
|
||||
// arbitrary.
|
||||
private static final Duration EVENT_SPACING = Duration.ofMillis(1);
|
||||
|
||||
// What real SES reports when it cannot identify the recipient's provider, which is always the
|
||||
// case here: Floci never sees a receiving mail server.
|
||||
private static final String UNKNOWN_ISP = "UNKNOWN_ISP";
|
||||
|
||||
// BounceType is an enum in the Smithy model (UNDETERMINED / TRANSIENT / PERMANENT), so it is
|
||||
// upper case, while BounceSubType and the complaint members are free strings. GetMessageInsights
|
||||
// spells the suppression subtype in upper snake case (probed 2026-09-21 for the bounce; the
|
||||
// complaint follows by analogy), unlike the OnAccountSuppressionList of the published events.
|
||||
static final String ON_ACCOUNT_SUPPRESSION_LIST = "ON_ACCOUNT_SUPPRESSION_LIST";
|
||||
// ComplaintSubType is null for an ordinary feedback-loop complaint; SES only sets it for a
|
||||
// complaint raised against an address already on the suppression list.
|
||||
private static final InsightsComplaint SIMULATED_COMPLAINT = new InsightsComplaint(null, "abuse");
|
||||
private static final InsightsComplaint SUPPRESSED_COMPLAINT =
|
||||
new InsightsComplaint(ON_ACCOUNT_SUPPRESSION_LIST, null);
|
||||
|
||||
private SesMessageInsights() {}
|
||||
|
||||
/**
|
||||
* Builds one {@link EmailInsights} per envelope recipient, in envelope order with blanks and
|
||||
* duplicates removed, from the events the classifier derived for that envelope.
|
||||
*/
|
||||
static List<EmailInsights> build(List<String> envelope, List<SesRecipientEvent> events, Instant sentAt) {
|
||||
Set<String> recipients = new LinkedHashSet<>();
|
||||
if (envelope != null) {
|
||||
for (String address : envelope) {
|
||||
if (address != null && !address.isBlank()) {
|
||||
recipients.add(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<EmailInsights> insights = new ArrayList<>(recipients.size());
|
||||
for (String recipient : recipients) {
|
||||
insights.add(new EmailInsights(recipient, UNKNOWN_ISP, eventsFor(recipient, events, sentAt)));
|
||||
}
|
||||
return insights;
|
||||
}
|
||||
|
||||
private static List<InsightsEvent> eventsFor(String recipient, List<SesRecipientEvent> events,
|
||||
Instant sentAt) {
|
||||
List<InsightsEvent> timeline = new ArrayList<>();
|
||||
timeline.add(InsightsEvent.of(sentAt, "SEND"));
|
||||
String trimmed = recipient.trim();
|
||||
boolean outcome = false;
|
||||
for (SesRecipientEvent event : events) {
|
||||
switch (event.eventType()) {
|
||||
case "REJECT" -> {
|
||||
// The whole message is refused, so every recipient's timeline ends here.
|
||||
timeline.add(InsightsEvent.of(next(sentAt, timeline), "REJECT"));
|
||||
outcome = true;
|
||||
}
|
||||
case "DELIVERY" -> {
|
||||
if (event.recipients().contains(trimmed)) {
|
||||
timeline.add(InsightsEvent.of(next(sentAt, timeline), "DELIVERY"));
|
||||
outcome = true;
|
||||
}
|
||||
}
|
||||
case "BOUNCE" -> {
|
||||
if (event.recipients().contains(trimmed)) {
|
||||
timeline.add(new InsightsEvent(next(sentAt, timeline), "BOUNCE",
|
||||
InsightsEventDetails.ofBounce(bounceDetails(trimmed, event.cause()))));
|
||||
outcome = true;
|
||||
}
|
||||
}
|
||||
case "COMPLAINT" -> {
|
||||
if (event.recipients().contains(trimmed)) {
|
||||
timeline.add(new InsightsEvent(next(sentAt, timeline), "COMPLAINT",
|
||||
InsightsEventDetails.ofComplaint(complaintDetails(event.cause()))));
|
||||
outcome = true;
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
// SEND is already on the timeline.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!outcome) {
|
||||
timeline.add(InsightsEvent.of(next(sentAt, timeline), "DELIVERY"));
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
private static Instant next(Instant sentAt, List<InsightsEvent> timeline) {
|
||||
return sentAt.plus(EVENT_SPACING.multipliedBy(timeline.size()));
|
||||
}
|
||||
|
||||
private static InsightsBounce bounceDetails(String recipient, Cause cause) {
|
||||
return switch (cause) {
|
||||
case ACCOUNT_SUPPRESSION -> new InsightsBounce("PERMANENT", ON_ACCOUNT_SUPPRESSION_LIST,
|
||||
SesEventPayload.ACCOUNT_SUPPRESSION_DIAGNOSTIC);
|
||||
// The shape of a list-management opt-out has not been probed, so it carries no diagnostic.
|
||||
case LIST_MANAGEMENT -> new InsightsBounce("PERMANENT", "General", null);
|
||||
default -> new InsightsBounce("PERMANENT", "General",
|
||||
SesEventPayload.bounceDiagnosticCode(recipient, false));
|
||||
};
|
||||
}
|
||||
|
||||
private static InsightsComplaint complaintDetails(Cause cause) {
|
||||
return cause == Cause.ACCOUNT_SUPPRESSION ? SUPPRESSED_COMPLAINT : SIMULATED_COMPLAINT;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Sent-email records (the {@code emailStore}), extracted from {@link SesService} as part of the
|
||||
@@ -39,6 +40,17 @@ public class SesSentEmailService {
|
||||
emailStore.put(emailKey(region, messageId), email);
|
||||
}
|
||||
|
||||
/**
|
||||
* One stored message, for {@code GetMessageInsights}. Empty when the region has no record under
|
||||
* that id; the caller owns the AWS-shaped error.
|
||||
*/
|
||||
public Optional<SentEmail> find(String region, String messageId) {
|
||||
if (messageId == null || messageId.isBlank()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return emailStore.get(emailKey(region, messageId));
|
||||
}
|
||||
|
||||
public long countInRegion(String region) {
|
||||
String prefix = "email::" + region + "::";
|
||||
return emailStore.scan(k -> k.startsWith(prefix)).size();
|
||||
|
||||
@@ -269,6 +269,9 @@ public class SesService {
|
||||
if (additionalHeaders != null && !additionalHeaders.isEmpty()) {
|
||||
email.setHeaders(additionalHeaders);
|
||||
}
|
||||
email.setEmailTags(emailTags);
|
||||
email.setInsights(SesMessageInsights.build(envelope,
|
||||
SesRecipientEvents.classify(envelope, suppressedReasons, rejected), email.getSentAt()));
|
||||
if (rejected) {
|
||||
email.discardContent(SesRecipientEvents.CONTENT_REJECT_REASON);
|
||||
}
|
||||
@@ -381,6 +384,16 @@ public class SesService {
|
||||
: firstNonBlank(headers.returnPath(), returnPath, effectiveSource);
|
||||
SentEmail email = new SentEmail(messageId, region, effectiveSource, effectiveDestinations, rawMessage);
|
||||
email.setReturnPath(effectiveReturnPath);
|
||||
// The MIME subject is already parsed for the published events; store it too so
|
||||
// GetMessageInsights reports it for a raw send as it does for a simple one. The parser
|
||||
// yields "" for a missing header, and an absent subject must stay absent.
|
||||
email.setSubject(firstNonBlank(headers.subject()));
|
||||
// A rejected message publishes only the tags that came with the request, so the stored
|
||||
// record keeps the same set: tags read off its headers must not resurface through insights.
|
||||
email.setEmailTags(rejected ? requestTags(emailTags) : effectiveTags);
|
||||
email.setInsights(SesMessageInsights.build(effectiveDestinations,
|
||||
SesRecipientEvents.classify(effectiveDestinations, suppressedReasons, rejected),
|
||||
email.getSentAt()));
|
||||
if (rejected) {
|
||||
email.discardContent(SesRecipientEvents.CONTENT_REJECT_REASON);
|
||||
}
|
||||
@@ -699,6 +712,9 @@ public class SesService {
|
||||
List.of(emailAddress), List.of(), List.of(), List.of(),
|
||||
template.getTemplateSubject(), null, renderedHtml);
|
||||
email.setReturnPath(template.getFromEmailAddress());
|
||||
email.setInsights(SesMessageInsights.build(List.of(emailAddress),
|
||||
SesRecipientEvents.classify(List.of(emailAddress), Map.of(), false),
|
||||
email.getSentAt()));
|
||||
sentEmailService.record(region, messageId, email);
|
||||
smtpRelay.relay(SmtpRelay.RelayMessage.builder(template.getFromEmailAddress())
|
||||
.returnPath(template.getFromEmailAddress())
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The per-recipient timeline returned by {@code GetMessageInsights}. One entry per envelope
|
||||
* recipient, carrying the events Floci derived for that address at send time.
|
||||
*
|
||||
* <p>{@code isp} is always {@code UNKNOWN_ISP}. Real SES reports the receiving provider it observed
|
||||
* and falls back to that literal when it cannot identify one (probe-confirmed 2026-09-21), which is
|
||||
* permanently Floci's situation, so the AWS-faithful value is also the honest one here.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record EmailInsights(
|
||||
@JsonProperty("Destination") String destination,
|
||||
@JsonProperty("Isp") String isp,
|
||||
@JsonProperty("Events") List<InsightsEvent> events) {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* The {@code Bounce} member of a {@code GetMessageInsights} event's {@code Details}.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record InsightsBounce(
|
||||
@JsonProperty("BounceType") String bounceType,
|
||||
@JsonProperty("BounceSubType") String bounceSubType,
|
||||
@JsonProperty("DiagnosticCode") String diagnosticCode) {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* The {@code Complaint} member of a {@code GetMessageInsights} event's {@code Details}.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record InsightsComplaint(
|
||||
@JsonProperty("ComplaintSubType") String complaintSubType,
|
||||
@JsonProperty("ComplaintFeedbackType") String complaintFeedbackType) {
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* One event in a {@code GetMessageInsights} recipient timeline. {@code type} is an SES
|
||||
* {@code EventType} name such as {@code SEND} or {@code DELIVERY}.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record InsightsEvent(
|
||||
@JsonProperty("Timestamp") Instant timestamp,
|
||||
@JsonProperty("Type") String type,
|
||||
@JsonProperty("Details") InsightsEventDetails details) {
|
||||
|
||||
public static InsightsEvent of(Instant timestamp, String type) {
|
||||
return new InsightsEvent(timestamp, type, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package io.github.hectorvent.floci.services.ses.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
/**
|
||||
* The {@code Details} member of a {@code GetMessageInsights} event. Only the member matching the
|
||||
* event type is populated, and an event with neither omits {@code Details} entirely.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record InsightsEventDetails(
|
||||
@JsonProperty("Bounce") InsightsBounce bounce,
|
||||
@JsonProperty("Complaint") InsightsComplaint complaint) {
|
||||
|
||||
public static InsightsEventDetails ofBounce(InsightsBounce bounce) {
|
||||
return new InsightsEventDetails(bounce, null);
|
||||
}
|
||||
|
||||
public static InsightsEventDetails ofComplaint(InsightsComplaint complaint) {
|
||||
return new InsightsEventDetails(null, complaint);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,15 @@ public class SentEmail {
|
||||
@JsonProperty("RejectReason")
|
||||
private String rejectReason;
|
||||
|
||||
@JsonProperty("EmailTags")
|
||||
private List<MessageTag> emailTags;
|
||||
|
||||
/**
|
||||
* Per-recipient event timelines, derived at send time and served by {@code GetMessageInsights}.
|
||||
*/
|
||||
@JsonProperty("Insights")
|
||||
private List<EmailInsights> insights;
|
||||
|
||||
public SentEmail() {}
|
||||
|
||||
/** Constructor for Simple / Template content. */
|
||||
@@ -154,4 +163,10 @@ public class SentEmail {
|
||||
this.bodyHtml = null;
|
||||
this.rawData = null;
|
||||
}
|
||||
|
||||
public List<MessageTag> getEmailTags() { return emailTags; }
|
||||
public void setEmailTags(List<MessageTag> emailTags) { this.emailTags = emailTags; }
|
||||
|
||||
public List<EmailInsights> getInsights() { return insights; }
|
||||
public void setInsights(List<EmailInsights> insights) { this.insights = insights; }
|
||||
}
|
||||
Reference in new issue
Block a user