mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-22 20:17:02 +00:00
message: Include inlines when returning attachments (#398)
Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
@@ -28,7 +28,9 @@ func New(m event.MessageMetadata, e *enmime.Envelope) *Message {
|
||||
|
||||
// Attachments returns the MIME attachments for the message.
|
||||
func (m *Message) Attachments() []*enmime.Part {
|
||||
return m.env.Attachments
|
||||
attachments := append([]*enmime.Part{}, m.env.Inlines...)
|
||||
attachments = append(attachments, m.env.Attachments...)
|
||||
return attachments
|
||||
}
|
||||
|
||||
// Header returns the header map for this message.
|
||||
|
||||
@@ -201,6 +201,10 @@ func TestRestMessage(t *testing.T) {
|
||||
FileName: "favicon.png",
|
||||
ContentType: "image/png",
|
||||
}},
|
||||
Inlines: []*enmime.Part{{
|
||||
FileName: "statement.pdf",
|
||||
ContentType: "application/pdf",
|
||||
}},
|
||||
},
|
||||
)
|
||||
mm.AddMessage("good", msg1)
|
||||
@@ -236,10 +240,14 @@ func TestRestMessage(t *testing.T) {
|
||||
decodedStringEquals(t, result, "header/To/[0]", "fred@fish.com")
|
||||
decodedStringEquals(t, result, "header/To/[1]", "keyword@nsa.gov")
|
||||
decodedStringEquals(t, result, "header/From/[0]", "noreply@inbucket.org")
|
||||
decodedStringEquals(t, result, "attachments/[0]/filename", "favicon.png")
|
||||
decodedStringEquals(t, result, "attachments/[0]/content-type", "image/png")
|
||||
decodedStringEquals(t, result, "attachments/[0]/download-link", "http://localhost/serve/mailbox/good/0001/attach/0/favicon.png")
|
||||
decodedStringEquals(t, result, "attachments/[0]/view-link", "http://localhost/serve/mailbox/good/0001/attach/0/favicon.png")
|
||||
decodedStringEquals(t, result, "attachments/[0]/filename", "statement.pdf")
|
||||
decodedStringEquals(t, result, "attachments/[0]/content-type", "application/pdf")
|
||||
decodedStringEquals(t, result, "attachments/[0]/download-link", "http://localhost/serve/mailbox/good/0001/attach/0/statement.pdf")
|
||||
decodedStringEquals(t, result, "attachments/[0]/view-link", "http://localhost/serve/mailbox/good/0001/attach/0/statement.pdf")
|
||||
decodedStringEquals(t, result, "attachments/[1]/filename", "favicon.png")
|
||||
decodedStringEquals(t, result, "attachments/[1]/content-type", "image/png")
|
||||
decodedStringEquals(t, result, "attachments/[1]/download-link", "http://localhost/serve/mailbox/good/0001/attach/1/favicon.png")
|
||||
decodedStringEquals(t, result, "attachments/[1]/view-link", "http://localhost/serve/mailbox/good/0001/attach/1/favicon.png")
|
||||
|
||||
if t.Failed() {
|
||||
// Wait for handler to finish logging
|
||||
|
||||
Reference in New Issue
Block a user