mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-25 00:37:17 +02:00
Chore: Allow setting of multiple message tags via plus addresses (#253)
This commit is contained in:
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
addressPlusRe = regexp.MustCompile(`^(.*){1,}\+(.*)@`)
|
addressPlusRe = regexp.MustCompile(`(?U)^(.*){1,}\+(.*)@`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetMessageTags will set the tags for a given database ID
|
// SetMessageTags will set the tags for a given database ID
|
||||||
@ -246,25 +246,25 @@ func (d DBMailSummary) tagsFromPlusAddresses() string {
|
|||||||
tags := []string{}
|
tags := []string{}
|
||||||
for _, c := range d.To {
|
for _, c := range d.To {
|
||||||
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
||||||
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
|
if len(matches) == 1 {
|
||||||
tags = append(tags, matches[0][2])
|
tags = append(tags, strings.Split(matches[0][2], "+")...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, c := range d.Cc {
|
for _, c := range d.Cc {
|
||||||
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
||||||
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
|
if len(matches) == 1 {
|
||||||
tags = append(tags, matches[0][2])
|
tags = append(tags, strings.Split(matches[0][2], "+")...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, c := range d.Bcc {
|
for _, c := range d.Bcc {
|
||||||
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
matches := addressPlusRe.FindAllStringSubmatch(c.String(), 1)
|
||||||
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
|
if len(matches) == 1 {
|
||||||
tags = append(tags, matches[0][2])
|
tags = append(tags, strings.Split(matches[0][2], "+")...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matches := addressPlusRe.FindAllStringSubmatch(d.From.String(), 1)
|
matches := addressPlusRe.FindAllStringSubmatch(d.From.String(), 1)
|
||||||
if len(matches) == 1 && config.ValidTagRegexp.MatchString(matches[0][2]) {
|
if len(matches) == 1 {
|
||||||
tags = append(tags, matches[0][2])
|
tags = append(tags, strings.Split(matches[0][2], "+")...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(tags, ",")
|
return strings.Join(tags, ",")
|
||||||
|
Reference in New Issue
Block a user