Skip to content

Commit

Permalink
chore: fixed Discord links when there is no explorer set (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored Oct 13, 2024
1 parent d3a213e commit 6be86bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
26 changes: 17 additions & 9 deletions pkg/templates/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,25 @@ func (m *DiscordTemplateManager) SerializeDate(date time.Time) string {
return date.Format(time.RFC822)
}

func (m *DiscordTemplateManager) GetValidatorLink(validatorLink types.Link) htmlTemplate.HTML {
if validatorLink.Href == "" {
return htmlTemplate.HTML(validatorLink.Text)
}

return htmlTemplate.HTML(fmt.Sprintf(
"%s (%s)",
validatorLink.Text,
m.SerializeLink(types.Link{
Href: validatorLink.Href,
Text: "link",
}),
))
}

func (m *DiscordTemplateManager) SerializeEvent(event types.RenderEventItem) string {
renderData := types.ReportEventRenderData{
Notifiers: m.SerializeNotifiers(event.Notifiers),
ValidatorLink: fmt.Sprintf(
"%s (%s)",
event.ValidatorLink.Text,
m.SerializeLink(types.Link{
Href: event.ValidatorLink.Href,
Text: "link",
}),
),
Notifiers: m.SerializeNotifiers(event.Notifiers),
ValidatorLink: m.GetValidatorLink(event.ValidatorLink),
}

switch entry := event.Event.(type) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/types/report.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package types

import (
htmlTemplate "html/template"
"main/pkg/constants"
)

type ReportEventRenderData struct {
Notifiers string
ValidatorLink any
ValidatorLink htmlTemplate.HTML
TimeToJail string
}

Expand Down

0 comments on commit 6be86bc

Please sign in to comment.