wip tests to filter out support user
This commit is contained in:
@@ -339,7 +339,7 @@ class UserDirectoryStore(SQLBaseStore):
|
||||
rows = yield self._execute("get_all_local_users", None, sql)
|
||||
defer.returnValue([name for name, in rows])
|
||||
|
||||
def add_users_who_share_room(self, room_id, share_private, user_id_tuples):
|
||||
def add_users_who_share_room(self, room_id, share_private, user_id_tuples_x):
|
||||
"""Insert entries into the users_who_share_rooms table. The first
|
||||
user should be a local user.
|
||||
|
||||
@@ -350,9 +350,7 @@ class UserDirectoryStore(SQLBaseStore):
|
||||
"""
|
||||
def _add_users_who_share_room_txn(txn):
|
||||
support_user = self.hs.config.support_user_id
|
||||
for ut in user_id_tuples:
|
||||
if support_user in ut:
|
||||
user_id_tuples.remove(ut)
|
||||
user_id_tuples = filter(lambda x: support_user not in x, user_id_tuples_x)
|
||||
|
||||
self._simple_insert_many_txn(
|
||||
txn,
|
||||
|
||||
@@ -75,3 +75,42 @@ class UserDirectoryStoreTestCase(unittest.TestCase):
|
||||
)
|
||||
finally:
|
||||
self.hs.config.user_directory_search_all_users = False
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_cannot_add_support_user_to_directory(self):
|
||||
self.hs.config.user_directory_search_all_users = True
|
||||
self.hs.config.support_user_id = "@support:test"
|
||||
SUPPORT_USER = self.hs.config.support_user_id
|
||||
yield self.store.add_profiles_to_user_dir(
|
||||
"!room:id",
|
||||
{SUPPORT_USER: ProfileInfo(None, "support")},
|
||||
)
|
||||
yield self.store.add_users_to_public_room("!room:id", [SUPPORT_USER])
|
||||
yield self.store.add_users_who_share_room(
|
||||
"!room:id", False, ((ALICE, SUPPORT_USER),)
|
||||
)
|
||||
|
||||
r = yield self.store.search_user_dir(ALICE, "support", 10)
|
||||
self.assertFalse(r["limited"])
|
||||
self.assertEqual(0, len(r["results"]))
|
||||
|
||||
# add_users_who_share_room
|
||||
# add_users_to_public_room
|
||||
# add_profiles_to_user_dir
|
||||
# update_user_in_user_dir
|
||||
# update_profile_in_user_dir
|
||||
# update_user_in_public_user_list
|
||||
|
||||
# yield self.store.add_profiles_to_user_dir(
|
||||
# "!room:id",
|
||||
# {SUPPORT_USER: ProfileInfo(None, "support")},
|
||||
# )
|
||||
# yield self.store.add_profiles_to_user_dir(SUPPORT_USER,
|
||||
#
|
||||
#
|
||||
#
|
||||
# yield self.store.add_users_to_public_room("!room:id", [SUPPORT_USER])
|
||||
#
|
||||
# yield self.store.add_users_who_share_room(
|
||||
# "!room:id", False, ((ALICE, SUPPORT_USER), (BOB, SUPPORT_USER))
|
||||
# )
|
||||
|
||||
Reference in New Issue
Block a user