mirror of
https://github.com/axllent/mailpit.git
synced 2025-07-13 01:20:22 +02:00
Bugfix: Return empty arrays rather than null for message To, CC, BCC, Inlines & Attachments
Bugfix: Return empty arrays rather than null for message To, CC, BCC, Inlines & Attachments
This commit is contained in:
@ -26,8 +26,8 @@ Returns a JSON summary of the message and attachments.
|
|||||||
"Address": "jane@example.com"
|
"Address": "jane@example.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Cc": null,
|
"Cc": [],
|
||||||
"Bcc": null,
|
"Bcc": [],
|
||||||
"Subject": "Message subject",
|
"Subject": "Message subject",
|
||||||
"Date": "2016-09-07T16:46:00+13:00",
|
"Date": "2016-09-07T16:46:00+13:00",
|
||||||
"Text": "Plain text MIME part of the email",
|
"Text": "Plain text MIME part of the email",
|
||||||
@ -57,7 +57,7 @@ Returns a JSON summary of the message and attachments.
|
|||||||
|
|
||||||
- `Read` - always true (message marked read on open)
|
- `Read` - always true (message marked read on open)
|
||||||
- `From` - Name & Address, or null
|
- `From` - Name & Address, or null
|
||||||
- `To`, `CC`, `BCC` - Array of Names & Address, or null
|
- `To`, `CC`, `BCC` - Array of Names & Address
|
||||||
- `Date` - Parsed email local date & time from headers
|
- `Date` - Parsed email local date & time from headers
|
||||||
- `Size` - Total size of raw email
|
- `Size` - Total size of raw email
|
||||||
- `Inline`, `Attachments` - Array of attachments and inline images.
|
- `Inline`, `Attachments` - Array of attachments and inline images.
|
||||||
|
@ -51,7 +51,7 @@ List messages in the mailbox. Messages are returned in the order of latest recei
|
|||||||
"Address": "accounts@example.com"
|
"Address": "accounts@example.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Bcc": null,
|
"Bcc": [],
|
||||||
"Subject": "Message subject",
|
"Subject": "Message subject",
|
||||||
"Created": "2022-10-03T21:35:32.228605299+13:00",
|
"Created": "2022-10-03T21:35:32.228605299+13:00",
|
||||||
"Size": 6144,
|
"Size": 6144,
|
||||||
@ -70,7 +70,7 @@ List messages in the mailbox. Messages are returned in the order of latest recei
|
|||||||
- `start` - The offset (default `0`) for pagination
|
- `start` - The offset (default `0`) for pagination
|
||||||
- `Read` - The read/unread status of the message
|
- `Read` - The read/unread status of the message
|
||||||
- `From` - Name & Address, or null if none
|
- `From` - Name & Address, or null if none
|
||||||
- `To`, `CC`, `BCC` - Array of Names & Address, or null if none
|
- `To`, `CC`, `BCC` - Array of Names & Address
|
||||||
- `Created` - Local date & time the message was received
|
- `Created` - Local date & time the message was received
|
||||||
- `Size` - Total size of raw email in bytes
|
- `Size` - Total size of raw email in bytes
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Matching messages are returned in the order of latest received to oldest.
|
|||||||
"Address": "accounts@example.com"
|
"Address": "accounts@example.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Bcc": null,
|
"Bcc": [],
|
||||||
"Subject": "Test email",
|
"Subject": "Test email",
|
||||||
"Created": "2022-10-03T21:35:32.228605299+13:00",
|
"Created": "2022-10-03T21:35:32.228605299+13:00",
|
||||||
"Size": 6144,
|
"Size": 6144,
|
||||||
@ -65,5 +65,5 @@ Matching messages are returned in the order of latest received to oldest.
|
|||||||
- `count` - Number of messages returned in request
|
- `count` - Number of messages returned in request
|
||||||
- `start` - The offset (default `0`) for pagination
|
- `start` - The offset (default `0`) for pagination
|
||||||
- `From` - Singular Name & Address, or null if none
|
- `From` - Singular Name & Address, or null if none
|
||||||
- `To`, `CC`, `BCC` - Array of Name & Address, or null if none
|
- `To`, `CC`, `BCC` - Array of Name & Address
|
||||||
- `Size` - Total size of raw email in bytes
|
- `Size` - Total size of raw email in bytes
|
||||||
|
@ -128,29 +128,27 @@ export default {
|
|||||||
<tr class="small">
|
<tr class="small">
|
||||||
<th>To</th>
|
<th>To</th>
|
||||||
<td class="privacy">
|
<td class="privacy">
|
||||||
<span v-if="message.To" v-for="(t, i) in message.To">
|
<span v-if="message.To && message.To.length" v-for="(t, i) in message.To">
|
||||||
<template v-if="i > 0">, </template>
|
<template v-if="i > 0">, </template>
|
||||||
<span class="text-nowrap">{{ t.Name + " <" + t.Address + ">" }}</span>
|
<span class="text-nowrap">{{ t.Name + " <" + t.Address + ">" }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else>Undisclosed recipients</span>
|
<span v-else>Undisclosed recipients</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="message.Cc" class="small">
|
<tr v-if="message.Cc && message.Cc.length" class="small">
|
||||||
<th>CC</th>
|
<th>CC</th>
|
||||||
<td class="privacy">
|
<td class="privacy">
|
||||||
<span v-for="(t, i) in message.Cc">
|
<span v-for="(t, i) in message.Cc">
|
||||||
<template v-if="i > 0">,</template>
|
<template v-if="i > 0">,</template>
|
||||||
{{ t.Name + " <" + t.Address +">" }}
|
{{ t.Name + " <" + t.Address + ">" }} </span>
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="message.Bcc" class="small">
|
<tr v-if="message.Bcc && message.Bcc.length" class="small">
|
||||||
<th>CC</th>
|
<th>BCC</th>
|
||||||
<td class="privacy">
|
<td class="privacy">
|
||||||
<span v-for="(t, i) in message.Bcc">
|
<span v-for="(t, i) in message.Bcc">
|
||||||
<template v-if="i > 0">,</template>
|
<template v-if="i > 0">,</template>
|
||||||
{{ t.Name + " <" + t.Address +">" }}
|
{{ t.Name + " <" + t.Address + ">" }} </span>
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -386,6 +386,8 @@ func GetMessage(id string) (*Message, error) {
|
|||||||
var re = regexp.MustCompile(`(?U)<base .*>`)
|
var re = regexp.MustCompile(`(?U)<base .*>`)
|
||||||
html := re.ReplaceAllString(env.HTML, "")
|
html := re.ReplaceAllString(env.HTML, "")
|
||||||
obj.HTML = html
|
obj.HTML = html
|
||||||
|
obj.Inline = []Attachment{}
|
||||||
|
obj.Attachments = []Attachment{}
|
||||||
|
|
||||||
for _, i := range env.Inlines {
|
for _, i := range env.Inlines {
|
||||||
if i.FileName != "" || i.ContentID != "" {
|
if i.FileName != "" || i.ContentID != "" {
|
||||||
|
@ -19,7 +19,10 @@ import (
|
|||||||
|
|
||||||
// Return a header field as a []*mail.Address, or "null" is not found/empty
|
// Return a header field as a []*mail.Address, or "null" is not found/empty
|
||||||
func addressToSlice(env *enmime.Envelope, key string) []*mail.Address {
|
func addressToSlice(env *enmime.Envelope, key string) []*mail.Address {
|
||||||
data, _ := env.AddressList(key)
|
data, err := env.AddressList(key)
|
||||||
|
if err != nil {
|
||||||
|
return []*mail.Address{}
|
||||||
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user