Skip to content

Commit ae71a9a

Browse files
authored
fix: removing mentions validation (WPB-20317) (#3824)
1 parent b185cfb commit ae71a9a

File tree

2 files changed

+0
-40
lines changed

2 files changed

+0
-40
lines changed

domain/backup/src/commonMain/kotlin/com/wire/backup/data/BackupData.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ public sealed class BackupMessageContent {
170170
@SerialName("mentions") val mentions: List<Mention> = emptyList(),
171171
@SerialName("quotedMessageId") val quotedMessageId: String? = null
172172
) : BackupMessageContent() {
173-
init {
174-
mentions.forEach { mention ->
175-
require(mention.start + mention.length <= text.length) { "Mention range exceeds text length" }
176-
}
177-
}
178-
179173
/**
180174
* Represents a mention of a user in a text.
181175
*

domain/backup/src/commonTest/kotlin/com/wire/backup/data/BackupContentTextTest.kt

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,6 @@ import kotlin.test.assertFailsWith
2323

2424
class BackupContentTextTest {
2525

26-
@Test
27-
fun givenMentionTooLong_whenCreatingText_thenShouldThrowIAE() {
28-
val text = "Hello"
29-
val mention = BackupMessageContent.Text.Mention(
30-
userId = BackupQualifiedId(id = "user", domain = "example.com"),
31-
start = 3,
32-
length = 5, // 3 + 5 = 8 > text.length (5)
33-
)
34-
35-
assertFailsWith<IllegalArgumentException> {
36-
BackupMessageContent.Text(text = text, mentions = listOf(mention))
37-
}
38-
}
39-
40-
@Test
41-
fun givenMultipleMentionsWithOnlyOneOutOfBounds_whenCreatingText_thenShouldThrowIAE() {
42-
val text = "Hello @alice"
43-
val validMention = BackupMessageContent.Text.Mention(
44-
userId = BackupQualifiedId(id = "alice-id", domain = "example.com"),
45-
start = 6,
46-
length = 6, // Valid: 6 + 6 = 12 == text.length
47-
)
48-
val invalidMention = BackupMessageContent.Text.Mention(
49-
userId = BackupQualifiedId(id = "bob-id", domain = "example.com"),
50-
start = 10,
51-
length = 5, // Invalid: 10 + 5 = 15 > text.length (12)
52-
)
53-
54-
assertFailsWith<IllegalArgumentException> {
55-
BackupMessageContent.Text(text = text, mentions = listOf(validMention, invalidMention))
56-
}
57-
}
58-
59-
6026
@Test
6127
fun givenNegativeStart_whenCreatingMention_thenShouldThrowIAE() {
6228
assertFailsWith<IllegalArgumentException> {

0 commit comments

Comments
 (0)