23
23
24
24
from synapse .api .constants import EventTypes
25
25
from synapse .events import EventBase
26
- from synapse .types import (
27
- DeviceListUpdates ,
28
- GroupID ,
29
- JsonDict ,
30
- UserID ,
31
- get_domain_from_id ,
32
- )
26
+ from synapse .types import DeviceListUpdates , JsonDict , UserID
33
27
from synapse .util .caches .descriptors import _CacheContext , cached
34
28
35
29
if TYPE_CHECKING :
@@ -55,7 +49,6 @@ class ApplicationServiceState(Enum):
55
49
@attr .s (slots = True , frozen = True , auto_attribs = True )
56
50
class Namespace :
57
51
exclusive : bool
58
- group_id : Optional [str ]
59
52
regex : Pattern [str ]
60
53
61
54
@@ -141,30 +134,13 @@ def _check_namespaces(
141
134
exclusive = regex_obj .get ("exclusive" )
142
135
if not isinstance (exclusive , bool ):
143
136
raise ValueError ("Expected bool for 'exclusive' in ns '%s'" % ns )
144
- group_id = regex_obj .get ("group_id" )
145
- if group_id :
146
- if not isinstance (group_id , str ):
147
- raise ValueError (
148
- "Expected string for 'group_id' in ns '%s'" % ns
149
- )
150
- try :
151
- GroupID .from_string (group_id )
152
- except Exception :
153
- raise ValueError (
154
- "Expected valid group ID for 'group_id' in ns '%s'" % ns
155
- )
156
-
157
- if get_domain_from_id (group_id ) != self .server_name :
158
- raise ValueError (
159
- "Expected 'group_id' to be this host in ns '%s'" % ns
160
- )
161
137
162
138
regex = regex_obj .get ("regex" )
163
139
if not isinstance (regex , str ):
164
140
raise ValueError ("Expected string for 'regex' in ns '%s'" % ns )
165
141
166
142
# Pre-compile regex.
167
- result [ns ].append (Namespace (exclusive , group_id , re .compile (regex )))
143
+ result [ns ].append (Namespace (exclusive , re .compile (regex )))
168
144
169
145
return result
170
146
@@ -369,21 +345,6 @@ def get_exclusive_user_regexes(self) -> List[Pattern[str]]:
369
345
if namespace .exclusive
370
346
]
371
347
372
- def get_groups_for_user (self , user_id : str ) -> Iterable [str ]:
373
- """Get the groups that this user is associated with by this AS
374
-
375
- Args:
376
- user_id: The ID of the user.
377
-
378
- Returns:
379
- An iterable that yields group_id strings.
380
- """
381
- return (
382
- namespace .group_id
383
- for namespace in self .namespaces [ApplicationService .NS_USERS ]
384
- if namespace .group_id and namespace .regex .match (user_id )
385
- )
386
-
387
348
def is_rate_limited (self ) -> bool :
388
349
return self .rate_limited
389
350
0 commit comments