|
|
|
@ -16,7 +16,7 @@ |
|
|
|
|
""" This module contains REST servlets to do with rooms: /rooms/<paths> """ |
|
|
|
|
from twisted.internet import defer |
|
|
|
|
|
|
|
|
|
from base import RestServlet, client_path_pattern |
|
|
|
|
from base import ClientV1RestServlet, client_path_pattern |
|
|
|
|
from synapse.api.errors import SynapseError, Codes |
|
|
|
|
from synapse.streams.config import PaginationConfig |
|
|
|
|
from synapse.api.constants import EventTypes, Membership |
|
|
|
@ -30,7 +30,7 @@ import urllib |
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RoomCreateRestServlet(RestServlet): |
|
|
|
|
class RoomCreateRestServlet(ClientV1RestServlet): |
|
|
|
|
# No PATTERN; we have custom dispatch rules here |
|
|
|
|
|
|
|
|
|
def register(self, http_server): |
|
|
|
@ -94,7 +94,7 @@ class RoomCreateRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing for generic events |
|
|
|
|
class RoomStateEventRestServlet(RestServlet): |
|
|
|
|
class RoomStateEventRestServlet(ClientV1RestServlet): |
|
|
|
|
def register(self, http_server): |
|
|
|
|
# /room/$roomid/state/$eventtype |
|
|
|
|
no_state_key = "/rooms/(?P<room_id>[^/]*)/state/(?P<event_type>[^/]*)$" |
|
|
|
@ -163,7 +163,7 @@ class RoomStateEventRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing for generic events + feedback |
|
|
|
|
class RoomSendEventRestServlet(RestServlet): |
|
|
|
|
class RoomSendEventRestServlet(ClientV1RestServlet): |
|
|
|
|
|
|
|
|
|
def register(self, http_server): |
|
|
|
|
# /rooms/$roomid/send/$event_type[/$txn_id] |
|
|
|
@ -206,7 +206,7 @@ class RoomSendEventRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing for room ID + alias joins |
|
|
|
|
class JoinRoomAliasServlet(RestServlet): |
|
|
|
|
class JoinRoomAliasServlet(ClientV1RestServlet): |
|
|
|
|
|
|
|
|
|
def register(self, http_server): |
|
|
|
|
# /join/$room_identifier[/$txn_id] |
|
|
|
@ -265,7 +265,7 @@ class JoinRoomAliasServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class PublicRoomListRestServlet(RestServlet): |
|
|
|
|
class PublicRoomListRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/publicRooms$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -276,7 +276,7 @@ class PublicRoomListRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class RoomMemberListRestServlet(RestServlet): |
|
|
|
|
class RoomMemberListRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/members$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -305,7 +305,7 @@ class RoomMemberListRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class RoomMessageListRestServlet(RestServlet): |
|
|
|
|
class RoomMessageListRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/messages$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -329,7 +329,7 @@ class RoomMessageListRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class RoomStateRestServlet(RestServlet): |
|
|
|
|
class RoomStateRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/state$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -345,7 +345,7 @@ class RoomStateRestServlet(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class RoomInitialSyncRestServlet(RestServlet): |
|
|
|
|
class RoomInitialSyncRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/initialSync$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -360,7 +360,7 @@ class RoomInitialSyncRestServlet(RestServlet): |
|
|
|
|
defer.returnValue((200, content)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RoomTriggerBackfill(RestServlet): |
|
|
|
|
class RoomTriggerBackfill(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern("/rooms/(?P<room_id>[^/]*)/backfill$") |
|
|
|
|
|
|
|
|
|
@defer.inlineCallbacks |
|
|
|
@ -379,7 +379,7 @@ class RoomTriggerBackfill(RestServlet): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Needs unit testing |
|
|
|
|
class RoomMembershipRestServlet(RestServlet): |
|
|
|
|
class RoomMembershipRestServlet(ClientV1RestServlet): |
|
|
|
|
|
|
|
|
|
def register(self, http_server): |
|
|
|
|
# /rooms/$roomid/[invite|join|leave] |
|
|
|
@ -431,7 +431,7 @@ class RoomMembershipRestServlet(RestServlet): |
|
|
|
|
defer.returnValue(response) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RoomRedactEventRestServlet(RestServlet): |
|
|
|
|
class RoomRedactEventRestServlet(ClientV1RestServlet): |
|
|
|
|
def register(self, http_server): |
|
|
|
|
PATTERN = ("/rooms/(?P<room_id>[^/]*)/redact/(?P<event_id>[^/]*)") |
|
|
|
|
register_txn_path(self, PATTERN, http_server) |
|
|
|
@ -469,7 +469,7 @@ class RoomRedactEventRestServlet(RestServlet): |
|
|
|
|
defer.returnValue(response) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RoomTypingRestServlet(RestServlet): |
|
|
|
|
class RoomTypingRestServlet(ClientV1RestServlet): |
|
|
|
|
PATTERN = client_path_pattern( |
|
|
|
|
"/rooms/(?P<room_id>[^/]*)/typing/(?P<user_id>[^/]*)$" |
|
|
|
|
) |
|
|
|
|