mirror of
https://github.com/pushbits/server.git
synced 2025-06-15 17:12:04 +02:00
Add misspell, gocritic, and revive
This commit is contained in:
parent
5e640800fe
commit
2c20e42a21
30 changed files with 79 additions and 43 deletions
|
@ -2,6 +2,7 @@ package model
|
|||
|
||||
import "strings"
|
||||
|
||||
// AlertmanagerWebhook is used to pass notifications over webhook pushes.
|
||||
type AlertmanagerWebhook struct {
|
||||
Version string `json:"version"`
|
||||
GroupKey string `json:"groupKey"`
|
||||
|
@ -13,6 +14,7 @@ type AlertmanagerWebhook struct {
|
|||
Alerts []AlertmanagerAlert `json:"alerts"`
|
||||
}
|
||||
|
||||
// AlertmanagerAlert holds information related to a single alert in a notification.
|
||||
type AlertmanagerAlert struct {
|
||||
Labels map[string]string `json:"labels"`
|
||||
Annotations map[string]string `json:"annotations"`
|
||||
|
@ -21,6 +23,7 @@ type AlertmanagerAlert struct {
|
|||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// ToNotification converts an Alertmanager alert into a Notification
|
||||
func (alert *AlertmanagerAlert) ToNotification(titleAnnotation, messageAnnotation string) Notification {
|
||||
title := strings.Builder{}
|
||||
message := strings.Builder{}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Package model contains structs used in the PushBits API and across the application.
|
||||
package model
|
||||
|
||||
import (
|
||||
|
@ -8,7 +9,7 @@ import (
|
|||
// Notification holds information like the message, the title, and the priority of a notification.
|
||||
type Notification struct {
|
||||
ID string `json:"id"`
|
||||
UrlEncodedID string `json:"id_url_encoded"`
|
||||
URLEncodedID string `json:"id_url_encoded"`
|
||||
ApplicationID uint `json:"appid"`
|
||||
Message string `json:"message" form:"message" query:"message" binding:"required"`
|
||||
Title string `json:"title" form:"title" query:"title"`
|
||||
|
@ -20,7 +21,7 @@ type Notification struct {
|
|||
// Sanitize sets explicit defaults for a notification.
|
||||
func (n *Notification) Sanitize(application *Application) {
|
||||
n.ID = ""
|
||||
n.UrlEncodedID = ""
|
||||
n.URLEncodedID = ""
|
||||
n.ApplicationID = application.ID
|
||||
if strings.TrimSpace(n.Title) == "" {
|
||||
n.Title = application.Name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue