Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ public interface OverrideProperties {
*/
Instant getDeliveryTime();

/**
* Specifies the maximum time window for delivering the message. Accepts values in format <code>
* [0-9]+h[0-9]+m</code> (e.g., <code>1h30m</code>, <code>30m</code>, <code>24h</code>), with a
* minimum of <code>5m</code> and maximum of <code>24h</code>. For scheduled messages, the
* delivery window starts from the scheduled time. The standard retry schedule applies within this
* window, so shorter timeframes may result in fewer delivery attempts.
*
* @return deliverWithin
*/
String getDeliverWithin();

/**
* Toggles Timezone Optimization (TZO) on a per message basis. String should be set to preferred
* delivery time in <code>HH:mm</code> or <code>hh:mmaa</code> format, where <code>HH:mm</code> is
Expand Down Expand Up @@ -255,6 +266,15 @@ interface Builder {
*/
Builder setDeliveryTime(Instant deliveryTime);

/**
* see getter
*
* @param deliverWithin see getter
* @return Current builder
* @see #getDeliverWithin
*/
Builder setDeliverWithin(String deliverWithin);

/**
* see getter
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class OverridePropertiesImpl implements OverrideProperties {

private OptionalValue<Instant> deliveryTime;

public static final String PROPERTY_DELIVER_WITHIN = "o:deliver-within";

private OptionalValue<String> deliverWithin;

public static final String PROPERTY_TIME_ZONE_LOCALIZE = "o:time-zone-localize";

private OptionalValue<String> timeZoneLocalize;
Expand Down Expand Up @@ -92,6 +96,7 @@ protected OverridePropertiesImpl(
OptionalValue<String> secondaryDkim,
OptionalValue<String> secondaryDkimPublic,
OptionalValue<Instant> deliveryTime,
OptionalValue<String> deliverWithin,
OptionalValue<String> timeZoneLocalize,
OptionalValue<TrueFalseHtmlonlyEnum> trackingClicks,
OptionalValue<TrueFalseHtmlonlyEnum> tracking,
Expand All @@ -110,6 +115,7 @@ protected OverridePropertiesImpl(
this.secondaryDkim = secondaryDkim;
this.secondaryDkimPublic = secondaryDkimPublic;
this.deliveryTime = deliveryTime;
this.deliverWithin = deliverWithin;
this.timeZoneLocalize = timeZoneLocalize;
this.trackingClicks = trackingClicks;
this.tracking = tracking;
Expand Down Expand Up @@ -182,6 +188,15 @@ public OptionalValue<Instant> deliveryTime() {
return deliveryTime;
}

public String getDeliverWithin() {
return deliverWithin.orElse(null);
}

@Property(PROPERTY_DELIVER_WITHIN)
public OptionalValue<String> deliverWithin() {
return deliverWithin;
}

public String getTimeZoneLocalize() {
return timeZoneLocalize.orElse(null);
}
Expand Down Expand Up @@ -311,6 +326,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.secondaryDkim, overrideProperties.secondaryDkim)
&& Objects.equals(this.secondaryDkimPublic, overrideProperties.secondaryDkimPublic)
&& Objects.equals(this.deliveryTime, overrideProperties.deliveryTime)
&& Objects.equals(this.deliverWithin, overrideProperties.deliverWithin)
&& Objects.equals(this.timeZoneLocalize, overrideProperties.timeZoneLocalize)
&& Objects.equals(this.trackingClicks, overrideProperties.trackingClicks)
&& Objects.equals(this.tracking, overrideProperties.tracking)
Expand All @@ -335,6 +351,7 @@ public int hashCode() {
secondaryDkim,
secondaryDkimPublic,
deliveryTime,
deliverWithin,
timeZoneLocalize,
trackingClicks,
tracking,
Expand Down Expand Up @@ -365,6 +382,7 @@ public String toString() {
.append(toIndentedString(secondaryDkimPublic))
.append("\n");
sb.append(" deliveryTime: ").append(toIndentedString(deliveryTime)).append("\n");
sb.append(" deliverWithin: ").append(toIndentedString(deliverWithin)).append("\n");
sb.append(" timeZoneLocalize: ").append(toIndentedString(timeZoneLocalize)).append("\n");
sb.append(" trackingClicks: ").append(toIndentedString(trackingClicks)).append("\n");
sb.append(" tracking: ").append(toIndentedString(tracking)).append("\n");
Expand Down Expand Up @@ -400,6 +418,7 @@ static class Builder implements OverrideProperties.Builder {
OptionalValue<String> secondaryDkim = OptionalValue.empty();
OptionalValue<String> secondaryDkimPublic = OptionalValue.empty();
OptionalValue<Instant> deliveryTime = OptionalValue.empty();
OptionalValue<String> deliverWithin = OptionalValue.empty();
OptionalValue<String> timeZoneLocalize = OptionalValue.empty();
OptionalValue<TrueFalseHtmlonlyEnum> trackingClicks = OptionalValue.empty();
OptionalValue<TrueFalseHtmlonlyEnum> tracking = OptionalValue.empty();
Expand Down Expand Up @@ -449,6 +468,12 @@ public Builder setDeliveryTime(Instant deliveryTime) {
return this;
}

@Property(value = PROPERTY_DELIVER_WITHIN)
public Builder setDeliverWithin(String deliverWithin) {
this.deliverWithin = OptionalValue.of(deliverWithin);
return this;
}

@Property(value = PROPERTY_TIME_ZONE_LOCALIZE)
public Builder setTimeZoneLocalize(String timeZoneLocalize) {
this.timeZoneLocalize = OptionalValue.of(timeZoneLocalize);
Expand Down Expand Up @@ -529,6 +554,7 @@ public OverrideProperties build() {
secondaryDkim,
secondaryDkimPublic,
deliveryTime,
deliverWithin,
timeZoneLocalize,
trackingClicks,
tracking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class SendEmailRequestTest extends BaseTest {
"o:secondary-dkim-public","public.example.com/s1",
"o:archive-to","http://an-archive-to-dest.com",
"o:deliverytime", "Sat, 22 Jan 2000 11:23:45 GMT",
"o:deliver-within", "30m",
"o:deliverytime-optimize-period", "29h",
"o:time-zone-localize","02:04PM",
"o:testmode", "false",
Expand Down Expand Up @@ -109,6 +110,7 @@ public class SendEmailRequestTest extends BaseTest {
"o:secondary-dkim-public","public.example.com/s1",
"o:archive-to","http://an-archive-to-dest.com",
"o:deliverytime", "Sat, 22 Jan 2000 11:23:45 GMT",
"o:deliver-within", "30m",
"o:deliverytime-optimize-period", "29h",
"o:time-zone-localize","02:04PM",
"o:testmode", "false",
Expand Down Expand Up @@ -147,6 +149,7 @@ public class SendEmailRequestTest extends BaseTest {
OverrideProperties.builder()
.setTag(Arrays.asList("tag1", "tag2"))
.setDeliveryTime(Instant.parse("2000-01-22T11:23:45Z"))
.setDeliverWithin("30m")
.setTestMode(false)
.setEnableDkimSignature(true)
.setSecondaryDkim("example.com/s1")
Expand Down Expand Up @@ -185,6 +188,7 @@ public class SendEmailRequestTest extends BaseTest {
OverrideProperties.builder()
.setTag(Arrays.asList("tag1", "tag2"))
.setDeliveryTime(Instant.parse("2000-01-22T11:23:45Z"))
.setDeliverWithin("30m")
.setTestMode(false)
.setEnableDkimSignature(true)
.setSecondaryDkim("example.com/s1")
Expand Down
Loading