data_import: Add email validation to third-party data converters.

This commit makes the third-party data converters check for invalid user
emails. If it finds any, it’ll raise an Exception and show an error
message with all the bad emails listed out.

Fixes: #31783
This commit is contained in:
PieterCK
2024-09-30 15:26:03 +07:00
committed by Tim Abbott
parent 7ffe558e81
commit 6289a551aa
8 changed files with 68 additions and 10 deletions

View File

@@ -39,6 +39,7 @@ from zerver.data_import.import_util import (
process_avatars,
process_emojis,
process_uploads,
validate_user_emails_for_import,
)
from zerver.data_import.sequencer import NEXT_ID
from zerver.data_import.slack_message_conversion import (
@@ -358,6 +359,7 @@ def users_to_zerver_userprofile(
logging.info("%s: %s -> %s", slack_user_id, user["name"], userprofile_dict["email"])
validate_user_emails_for_import(list(found_emails))
process_customprofilefields(zerver_customprofilefield, zerver_customprofilefield_values)
logging.info("######### IMPORTING USERS FINISHED #########\n")
return (