Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When sending user mentions, always send the user id as the fallback text #8847

Merged
merged 1 commit into from
Jun 21, 2024
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 @@ -26,10 +26,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.matrix.android.sdk.InstrumentedTest
import org.matrix.android.sdk.api.MatrixConfiguration
import org.matrix.android.sdk.api.util.TextContent
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils

Expand All @@ -56,12 +53,6 @@ class MarkdownParserTest : InstrumentedTest {
HtmlRenderer.builder().softbreak("<br />").build(),
TextPillsUtils(
MentionLinkSpecComparator(),
DisplayNameResolver(
MatrixConfiguration(
applicationFlavor = "TestFlavor",
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider()
)
),
TestPermalinkService()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import android.text.SpannableString
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.room.send.MatrixItemSpan
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
import java.util.Collections
import javax.inject.Inject

Expand All @@ -29,7 +28,6 @@ import javax.inject.Inject
*/
internal class TextPillsUtils @Inject constructor(
private val mentionLinkSpecComparator: MentionLinkSpecComparator,
private val displayNameResolver: DisplayNameResolver,
private val permalinkService: PermalinkService
) {

Expand Down Expand Up @@ -70,7 +68,7 @@ internal class TextPillsUtils @Inject constructor(
// append text before pill
append(text, currIndex, start)
// append the pill
append(String.format(template, urlSpan.matrixItem.id, displayNameResolver.getBestName(urlSpan.matrixItem)))
append(String.format(template, urlSpan.matrixItem.id, urlSpan.matrixItem.id))
currIndex = end
}
// append text after the last pill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ class AutoCompleter @AssistedInject constructor(
val linkText = when (matrixItem) {
is MatrixItem.RoomAliasItem,
is MatrixItem.RoomItem,
is MatrixItem.SpaceItem ->
is MatrixItem.SpaceItem,
is MatrixItem.UserItem ->
matrixItem.id
is MatrixItem.EveryoneInRoomItem,
is MatrixItem.UserItem,
is MatrixItem.EventItem ->
matrixItem.getBestName()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,14 +796,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
composer.editText.setSelection(Command.EMOTE.command.length + 1)
} else {
val roomMember = timelineViewModel.getMember(userId)
val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
if ((composer as? RichTextComposerLayout)?.isTextFormattingEnabled == true) {
// Rich text editor is enabled so we need to use its APIs
permalinkService.createPermalink(userId)?.let { url ->
(composer as RichTextComposerLayout).insertMention(url, displayName)
(composer as RichTextComposerLayout).insertMention(url, userId)
composer.editText.append(" ")
}
} else {
val displayName = sanitizeDisplayName(roomMember?.displayName ?: userId)
val pill = buildSpannedString {
append(displayName)
setSpan(
Expand Down
Loading