UsernameMatchesMultipleExclusiveNamespaces will check if a given username matches more than one exclusive namespace. More than one is not allowed
( cfg *config.ClientAPI, username string, )
| 449 | // UsernameMatchesMultipleExclusiveNamespaces will check if a given username matches |
| 450 | // more than one exclusive namespace. More than one is not allowed |
| 451 | func UsernameMatchesMultipleExclusiveNamespaces( |
| 452 | cfg *config.ClientAPI, |
| 453 | username string, |
| 454 | ) bool { |
| 455 | userID := userutil.MakeUserID(username, cfg.Matrix.ServerName) |
| 456 | |
| 457 | // Check namespaces and see if more than one match |
| 458 | matchCount := 0 |
| 459 | for _, appservice := range cfg.Derived.ApplicationServices { |
| 460 | if appservice.OwnsNamespaceCoveringUserId(userID) { |
| 461 | if matchCount++; matchCount > 1 { |
| 462 | return true |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | return false |
| 467 | } |
| 468 | |
| 469 | // UsernameMatchesExclusiveNamespaces will check if a given username matches any |
| 470 | // application service's exclusive users namespace |
no test coverage detected