package matrix import "maunium.net/go/mautrix/id" func makeUserID(userIdentifier, homeserverURL string) (id.UserID, error) { userID := id.UserID(userIdentifier) localpart, _, err := userID.Parse() if err != nil { userID = id.NewUserID(userIdentifier, homeserverURL) if _, _, err := userID.ParseAndValidate(); err != nil { return "", err } } else if err := id.ValidateUserLocalpart(localpart); err != nil { return "", err } else if len(userID) > id.UserIDMaxLength { return "", id.ErrUserIDTooLong } return userID, nil }