PM-17680: Overwrite the expiration date to the deletion date (#4642)

This commit is contained in:
David Perez
2025-01-28 16:20:47 -06:00
committed by GitHub
parent 2eca28d571
commit 69f33ddca9
2 changed files with 30 additions and 1 deletions

View File

@@ -31,7 +31,11 @@ fun AddSendState.ViewState.Content.toSendView(
hideEmail = common.isHideEmailChecked,
revisionDate = clock.instant(),
deletionDate = common.deletionDate.toInstant(),
expirationDate = common.expirationDate?.toInstant(),
expirationDate = common.expirationDate?.let {
// We no longer support expiration dates but is a send has one already,
// we just update it to match the deletion date.
common.deletionDate.toInstant()
},
)
private fun AddSendState.ViewState.Content.SendType.toSendType(): SendType =

View File

@@ -58,6 +58,31 @@ class AddSendStateExtensionsTest {
assertEquals(sendView, result)
}
@Suppress("MaxLineLength")
@Test
fun `toSendView should create an appropriate SendView with expiration date set to deletion date`() {
val sendView = createMockSendView(number = 1, type = SendType.TEXT).copy(
id = null,
accessId = null,
key = null,
accessCount = 0U,
hasPassword = false,
deletionDate = ZonedDateTime.parse("2030-10-27T12:00:00Z").toInstant(),
expirationDate = ZonedDateTime.parse("2030-10-27T12:00:00Z").toInstant(),
)
val result = DEFAULT_VIEW_STATE
.copy(
common = DEFAULT_COMMON_STATE.copy(
deletionDate = ZonedDateTime.parse("2030-10-27T12:00:00Z"),
expirationDate = ZonedDateTime.parse("2026-10-27T12:00:00Z"),
),
)
.toSendView(FIXED_CLOCK)
assertEquals(sendView, result)
}
}
private val FIXED_CLOCK: Clock = Clock.fixed(