fix: make user mentions case-insensitive

AD
1mo ago
+35-8

What was fixed

Closes #13374

Mentions now work even when the typed username uses different casing.

Before this change, if a user’s username was foo, typing @Foo or @FOO would not create a proper mention. This was inconsistent because Rocket.Chat already treats usernames as case-insensitive in other places, like user creation.

What changed

Updated the message save logic so user mentions are resolved case-insensitively.

Also updated the mention rendering logic so a differently-cased typed mention still gets highlighted correctly and uses the actual stored username.

Tests added

Added tests for:

  • resolving a mixed-case typed mention to the correct existing user
  • rendering a mixed-case mention as a normal highlighted mention

Summary by CodeRabbit

  • Bug Fixes
    • User mention matching is now case-insensitive, allowing mentions with any capitalization (e.g., @Rocket.Cat correctly resolves to @rocket.cat). Mention links now use normalized usernames for consistency while preserving display names.