Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 431034a

Browse files
committed
Remove GroupID construct.
1 parent 17a6aa0 commit 431034a

File tree

2 files changed

+1
-43
lines changed

2 files changed

+1
-43
lines changed

synapse/types.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -320,29 +320,6 @@ class EventID(DomainSpecificString):
320320
SIGIL = "$"
321321

322322

323-
@attr.s(slots=True, frozen=True, repr=False)
324-
class GroupID(DomainSpecificString):
325-
"""Structure representing a group ID."""
326-
327-
SIGIL = "+"
328-
329-
@classmethod
330-
def from_string(cls: Type[DS], s: str) -> DS:
331-
group_id: DS = super().from_string(s) # type: ignore
332-
333-
if not group_id.localpart:
334-
raise SynapseError(400, "Group ID cannot be empty", Codes.INVALID_PARAM)
335-
336-
if contains_invalid_mxid_characters(group_id.localpart):
337-
raise SynapseError(
338-
400,
339-
"Group ID can only contain characters a-z, 0-9, or '=_-./'",
340-
Codes.INVALID_PARAM,
341-
)
342-
343-
return group_id
344-
345-
346323
mxid_localpart_allowed_characters = set(
347324
"_-./=" + string.ascii_lowercase + string.digits
348325
)

tests/test_types.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from synapse.api.errors import SynapseError
16-
from synapse.types import GroupID, RoomAlias, UserID, map_username_to_mxid_localpart
16+
from synapse.types import RoomAlias, UserID, map_username_to_mxid_localpart
1717

1818
from tests import unittest
1919

@@ -62,25 +62,6 @@ def test_validate(self):
6262
self.assertFalse(RoomAlias.is_valid(id_string))
6363

6464

65-
class GroupIDTestCase(unittest.TestCase):
66-
def test_parse(self):
67-
group_id = GroupID.from_string("+group/=_-.123:my.domain")
68-
self.assertEqual("group/=_-.123", group_id.localpart)
69-
self.assertEqual("my.domain", group_id.domain)
70-
71-
def test_validate(self):
72-
bad_ids = ["$badsigil:domain", "+:empty"] + [
73-
"+group" + c + ":domain" for c in "A%?æ£"
74-
]
75-
for id_string in bad_ids:
76-
try:
77-
GroupID.from_string(id_string)
78-
self.fail("Parsing '%s' should raise exception" % id_string)
79-
except SynapseError as exc:
80-
self.assertEqual(400, exc.code)
81-
self.assertEqual("M_INVALID_PARAM", exc.errcode)
82-
83-
8465
class MapUsernameTestCase(unittest.TestCase):
8566
def testPassThrough(self):
8667
self.assertEqual(map_username_to_mxid_localpart("test1234"), "test1234")

0 commit comments

Comments
 (0)