mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
slack_data_import: Update how Slack user avatars are processed.
Previously, the Slack export converter can only process Slack's avatar URL from Slack's "ca.slack-edge.com" server, which looks like this: https://ca.slack-edge.com/T0CDRA6HM3P-U06NABE26M9-1173e04f818e-512 This commit adds support for converting any public downloadable image URLs. This is done to support importing Slack's integration bots and their messages, which typically have PNG type file url: https://avatars.slack-edge.com/2024-05-01/7057208497908_a4351f6deb91094eac4c_72.png
This commit is contained in:
@@ -560,7 +560,11 @@ def get_avatar(avatar_dir: str, size_url_suffix: str, avatar_upload_item: list[s
|
||||
image_path = os.path.join(avatar_dir, avatar_upload_item[1])
|
||||
original_image_path = os.path.join(avatar_dir, avatar_upload_item[2])
|
||||
|
||||
response = requests.get(avatar_url + size_url_suffix, stream=True)
|
||||
if avatar_url.startswith("https://ca.slack-edge.com/"):
|
||||
# Adjust the avatar size for a typical Slack user.
|
||||
avatar_url += size_url_suffix
|
||||
|
||||
response = requests.get(avatar_url, stream=True)
|
||||
with open(image_path, "wb") as image_file:
|
||||
shutil.copyfileobj(response.raw, image_file)
|
||||
shutil.copy(image_path, original_image_path)
|
||||
|
||||
Reference in New Issue
Block a user