mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-19 09:31:35 +03:00
Don't restrict non-fed rooms over client APIs
This commit is contained in:
parent
ffa64f373a
commit
280068e28c
3 changed files with 22 additions and 14 deletions
|
@ -697,7 +697,8 @@ class PublicRoomList(BaseFederationServlet):
|
||||||
|
|
||||||
data = yield self.handler.get_local_public_room_list(
|
data = yield self.handler.get_local_public_room_list(
|
||||||
limit, since_token,
|
limit, since_token,
|
||||||
network_tuple=network_tuple
|
network_tuple=network_tuple,
|
||||||
|
from_federation=True,
|
||||||
)
|
)
|
||||||
defer.returnValue((200, data))
|
defer.returnValue((200, data))
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class GroupsServerHandler(object):
|
||||||
room_id = room_entry["room_id"]
|
room_id = room_entry["room_id"]
|
||||||
joined_users = yield self.store.get_users_in_room(room_id)
|
joined_users = yield self.store.get_users_in_room(room_id)
|
||||||
entry = yield self.room_list_handler.generate_room_entry(
|
entry = yield self.room_list_handler.generate_room_entry(
|
||||||
room_id, len(joined_users),
|
room_id, True, len(joined_users),
|
||||||
with_alias=False, allow_private=True,
|
with_alias=False, allow_private=True,
|
||||||
)
|
)
|
||||||
entry = dict(entry) # so we don't change whats cached
|
entry = dict(entry) # so we don't change whats cached
|
||||||
|
@ -544,7 +544,7 @@ class GroupsServerHandler(object):
|
||||||
|
|
||||||
joined_users = yield self.store.get_users_in_room(room_id)
|
joined_users = yield self.store.get_users_in_room(room_id)
|
||||||
entry = yield self.room_list_handler.generate_room_entry(
|
entry = yield self.room_list_handler.generate_room_entry(
|
||||||
room_id, len(joined_users),
|
room_id, True, len(joined_users),
|
||||||
with_alias=False, allow_private=True,
|
with_alias=False, allow_private=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ class RoomListHandler(BaseHandler):
|
||||||
|
|
||||||
def get_local_public_room_list(self, limit=None, since_token=None,
|
def get_local_public_room_list(self, limit=None, since_token=None,
|
||||||
search_filter=None,
|
search_filter=None,
|
||||||
network_tuple=EMPTY_THIRD_PARTY_ID,):
|
network_tuple=EMPTY_THIRD_PARTY_ID,
|
||||||
|
from_federation=False):
|
||||||
"""Generate a local public room list.
|
"""Generate a local public room list.
|
||||||
|
|
||||||
There are multiple different lists: the main one plus one per third
|
There are multiple different lists: the main one plus one per third
|
||||||
|
@ -82,13 +83,15 @@ class RoomListHandler(BaseHandler):
|
||||||
return self.response_cache.wrap(
|
return self.response_cache.wrap(
|
||||||
key,
|
key,
|
||||||
self._get_public_room_list,
|
self._get_public_room_list,
|
||||||
limit, since_token, network_tuple=network_tuple,
|
limit, since_token,
|
||||||
|
network_tuple=network_tuple, from_federation=from_federation,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get_public_room_list(self, limit=None, since_token=None,
|
def _get_public_room_list(self, limit=None, since_token=None,
|
||||||
search_filter=None,
|
search_filter=None,
|
||||||
network_tuple=EMPTY_THIRD_PARTY_ID,):
|
network_tuple=EMPTY_THIRD_PARTY_ID,
|
||||||
|
from_federation=False,):
|
||||||
if since_token and since_token != "END":
|
if since_token and since_token != "END":
|
||||||
since_token = RoomListNextBatch.from_token(since_token)
|
since_token = RoomListNextBatch.from_token(since_token)
|
||||||
else:
|
else:
|
||||||
|
@ -208,7 +211,8 @@ class RoomListHandler(BaseHandler):
|
||||||
yield concurrently_execute(
|
yield concurrently_execute(
|
||||||
lambda r: self._append_room_entry_to_chunk(
|
lambda r: self._append_room_entry_to_chunk(
|
||||||
r, rooms_to_num_joined[r],
|
r, rooms_to_num_joined[r],
|
||||||
chunk, limit, search_filter
|
chunk, limit, search_filter,
|
||||||
|
from_federation=from_federation,
|
||||||
),
|
),
|
||||||
batch, 5,
|
batch, 5,
|
||||||
)
|
)
|
||||||
|
@ -279,7 +283,7 @@ class RoomListHandler(BaseHandler):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _append_room_entry_to_chunk(self, room_id, num_joined_users, chunk, limit,
|
def _append_room_entry_to_chunk(self, room_id, num_joined_users, chunk, limit,
|
||||||
search_filter):
|
search_filter, from_federation=False):
|
||||||
"""Generate the entry for a room in the public room list and append it
|
"""Generate the entry for a room in the public room list and append it
|
||||||
to the `chunk` if it matches the search filter
|
to the `chunk` if it matches the search filter
|
||||||
"""
|
"""
|
||||||
|
@ -287,16 +291,19 @@ class RoomListHandler(BaseHandler):
|
||||||
# We've already got enough, so lets just drop it.
|
# We've already got enough, so lets just drop it.
|
||||||
return
|
return
|
||||||
|
|
||||||
result = yield self.generate_room_entry(room_id, num_joined_users,
|
if from_federation:
|
||||||
allow_federated=self.config.allow_non_federated_in_public_rooms)
|
result = yield self.generate_room_entry(room_id,
|
||||||
|
self.config.allow_non_federated_in_public_rooms,
|
||||||
|
num_joined_users)
|
||||||
|
else:
|
||||||
|
result = yield self.generate_room_entry(room_id, True, num_joined_users)
|
||||||
|
|
||||||
if result and _matches_room_entry(result, search_filter):
|
if result and _matches_room_entry(result, search_filter):
|
||||||
chunk.append(result)
|
chunk.append(result)
|
||||||
|
|
||||||
@cachedInlineCallbacks(num_args=1, cache_context=True)
|
@cachedInlineCallbacks(num_args=2, cache_context=True)
|
||||||
def generate_room_entry(self, room_id, num_joined_users, cache_context,
|
def generate_room_entry(self, room_id, allow_federated, num_joined_users,
|
||||||
with_alias=True, allow_private=False,
|
cache_context, with_alias=True, allow_private=False):
|
||||||
allow_federated=True):
|
|
||||||
"""Returns the entry for a room
|
"""Returns the entry for a room
|
||||||
"""
|
"""
|
||||||
result = {
|
result = {
|
||||||
|
|
Loading…
Reference in a new issue