mirror of https://github.com/zulip/zulip.git
slack import: Improve algorithm and formatting for attachments.
The previous system would crash with some files (because for some reason the comment count was 1 but there was no "initial comment") and also the file comment and file name were sorta redundant.
This commit is contained in:
parent
06071166c7
commit
99bae7fa5d
|
@ -671,14 +671,7 @@ def get_attachment_path_and_content(fileinfo: ZerverFieldsT, realm_id: int) -> T
|
|||
sanitize_name(fileinfo['name'])
|
||||
])
|
||||
attachment_path = ('/user_uploads/%s' % (s3_path))
|
||||
|
||||
# change the default upload message: 'uploaded this file: <file_name>' in Slack
|
||||
# to '<file_comment> <file_name>'
|
||||
if fileinfo['comments_count'] != 0:
|
||||
file_comment = fileinfo['initial_comment'].get("comment", '')
|
||||
else:
|
||||
file_comment = ''
|
||||
content = '%s [%s](%s)' % (file_comment, fileinfo['name'], attachment_path)
|
||||
content = '[%s](%s)' % (fileinfo['title'], attachment_path)
|
||||
|
||||
return s3_path, content
|
||||
|
||||
|
|
Loading…
Reference in New Issue