mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 15:15:12 +08:00
Include unnamed files as attachements and rename to 'Unnamed Attachement'
Summary: Fixes T2024 and renames unnamed files to Unnamed Attachment before appending the attachement component to message list Test Plan: Added a test to ensure file without filename is renamed to Unnamed Attachment Reviewers: bengotow Reviewed By: bengotow Maniphest Tasks: T2024 Differential Revision: https://phab.nylas.com/D1685
This commit is contained in:
parent
13f3669ebf
commit
b42d102740
3 changed files with 9 additions and 18 deletions
|
@ -39,7 +39,7 @@ class AttachmentComponent extends React.Component
|
|||
fallback="file-fallback.png"
|
||||
name="file-#{@_extension()}.png"/>
|
||||
</span>
|
||||
<span className="attachment-file-name">{@props.file.filename}</span>
|
||||
<span className="attachment-file-name">{@props.file.filename ? "Unnamed Attachment"}</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -296,12 +296,9 @@ class MessageItem extends React.Component
|
|||
|
||||
return otherAttachments.concat(imageAttachments)
|
||||
|
||||
# We ignore files with no name because they're actually mime-parts of the
|
||||
# message being served by the API as files.
|
||||
_isRealFile: (file) ->
|
||||
hasName = file.filename and file.filename.length > 0
|
||||
hasCIDInBody = file.contentId? and @props.message.body?.indexOf(file.contentId) > 0
|
||||
return hasName and not hasCIDInBody
|
||||
return not hasCIDInBody
|
||||
|
||||
_isForwardedMessage: =>
|
||||
Utils.isForwardedMessage(@props.message)
|
||||
|
|
|
@ -53,11 +53,10 @@ file_cid_but_not_referenced_or_image = new File
|
|||
contentId: 'file_cid_but_not_referenced_or_image'
|
||||
contentType: 'text/plain'
|
||||
size: 300
|
||||
file_actually_a_mime_part = new File
|
||||
id: 'file_actually_a_mime_part'
|
||||
contentId: 'file_actually_a_mime_part'
|
||||
contentType: 'text/html'
|
||||
size: 300
|
||||
file_without_filename = new File
|
||||
id: 'file_without_filename'
|
||||
contentType: 'image/png'
|
||||
size: 10
|
||||
|
||||
download =
|
||||
fileId: 'file_1_id'
|
||||
|
@ -178,7 +177,7 @@ describe "MessageItem", ->
|
|||
file_inline,
|
||||
file_inline_downloading,
|
||||
file_inline_not_downloaded,
|
||||
file_actually_a_mime_part
|
||||
file_without_filename
|
||||
]
|
||||
@message.body = """
|
||||
<img alt=\"A\" src=\"cid:#{file_inline.contentId}\"/>
|
||||
|
@ -198,17 +197,12 @@ describe "MessageItem", ->
|
|||
|
||||
it "should list attachments that are not mentioned in the body via cid", ->
|
||||
attachments = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: 'Attachment'})
|
||||
expect(attachments.length).toEqual(4)
|
||||
expect(attachments.length).toEqual(5)
|
||||
expect(attachments[0].props.exposedProps.file).toBe(file)
|
||||
expect(attachments[1].props.exposedProps.file).toBe(file_not_downloaded)
|
||||
expect(attachments[2].props.exposedProps.file).toBe(file_cid_but_not_referenced)
|
||||
expect(attachments[3].props.exposedProps.file).toBe(file_cid_but_not_referenced_or_image)
|
||||
|
||||
it "should list attachments without a filename", ->
|
||||
attachments = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: 'Attachment'})
|
||||
for attachment in attachments
|
||||
expect(attachment.props.exposedProps.file).not.toBe(file_actually_a_mime_part)
|
||||
|
||||
it "should provide file download state to each InjectedComponent", ->
|
||||
attachments = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: 'Attachment'})
|
||||
expect(attachments[0].props.exposedProps.download).toBe(download)
|
||||
|
@ -218,7 +212,7 @@ describe "MessageItem", ->
|
|||
@message.body = ""
|
||||
@createComponent()
|
||||
attachments = ReactTestUtils.scryRenderedComponentsWithTypeAndProps(@component, InjectedComponent, matching: {role: 'Attachment'})
|
||||
expect(attachments.length).toEqual(7)
|
||||
expect(attachments.length).toEqual(8)
|
||||
|
||||
describe "inline", ->
|
||||
it "should never leave src=cid:// in the message body", ->
|
||||
|
|
Loading…
Reference in a new issue