mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-26 13:41:33 +00:00
support non-exclusive namespaces for AS (#828)
Signed-off-by: MohitKS5 <mohitkumarsingh907@gmail.com> Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com> Co-authored-by: Kegsay <kegan@matrix.org>
This commit is contained in:
parent
1321f8da80
commit
2c43e222bd
@ -362,7 +362,7 @@ func UsernameMatchesMultipleExclusiveNamespaces(
|
|||||||
// Check namespaces and see if more than one match
|
// Check namespaces and see if more than one match
|
||||||
matchCount := 0
|
matchCount := 0
|
||||||
for _, appservice := range cfg.Derived.ApplicationServices {
|
for _, appservice := range cfg.Derived.ApplicationServices {
|
||||||
if appservice.IsInterestedInUserID(userID) {
|
if appservice.OwnsNamespaceCoveringUserId(userID) {
|
||||||
if matchCount++; matchCount > 1 {
|
if matchCount++; matchCount > 1 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -1000,7 +1000,7 @@ func RegisterAvailable(
|
|||||||
// Check if this username is reserved by an application service
|
// Check if this username is reserved by an application service
|
||||||
userID := userutil.MakeUserID(username, cfg.Matrix.ServerName)
|
userID := userutil.MakeUserID(username, cfg.Matrix.ServerName)
|
||||||
for _, appservice := range cfg.Derived.ApplicationServices {
|
for _, appservice := range cfg.Derived.ApplicationServices {
|
||||||
if appservice.IsInterestedInUserID(userID) {
|
if appservice.OwnsNamespaceCoveringUserId(userID) {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.UserInUse("Desired user ID is reserved by an application service."),
|
JSON: jsonerror.UserInUse("Desired user ID is reserved by an application service."),
|
||||||
|
@ -98,6 +98,22 @@ func (a *ApplicationService) IsInterestedInUserID(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OwnsNamespaceCoveringUserId returns a bool on whether an application service's
|
||||||
|
// namespace is exclusive and includes the given user ID
|
||||||
|
func (a *ApplicationService) OwnsNamespaceCoveringUserId(
|
||||||
|
userID string,
|
||||||
|
) bool {
|
||||||
|
if namespaceSlice, ok := a.NamespaceMap["users"]; ok {
|
||||||
|
for _, namespace := range namespaceSlice {
|
||||||
|
if namespace.Exclusive && namespace.RegexpObject.MatchString(userID) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// IsInterestedInRoomAlias returns a bool on whether an application service's
|
// IsInterestedInRoomAlias returns a bool on whether an application service's
|
||||||
// namespace includes the given room alias
|
// namespace includes the given room alias
|
||||||
func (a *ApplicationService) IsInterestedInRoomAlias(
|
func (a *ApplicationService) IsInterestedInRoomAlias(
|
||||||
|
Loading…
Reference in New Issue
Block a user