Skip to content

Commit b48885f

Browse files
author
PrithvijitBose
committed
fix(who-is): support case-insensitive GitHub username lookups
1 parent d720583 commit b48885f

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/ghdcbot/engine/issue_assignment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def resolve_github_to_discord(
7878
if not callable(verified):
7979
return None
8080

81+
target = (github_user or "").strip().lower()
8182
for mapping in verified():
82-
if mapping.github_user == github_user:
83+
if (mapping.github_user or "").strip().lower() == target:
8384
return mapping.discord_user_id
8485

8586
return None

tests/test_who_is_command.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,29 @@ async def test_who_is_missing_github_link() -> None:
150150
== "❌ GitHub user **unknown_user** is not linked or verified with any Discord account."
151151
)
152152
assert interaction.followup.messages[0]["ephemeral"] is True
153+
154+
155+
@pytest.mark.asyncio
156+
async def test_who_is_case_insensitive_matching() -> None:
157+
"""Test /who-is resolves GitHub username regardless of character case."""
158+
storage = MagicMock()
159+
config = MagicMock()
160+
config.identity.verified_max_age_days = 30
161+
162+
mapping_record = MagicMock()
163+
mapping_record.github_user = "OctoCat"
164+
mapping_record.discord_user_id = "999888777"
165+
storage.list_verified_identity_mappings.return_value = [mapping_record]
166+
167+
storage.get_identity_status.return_value = {
168+
"status": "verified",
169+
"is_stale": False,
170+
"github_user": "OctoCat",
171+
}
172+
173+
interaction = _FakeInteraction()
174+
await _run_who_is_handler(interaction, storage, config, "octocat")
175+
176+
assert len(interaction.followup.messages) == 1
177+
assert "as Discord member <@999888777>" in interaction.followup.messages[0]["content"]
178+

0 commit comments

Comments
 (0)