Replace hs.parse_roomid with RoomID.from_string
parent
5759bec43c
commit
1c06c48ce2
|
@ -246,8 +246,6 @@ class RoomMemberHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_room_members(self, room_id):
|
def get_room_members(self, room_id):
|
||||||
hs = self.hs
|
|
||||||
|
|
||||||
users = yield self.store.get_users_in_room(room_id)
|
users = yield self.store.get_users_in_room(room_id)
|
||||||
|
|
||||||
defer.returnValue([UserID.from_string(u) for u in users])
|
defer.returnValue([UserID.from_string(u) for u in users])
|
||||||
|
|
|
@ -20,7 +20,7 @@ from base import RestServlet, client_path_pattern
|
||||||
from synapse.api.errors import SynapseError, Codes
|
from synapse.api.errors import SynapseError, Codes
|
||||||
from synapse.streams.config import PaginationConfig
|
from synapse.streams.config import PaginationConfig
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID, RoomID
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
@ -227,7 +227,7 @@ class JoinRoomAliasServlet(RestServlet):
|
||||||
identifier = self.hs.parse_roomalias(room_identifier)
|
identifier = self.hs.parse_roomalias(room_identifier)
|
||||||
is_room_alias = True
|
is_room_alias = True
|
||||||
except SynapseError:
|
except SynapseError:
|
||||||
identifier = self.hs.parse_roomid(room_identifier)
|
identifier = RoomID.from_string(room_identifier)
|
||||||
|
|
||||||
# TODO: Support for specifying the home server to join with?
|
# TODO: Support for specifying the home server to join with?
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ from synapse.api.auth import Auth
|
||||||
from synapse.handlers import Handlers
|
from synapse.handlers import Handlers
|
||||||
from synapse.state import StateHandler
|
from synapse.state import StateHandler
|
||||||
from synapse.storage import DataStore
|
from synapse.storage import DataStore
|
||||||
from synapse.types import UserID, RoomAlias, RoomID, EventID
|
from synapse.types import RoomAlias, EventID
|
||||||
from synapse.util import Clock
|
from synapse.util import Clock
|
||||||
from synapse.util.distributor import Distributor
|
from synapse.util.distributor import Distributor
|
||||||
from synapse.util.lockutils import LockManager
|
from synapse.util.lockutils import LockManager
|
||||||
|
@ -132,11 +132,6 @@ class BaseHomeServer(object):
|
||||||
object."""
|
object."""
|
||||||
return RoomAlias.from_string(s)
|
return RoomAlias.from_string(s)
|
||||||
|
|
||||||
def parse_roomid(self, s):
|
|
||||||
"""Parse the string given by 's' as a Room ID and return a RoomID
|
|
||||||
object."""
|
|
||||||
return RoomID.from_string(s)
|
|
||||||
|
|
||||||
def parse_eventid(self, s):
|
def parse_eventid(self, s):
|
||||||
"""Parse the string given by 's' as a Event ID and return a EventID
|
"""Parse the string given by 's' as a Event ID and return a EventID
|
||||||
object."""
|
object."""
|
||||||
|
|
|
@ -19,6 +19,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.directory import DirectoryStore
|
from synapse.storage.directory import DirectoryStore
|
||||||
|
from synapse.types import RoomID
|
||||||
|
|
||||||
from tests.utils import SQLiteMemoryDbPool
|
from tests.utils import SQLiteMemoryDbPool
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ class DirectoryStoreTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.store = DirectoryStore(hs)
|
self.store = DirectoryStore(hs)
|
||||||
|
|
||||||
self.room = hs.parse_roomid("!abcde:test")
|
self.room = RoomID.from_string("!abcde:test")
|
||||||
self.alias = hs.parse_roomalias("#my-room:test")
|
self.alias = hs.parse_roomalias("#my-room:test")
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
|
@ -19,7 +19,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID, RoomID
|
||||||
|
|
||||||
from tests.utils import SQLiteMemoryDbPool, MockKey
|
from tests.utils import SQLiteMemoryDbPool, MockKey
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class RedactionTestCase(unittest.TestCase):
|
||||||
self.u_alice = UserID.from_string("@alice:test")
|
self.u_alice = UserID.from_string("@alice:test")
|
||||||
self.u_bob = UserID.from_string("@bob:test")
|
self.u_bob = UserID.from_string("@bob:test")
|
||||||
|
|
||||||
self.room1 = hs.parse_roomid("!abc123:test")
|
self.room1 = RoomID.from_string("!abc123:test")
|
||||||
|
|
||||||
self.depth = 1
|
self.depth = 1
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.api.constants import EventTypes
|
from synapse.api.constants import EventTypes
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID, RoomID
|
||||||
|
|
||||||
from tests.utils import SQLiteMemoryDbPool
|
from tests.utils import SQLiteMemoryDbPool
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class RoomStoreTestCase(unittest.TestCase):
|
||||||
# management of the 'room_aliases' table
|
# management of the 'room_aliases' table
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
|
|
||||||
self.room = hs.parse_roomid("!abcde:test")
|
self.room = RoomID.from_string("!abcde:test")
|
||||||
self.alias = hs.parse_roomalias("#a-room-name:test")
|
self.alias = hs.parse_roomalias("#a-room-name:test")
|
||||||
self.u_creator = UserID.from_string("@creator:test")
|
self.u_creator = UserID.from_string("@creator:test")
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class RoomEventsStoreTestCase(unittest.TestCase):
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.event_factory = hs.get_event_factory();
|
self.event_factory = hs.get_event_factory();
|
||||||
|
|
||||||
self.room = hs.parse_roomid("!abcde:test")
|
self.room = RoomID.from_string("!abcde:test")
|
||||||
|
|
||||||
yield self.store.store_room(self.room.to_string(),
|
yield self.store.store_room(self.room.to_string(),
|
||||||
room_creator_user_id="@creator:text",
|
room_creator_user_id="@creator:text",
|
||||||
|
|
|
@ -19,7 +19,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID, RoomID
|
||||||
|
|
||||||
from tests.utils import SQLiteMemoryDbPool, MockKey
|
from tests.utils import SQLiteMemoryDbPool, MockKey
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class RoomMemberStoreTestCase(unittest.TestCase):
|
||||||
# User elsewhere on another host
|
# User elsewhere on another host
|
||||||
self.u_charlie = UserID.from_string("@charlie:elsewhere")
|
self.u_charlie = UserID.from_string("@charlie:elsewhere")
|
||||||
|
|
||||||
self.room = hs.parse_roomid("!abc123:test")
|
self.room = RoomID.from_string("!abc123:test")
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def inject_room_member(self, room, user, membership, replaces_state=None):
|
def inject_room_member(self, room, user, membership, replaces_state=None):
|
||||||
|
|
|
@ -19,7 +19,7 @@ from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.api.constants import EventTypes, Membership
|
from synapse.api.constants import EventTypes, Membership
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID, RoomID
|
||||||
|
|
||||||
from tests.utils import SQLiteMemoryDbPool, MockKey
|
from tests.utils import SQLiteMemoryDbPool, MockKey
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ class StreamStoreTestCase(unittest.TestCase):
|
||||||
self.u_alice = UserID.from_string("@alice:test")
|
self.u_alice = UserID.from_string("@alice:test")
|
||||||
self.u_bob = UserID.from_string("@bob:test")
|
self.u_bob = UserID.from_string("@bob:test")
|
||||||
|
|
||||||
self.room1 = hs.parse_roomid("!abc123:test")
|
self.room1 = RoomID.from_string("!abc123:test")
|
||||||
self.room2 = hs.parse_roomid("!xyx987:test")
|
self.room2 = RoomID.from_string("!xyx987:test")
|
||||||
|
|
||||||
self.depth = 1
|
self.depth = 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue