mirror of
https://github.com/axllent/mailpit.git
synced 2024-12-28 23:06:43 +02:00
UI: cater for messages without From email address
This commit is contained in:
parent
3bbc122869
commit
7fd73a6fdb
@ -80,7 +80,8 @@ export default {
|
||||
<th>From</th>
|
||||
<td>
|
||||
<span v-if="message.From">
|
||||
{{ message.From.Name + " <" + message.From.Address +">" }}
|
||||
<span v-if="message.From.Name">{{ message.From.Name }}</span>
|
||||
<span v-if="message.From.Address"><{{ message.From.Address }}></span>
|
||||
</span>
|
||||
<span v-else>
|
||||
[ Unknown ]
|
||||
|
@ -185,6 +185,8 @@ func Store(mailbox string, b []byte) (string, error) {
|
||||
fromData := addressToSlice(env, "From")
|
||||
if len(fromData) > 0 {
|
||||
from = fromData[0]
|
||||
} else if env.GetHeader("From") != "" {
|
||||
from = &mail.Address{Name: env.GetHeader("From")}
|
||||
}
|
||||
|
||||
obj := CloverStore{
|
||||
@ -311,7 +313,7 @@ func List(mailbox string, start, limit int) ([]data.Summary, error) {
|
||||
|
||||
// Search returns a summary of items mathing a search. It searched the SearchText field.
|
||||
func Search(mailbox, search string, start, limit int) ([]data.Summary, error) {
|
||||
sq := fmt.Sprintf("(?i)%s", regexp.QuoteMeta(search))
|
||||
sq := fmt.Sprintf("(?i)%s", cleanString(regexp.QuoteMeta(search)))
|
||||
q, err := db.FindAll(clover.NewQuery(mailbox).
|
||||
Skip(start).
|
||||
Limit(limit).
|
||||
@ -393,6 +395,8 @@ func GetMessage(mailbox, id string) (*data.Message, error) {
|
||||
fromData := addressToSlice(env, "From")
|
||||
if len(fromData) > 0 {
|
||||
from = fromData[0]
|
||||
} else if env.GetHeader("From") != "" {
|
||||
from = &mail.Address{Name: env.GetHeader("From")}
|
||||
}
|
||||
|
||||
date, err := env.Date()
|
||||
|
@ -42,17 +42,20 @@ func createSearchText(env *enmime.Envelope) string {
|
||||
b.WriteString(a.FileName + " ")
|
||||
}
|
||||
|
||||
d := b.String()
|
||||
|
||||
// remove/replace new lines
|
||||
re := regexp.MustCompile(`(\r?\n|\t|>|<|"|:|\,|;)`)
|
||||
d = re.ReplaceAllString(d, " ")
|
||||
// remove duplicate whitespace and trim
|
||||
d = strings.ToLower(strings.Join(strings.Fields(strings.TrimSpace(d)), " "))
|
||||
d := cleanString(b.String())
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
// cleanString removed unwanted characters from stored search text and search queries
|
||||
func cleanString(str string) string {
|
||||
// remove/replace new lines
|
||||
re := regexp.MustCompile(`(\r?\n|\t|>|<|"|:|\,|;)`)
|
||||
str = re.ReplaceAllString(str, " ")
|
||||
// remove duplicate whitespace and trim
|
||||
return strings.ToLower(strings.Join(strings.Fields(strings.TrimSpace(str)), " "))
|
||||
}
|
||||
|
||||
// Auto-prune runs every 5 minutes to automatically delete oldest messages
|
||||
// if total is greater than the threshold
|
||||
func pruneCron() {
|
||||
|
Loading…
Reference in New Issue
Block a user