mirror of
https://github.com/pushbits/server.git
synced 2025-05-02 03:36:43 +02:00
rework title coloring
This commit is contained in:
parent
2ff9f5972a
commit
b0efac8b45
3 changed files with 12 additions and 19 deletions
|
@ -58,5 +58,5 @@ crypto:
|
|||
keylength: 32
|
||||
|
||||
formatting:
|
||||
# Whether to use colored titles based on the message priority.
|
||||
# Whether to use colored titles based on the message priority (<0: grey, 0-3: default, 4-10: yellow, 10-20: orange, >20: red).
|
||||
coloredtitle: false
|
||||
|
|
|
@ -30,7 +30,6 @@ type NotificationHandler struct {
|
|||
// CreateNotification is used to create a new notification for a user.
|
||||
func (h *NotificationHandler) CreateNotification(ctx *gin.Context) {
|
||||
var notification model.Notification
|
||||
notification.Priority = 8 // set a default value
|
||||
|
||||
if err := ctx.Bind(¬ification); err != nil {
|
||||
return
|
||||
|
|
|
@ -46,7 +46,6 @@ func (d *Dispatcher) getFormattedMessage(n *model.Notification) string {
|
|||
|
||||
if optionsDisplayRaw, ok := n.Extras["client::display"]; ok {
|
||||
optionsDisplay, ok := optionsDisplayRaw.(map[string]interface{})
|
||||
log.Printf("%s", optionsDisplay)
|
||||
|
||||
if ok {
|
||||
if contentTypeRaw, ok := optionsDisplay["contentType"]; ok {
|
||||
|
@ -69,23 +68,18 @@ func (d *Dispatcher) getFormattedMessage(n *model.Notification) string {
|
|||
|
||||
// Maps priorities to hex colors
|
||||
func (d *Dispatcher) priorityToColor(prio int) string {
|
||||
switch prio {
|
||||
case 0: // emergency - dark red
|
||||
return "#cc0000"
|
||||
case 1: // alert - red
|
||||
return "#ed1f11"
|
||||
case 2: // critical - dark orange
|
||||
return "#ed6d11"
|
||||
case 3: // error - orange
|
||||
return "#edab11"
|
||||
case 4: // warning - yellow
|
||||
return "#edd711"
|
||||
case 5: // notice - green
|
||||
return "#70ed11"
|
||||
case 6: // informational - blue
|
||||
return "#118eed"
|
||||
case 7: // debug - grey
|
||||
log.Printf("Prio: %d", prio)
|
||||
switch {
|
||||
case prio < 0:
|
||||
return "#828282"
|
||||
case prio <= 3: // info - default color
|
||||
return ""
|
||||
case prio <= 10: // low - yellow
|
||||
return "#edd711"
|
||||
case prio <= 20: // mid - orange
|
||||
return "#ed6d11"
|
||||
case prio > 20: // high - red
|
||||
return "#ed1f11"
|
||||
}
|
||||
|
||||
return ""
|
||||
|
|
Loading…
Add table
Reference in a new issue