| 1 | package ntfy |
| 2 | |
| 3 | import ( |
| 4 | "github.com/nicholas-fedor/shoutrrr/pkg/format" |
| 5 | "github.com/nicholas-fedor/shoutrrr/pkg/types" |
| 6 | ) |
| 7 | |
| 8 | type priority int |
| 9 | |
| 10 | type priorityVals struct { |
| 11 | Min priority |
| 12 | Low priority |
| 13 | Default priority |
| 14 | High priority |
| 15 | Max priority |
| 16 | Enum types.EnumFormatter |
| 17 | } |
| 18 | |
| 19 | // Priority levels as constants. |
| 20 | const ( |
| 21 | PriorityMin priority = 1 |
| 22 | PriorityLow priority = 2 |
| 23 | PriorityDefault priority = 3 |
| 24 | PriorityHigh priority = 4 |
| 25 | PriorityMax priority = 5 |
| 26 | ) |
| 27 | |
| 28 | // Priority defines the notification priority levels. |
| 29 | var Priority = &priorityVals{ |
| 30 | Min: PriorityMin, |
| 31 | Low: PriorityLow, |
| 32 | Default: PriorityDefault, |
| 33 | High: PriorityHigh, |
| 34 | Max: PriorityMax, |
| 35 | Enum: format.CreateEnumFormatter( |
| 36 | []string{ |
| 37 | "", |
| 38 | "Min", |
| 39 | "Low", |
| 40 | "Default", |
| 41 | "High", |
| 42 | "Max", |
| 43 | }, map[string]int{ |
| 44 | "1": int(PriorityMin), |
| 45 | "2": int(PriorityLow), |
| 46 | "3": int(PriorityDefault), |
| 47 | "4": int(PriorityHigh), |
| 48 | "5": int(PriorityMax), |
| 49 | "urgent": int(PriorityMax), |
| 50 | }, |
| 51 | ), |
| 52 | } |
| 53 | |
| 54 | func (p priority) String() string { |
| 55 | return Priority.Enum.Print(int(p)) |
| 56 | } |