Rename store_room()'s is_public parameter to published; default it from the badly-named "visiblity" parameter but allow a new "published" to override it
This commit is contained in:
parent
7c5315b1a8
commit
a197d2492f
|
@ -189,7 +189,7 @@ class FederationHandler(BaseHandler):
|
||||||
yield self.store.store_room(
|
yield self.store.store_room(
|
||||||
room_id=event.room_id,
|
room_id=event.room_id,
|
||||||
room_creator_user_id="",
|
room_creator_user_id="",
|
||||||
is_public=False,
|
published=False,
|
||||||
)
|
)
|
||||||
except StoreError:
|
except StoreError:
|
||||||
logger.exception("Failed to store room.")
|
logger.exception("Failed to store room.")
|
||||||
|
@ -594,7 +594,7 @@ class FederationHandler(BaseHandler):
|
||||||
yield self.store.store_room(
|
yield self.store.store_room(
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
room_creator_user_id="",
|
room_creator_user_id="",
|
||||||
is_public=False
|
published=False,
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
# FIXME
|
# FIXME
|
||||||
|
|
|
@ -77,6 +77,14 @@ class RoomCreationHandler(BaseHandler):
|
||||||
|
|
||||||
is_public = config.get("visibility", None) == "public"
|
is_public = config.get("visibility", None) == "public"
|
||||||
|
|
||||||
|
# By default, all public-joinable rooms are published. Allow overriding
|
||||||
|
# that decision.
|
||||||
|
# TODO(paul): Specify 'published' key
|
||||||
|
if "published" in config:
|
||||||
|
published = config["published"]
|
||||||
|
else:
|
||||||
|
published = is_public
|
||||||
|
|
||||||
if room_id:
|
if room_id:
|
||||||
# Ensure room_id is the correct type
|
# Ensure room_id is the correct type
|
||||||
room_id_obj = RoomID.from_string(room_id)
|
room_id_obj = RoomID.from_string(room_id)
|
||||||
|
@ -86,7 +94,7 @@ class RoomCreationHandler(BaseHandler):
|
||||||
yield self.store.store_room(
|
yield self.store.store_room(
|
||||||
room_id=room_id,
|
room_id=room_id,
|
||||||
room_creator_user_id=user_id,
|
room_creator_user_id=user_id,
|
||||||
is_public=is_public
|
published=published,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# autogen room IDs and try to create it. We may clash, so just
|
# autogen room IDs and try to create it. We may clash, so just
|
||||||
|
@ -103,7 +111,7 @@ class RoomCreationHandler(BaseHandler):
|
||||||
yield self.store.store_room(
|
yield self.store.store_room(
|
||||||
room_id=gen_room_id.to_string(),
|
room_id=gen_room_id.to_string(),
|
||||||
room_creator_user_id=user_id,
|
room_creator_user_id=user_id,
|
||||||
is_public=is_public
|
published=published,
|
||||||
)
|
)
|
||||||
room_id = gen_room_id.to_string()
|
room_id = gen_room_id.to_string()
|
||||||
break
|
break
|
||||||
|
|
|
@ -34,14 +34,14 @@ OpsLevel = collections.namedtuple(
|
||||||
class RoomStore(SQLBaseStore):
|
class RoomStore(SQLBaseStore):
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def store_room(self, room_id, room_creator_user_id, is_public):
|
def store_room(self, room_id, room_creator_user_id, published):
|
||||||
"""Stores a room.
|
"""Stores a room.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
room_id (str): The desired room ID, can be None.
|
room_id (str): The desired room ID, can be None.
|
||||||
room_creator_user_id (str): The user ID of the room creator.
|
room_creator_user_id (str): The user ID of the room creator.
|
||||||
is_public (bool): True to indicate that this room should appear in
|
published (bool): True to indicate that this room should appear in
|
||||||
public room lists.
|
published room lists.
|
||||||
Raises:
|
Raises:
|
||||||
StoreError if the room could not be stored.
|
StoreError if the room could not be stored.
|
||||||
"""
|
"""
|
||||||
|
@ -51,7 +51,8 @@ class RoomStore(SQLBaseStore):
|
||||||
{
|
{
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"creator": room_creator_user_id,
|
"creator": room_creator_user_id,
|
||||||
"is_public": is_public,
|
# TODO(paul): rename this table in the SQL schema
|
||||||
|
"is_public": published,
|
||||||
},
|
},
|
||||||
desc="store_room",
|
desc="store_room",
|
||||||
)
|
)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class RoomStoreTestCase(unittest.TestCase):
|
||||||
|
|
||||||
yield self.store.store_room(self.room.to_string(),
|
yield self.store.store_room(self.room.to_string(),
|
||||||
room_creator_user_id=self.u_creator.to_string(),
|
room_creator_user_id=self.u_creator.to_string(),
|
||||||
is_public=True
|
published=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -91,7 +91,7 @@ class RoomEventsStoreTestCase(unittest.TestCase):
|
||||||
|
|
||||||
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",
|
||||||
is_public=True
|
published=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
|
Loading…
Reference in New Issue