Skip to content

Commit

Permalink
Allow to add activity codes
Browse files Browse the repository at this point in the history
  • Loading branch information
lixmal committed Feb 13, 2024
1 parent 3bb3f10 commit f019182
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions management/server/activity/codes.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package activity

import "maps"

// Activity that triggered an Event
type Activity int

// Code is an activity string representation
type Code struct {
message string
code string
Message string
Code string
}

const (
Expand Down Expand Up @@ -198,15 +200,20 @@ var activityMap = map[Activity]Code{
// StringCode returns a string code of the activity
func (a Activity) StringCode() string {
if code, ok := activityMap[a]; ok {
return code.code
return code.Code
}
return "UNKNOWN_ACTIVITY"
}

// Message returns a string representation of an activity
func (a Activity) Message() string {
if code, ok := activityMap[a]; ok {
return code.message
return code.Message
}
return "UNKNOWN_ACTIVITY"
}

// RegisterActivityMap adds new codes to the activity map
func RegisterActivityMap(codes map[Activity]Code) {
maps.Copy(activityMap, codes)
}

0 comments on commit f019182

Please sign in to comment.