Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
import/rocketchat: Import users with the "bot" role as bots.
PieterCK68812981b397
diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.pyindex 84272340346..08cae1a78a6 100644--- a/zerver/data_import/rocketchat.py+++ b/zerver/data_import/rocketchat.py@@ -219,14 +219,15 @@ def process_users(role = UserProfile.ROLE_MEMBERif "admin" in user_dict["roles"]:role = UserProfile.ROLE_REALM_OWNER- realm_owners.append(id)elif "guest" in user_dict["roles"]:role = UserProfile.ROLE_GUEST- elif "bot" in user_dict["roles"]:+ if "bot" in user_dict["roles"]:is_bot = Trueif is_bot:bots.append(id)+ elif role == UserProfile.ROLE_REALM_OWNER:+ realm_owners.append(id)user = build_user_profile(avatar_source=avatar_source,diff --git a/zerver/tests/test_rocketchat_importer.py b/zerver/tests/test_rocketchat_importer.pyindex cd986d2377d..0f927408752 100644--- a/zerver/tests/test_rocketchat_importer.py+++ b/zerver/tests/test_rocketchat_importer.py@@ -179,6 +179,35 @@ class RocketChatImporter(ZulipTestCase):self.assertEqual(user["is_mirror_dummy"], True)self.assertEqual(user["is_bot"], False)+ # Users with the "bot" role are bots, even if they have other+ # roles.+ admin_bot: dict[str, Any] = {+ "_id": "4dm1nB0tID",+ "createdAt": datetime(2019, 11, 6, 0, 38, 42, 796000, tzinfo=timezone.utc),+ "type": "user",+ "roles": ["admin", "bot"],+ "name": "Admin bot",+ "username": "admin.bot",+ }+ user_id_to_user_map = map_user_id_to_user([admin_bot, *rocketchat_data["user"]])++ process_users(+ user_id_to_user_map=user_id_to_user_map,+ realm_id=realm_id,+ domain_name=domain_name,+ user_handler=user_handler,+ user_id_mapper=user_id_mapper,+ )++ user_id = user_id_mapper.get(admin_bot["_id"])+ user = user_handler.get_user(user_id)++ self.assertEqual(user["is_active"], True)+ self.assertEqual(user["is_bot"], True)+ self.assertEqual(user["bot_type"], 1)+ self.assertEqual(user["bot_owner"], 2)+ self.assertEqual(user["role"], UserProfile.ROLE_REALM_OWNER)+# Importer should raise error when user emails are malformedbad_email1 = rocketchat_data["user"][0]["emails"][0]["address"] = "test1@hotmai,l.om"bad_email2 = rocketchat_data["user"][1]["emails"][0]["address"] = "[email protected]"