Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c467e489
Commit
c467e489
authored
Dec 15, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(notifications): removes html escaping subject
closes #6905
parent
597ebb11
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
15 deletions
+23
-15
pkg/models/notifications.go
+1
-0
pkg/services/alerting/notifiers/email.go
+1
-0
pkg/services/notifications/mailer.go
+20
-15
pkg/services/notifications/notifications.go
+1
-0
No files found.
pkg/models/notifications.go
View file @
c467e489
...
...
@@ -7,6 +7,7 @@ var ErrInvalidEmailCode = errors.New("Invalid or expired email code")
type
SendEmailCommand
struct
{
To
[]
string
Template
string
Subject
string
Data
map
[
string
]
interface
{}
Info
string
EmbededFiles
[]
string
...
...
pkg/services/alerting/notifiers/email.go
View file @
c467e489
...
...
@@ -57,6 +57,7 @@ func (this *EmailNotifier) Notify(evalContext *alerting.EvalContext) error {
cmd
:=
&
m
.
SendEmailCommandSync
{
SendEmailCommand
:
m
.
SendEmailCommand
{
Subject
:
evalContext
.
GetNotificationTitle
(),
Data
:
map
[
string
]
interface
{}{
"Title"
:
evalContext
.
GetNotificationTitle
(),
"State"
:
evalContext
.
Rule
.
State
,
...
...
pkg/services/notifications/mailer.go
View file @
c467e489
...
...
@@ -111,7 +111,6 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
var
buffer
bytes
.
Buffer
var
err
error
var
subjectText
interface
{}
data
:=
cmd
.
Data
if
data
==
nil
{
...
...
@@ -124,28 +123,34 @@ func buildEmailMessage(cmd *m.SendEmailCommand) (*Message, error) {
return
nil
,
err
}
subjectData
:=
data
[
"Subject"
]
.
(
map
[
string
]
interface
{})
subjectText
,
hasSubject
:=
subjectData
[
"value"
]
subject
:=
cmd
.
Subject
if
cmd
.
Subject
==
""
{
var
subjectText
interface
{}
subjectData
:=
data
[
"Subject"
]
.
(
map
[
string
]
interface
{})
subjectText
,
hasSubject
:=
subjectData
[
"value"
]
if
!
hasSubject
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Missing subject in Template %s"
,
cmd
.
Template
))
}
if
!
hasSubject
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"Missing subject in Template %s"
,
cmd
.
Template
))
}
subjectTmpl
,
err
:=
template
.
New
(
"subject"
)
.
Parse
(
subjectText
.
(
string
))
if
err
!=
nil
{
return
nil
,
err
}
subjectTmpl
,
err
:=
template
.
New
(
"subject"
)
.
Parse
(
subjectText
.
(
string
))
if
err
!=
nil
{
return
nil
,
err
}
var
subjectBuffer
bytes
.
Buffer
err
=
subjectTmpl
.
ExecuteTemplate
(
&
subjectBuffer
,
"subject"
,
data
)
if
err
!=
nil
{
return
nil
,
err
var
subjectBuffer
bytes
.
Buffer
err
=
subjectTmpl
.
ExecuteTemplate
(
&
subjectBuffer
,
"subject"
,
data
)
if
err
!=
nil
{
return
nil
,
err
}
subject
=
subjectBuffer
.
String
()
}
return
&
Message
{
To
:
cmd
.
To
,
From
:
setting
.
Smtp
.
FromAddress
,
Subject
:
subject
Buffer
.
String
()
,
Subject
:
subject
,
Body
:
buffer
.
String
(),
EmbededFiles
:
cmd
.
EmbededFiles
,
},
nil
...
...
pkg/services/notifications/notifications.go
View file @
c467e489
...
...
@@ -80,6 +80,7 @@ func sendEmailCommandHandlerSync(ctx context.Context, cmd *m.SendEmailCommandSyn
Template
:
cmd
.
Template
,
To
:
cmd
.
To
,
EmbededFiles
:
cmd
.
EmbededFiles
,
Subject
:
cmd
.
Subject
,
})
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment