mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-27 00:41:24 +02:00
UI: Cater for messages without From email address
This commit is contained in:
@ -80,7 +80,8 @@ export default {
|
|||||||
<th>From</th>
|
<th>From</th>
|
||||||
<td>
|
<td>
|
||||||
<span v-if="message.From">
|
<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>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
[ Unknown ]
|
[ Unknown ]
|
||||||
|
@ -185,6 +185,8 @@ func Store(mailbox string, b []byte) (string, error) {
|
|||||||
fromData := addressToSlice(env, "From")
|
fromData := addressToSlice(env, "From")
|
||||||
if len(fromData) > 0 {
|
if len(fromData) > 0 {
|
||||||
from = fromData[0]
|
from = fromData[0]
|
||||||
|
} else if env.GetHeader("From") != "" {
|
||||||
|
from = &mail.Address{Name: env.GetHeader("From")}
|
||||||
}
|
}
|
||||||
|
|
||||||
obj := CloverStore{
|
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.
|
// 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) {
|
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).
|
q, err := db.FindAll(clover.NewQuery(mailbox).
|
||||||
Skip(start).
|
Skip(start).
|
||||||
Limit(limit).
|
Limit(limit).
|
||||||
@ -393,6 +395,8 @@ func GetMessage(mailbox, id string) (*data.Message, error) {
|
|||||||
fromData := addressToSlice(env, "From")
|
fromData := addressToSlice(env, "From")
|
||||||
if len(fromData) > 0 {
|
if len(fromData) > 0 {
|
||||||
from = fromData[0]
|
from = fromData[0]
|
||||||
|
} else if env.GetHeader("From") != "" {
|
||||||
|
from = &mail.Address{Name: env.GetHeader("From")}
|
||||||
}
|
}
|
||||||
|
|
||||||
date, err := env.Date()
|
date, err := env.Date()
|
||||||
|
@ -42,17 +42,20 @@ func createSearchText(env *enmime.Envelope) string {
|
|||||||
b.WriteString(a.FileName + " ")
|
b.WriteString(a.FileName + " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
d := b.String()
|
d := cleanString(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)), " "))
|
|
||||||
|
|
||||||
return d
|
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
|
// Auto-prune runs every 5 minutes to automatically delete oldest messages
|
||||||
// if total is greater than the threshold
|
// if total is greater than the threshold
|
||||||
func pruneCron() {
|
func pruneCron() {
|
||||||
|
Reference in New Issue
Block a user