Skip to content

Commit

Permalink
Merge pull request #44 from cseeger-epages/issue/43
Browse files Browse the repository at this point in the history
added BodyPrefix/Suffix
  • Loading branch information
cseeger-epages authored Apr 15, 2020
2 parents a0eb288 + b6e803a commit d99092e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions conf/mail2most.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
HideFromEmail = false
# allow posting mail attachments into mattermost
MailAttachments = true
# BodyPrefix adds a prefix to the message body e.g:
# BodyPrefix = "**This content was forwarded by Mail2Most and might be reformatted**"
BodyPrefix = ""
# BodySuffix adds a suffix to the message body e.g:
# BodySuffix = "**Disclaimer: This content was forwarded by Mail2Most and might be reformatted**"
BodySuffix = ""

# The DefaultProfile.Filter defines a default filter
# if your Profile has no defined filter this information will be used
Expand Down Expand Up @@ -134,6 +140,12 @@
HideFromEmail = false
# allow posting mail attachments into mattermost
MailAttachments = true
# BodyPrefix adds a prefix to the message body e.g:
# BodyPrefix = "**This content was forwarded by Mail2Most and might be reformatted**"
BodyPrefix = ""
# BodySuffix adds a suffix to the message body e.g:
# BodySuffix = "**Disclaimer: This content was forwarded by Mail2Most and might be reformatted**"
BodySuffix = ""

#[Profile.Filter] contains all filters that are applied to your mails and overwrites the default
[Profile.Filter]
Expand Down Expand Up @@ -186,6 +198,8 @@
Broadcast = []
SubjectOnly = false
BodyOnly = false
BodyPrefix = ""
BodySuffix = ""

# if you dont add for example [Profile.Filter] the filters defined in the [DefaultProfile.Filter] section are used

Expand Down
1 change: 1 addition & 0 deletions lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type mattermost struct {
HideFrom bool
HideFromEmail bool
MailAttachments bool
BodyPrefix, BodySuffix string
}

func parseConfig(fileName string, conf *config) error {
Expand Down
9 changes: 9 additions & 0 deletions lib/mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (m Mail2Most) PostMattermost(profile int, mail Mail) error {

// check if body is base64 encoded
var body string

bb, err := base64.StdEncoding.DecodeString(mail.Body)
if err != nil {
body = mail.Body
Expand Down Expand Up @@ -90,6 +91,14 @@ func (m Mail2Most) PostMattermost(profile int, mail Mail) error {
return nil
}

if m.Config.Profiles[profile].Mattermost.BodyPrefix != "" {
body = m.Config.Profiles[profile].Mattermost.BodyPrefix + "\n" + body
}

if m.Config.Profiles[profile].Mattermost.BodySuffix != "" {
body = body + "\n" + m.Config.Profiles[profile].Mattermost.BodySuffix
}

msg := ":email: "

if !m.Config.Profiles[profile].Mattermost.HideFrom {
Expand Down

0 comments on commit d99092e

Please sign in to comment.