MCPcopy Create free account
hub / github.com/daodst/chat / UsernameMatchesMultipleExclusiveNamespaces

Function UsernameMatchesMultipleExclusiveNamespaces

clientapi/routing/register.go:451–467  ·  view source on GitHub ↗

UsernameMatchesMultipleExclusiveNamespaces will check if a given username matches more than one exclusive namespace. More than one is not allowed

(
	cfg *config.ClientAPI,
	username string,
)

Source from the content-addressed store, hash-verified

449// UsernameMatchesMultipleExclusiveNamespaces will check if a given username matches
450// more than one exclusive namespace. More than one is not allowed
451func 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

Callers 1

Calls 1

Tested by

no test coverage detected