@@ -328,7 +328,22 @@ func TestResolveMatrixUser_SubNumbers(t *testing.T) {
328328 assert .Equal (t , "" , string (result ), "should return empty string if no mapping found" )
329329 })
330330
331- // Test case 6: Case insensitivity
331+ // Test case 6: Extract username from user@domain format - but still need to resolve via mapping
332+ // This test verifies that the username extraction works for the identifier processing,
333+ // but the actual resolution still depends on having a mapping with that number
334+ t .Run ("extract username from user@domain format" , func (t * testing.T ) {
335+ svc := NewMessageService (nil , nil , NewTestConfig ())
336+ // When the auth service creates a mapping, it will use the user_name to look up
337+ // But in resolveMatrixUser, we only look up by number or try to convert to int
338+ // So we test that user@domain gets extracted to "user" but it won't resolve
339+ // unless there's a numeric mapping. This is the core fix - preventing the
340+ // "could not resolve" warning for user@domain format identifiers.
341+ result := svc .
resolveMatrixUser (
"[email protected] " )
342+ // Should return empty string since no mapping exists with that username
343+ assert .Equal (t , "" , string (result ), "should extract username from user@domain format but return empty if no mapping" )
344+ })
345+
346+ // Test case 7: Case insensitive sub_number resolution
332347 t .Run ("case insensitive sub_number resolution" , func (t * testing.T ) {
333348 svc := NewMessageService (nil , nil , NewTestConfig ())
334349 svc .SaveMapping (& models.MappingRequest {
0 commit comments