add dat base

This commit is contained in:
2022-12-31 17:17:10 +01:00
parent 6fb82df153
commit 4ff22d7d63
27 changed files with 1337 additions and 36 deletions
+21
View File
@@ -0,0 +1,21 @@
package events
import "fmt"
type AliasAdded struct {
ID string
Alias string
}
func (e AliasAdded) EventDescription() string {
return fmt.Sprintf("AliasAdded(id=%s, alias=%s)", e.ID, e.Alias)
}
type AliasRemoved struct {
ID string
Alias string
}
func (e AliasRemoved) EventDescription() string {
return fmt.Sprintf("AliasRemoved(id=%s, alias=%s)", e.ID, e.Alias)
}
+34
View File
@@ -0,0 +1,34 @@
package events
import (
"fmt"
lucifer3 "git.aiterp.net/lucifer3/server"
"github.com/google/uuid"
)
type AssignmentCreated struct {
ID uuid.UUID
Match string
Effect lucifer3.Effect
}
func (e AssignmentCreated) EventDescription() string {
return fmt.Sprintf("AssignmentCreated(id=%s, match=%s, effect=%s)", e.ID, e.Match, e.Effect.EffectDescription())
}
type AssignmentRemoved struct {
ID uuid.UUID
}
func (e AssignmentRemoved) EventDescription() string {
return fmt.Sprintf("AssignmentRemoved(id=%s)", e.ID)
}
type DeviceAssigned struct {
DeviceID string `json:"deviceId"`
AssignmentID *uuid.UUID `json:"assignmentId"`
}
func (e DeviceAssigned) EventDescription() string {
return fmt.Sprintf("DeviceAssigned(device=%s, %s)", e.DeviceID, e.AssignmentID)
}
+18 -3
View File
@@ -4,6 +4,8 @@ import (
"fmt"
"git.aiterp.net/lucifer3/server/device"
"git.aiterp.net/lucifer3/server/internal/color"
"git.aiterp.net/lucifer3/server/internal/formattools"
"os"
)
type DeviceConnected struct {
@@ -24,7 +26,7 @@ func (e DeviceDisconnected) EventDescription() string {
}
type HardwareState struct {
ID string `json:"internalId"`
ID string `json:"id"`
InternalName string `json:"internalName"`
SupportFlags device.SupportFlags `json:"supportFlags"`
ColorFlags device.ColorFlags `json:"colorFlags"`
@@ -34,6 +36,7 @@ type HardwareState struct {
State device.State `json:"state"`
BatteryPercentage *int `json:"batteryPercentage"`
Unreachable bool `json:"unreachable"`
Stale bool `json:"stale,omitempty"`
}
func (e HardwareState) EventDescription() string {
@@ -53,6 +56,7 @@ type HardwareMetadata struct {
Icon string `json:"icon,omitempty"`
SerialNumber string `json:"serialNumber,omitempty"`
FirmwareVersion string `json:"firmwareVersion,omitempty"`
Stale bool `json:"stale,omitempty"`
}
func (e HardwareMetadata) EventDescription() string {
@@ -85,6 +89,17 @@ type DeviceAccepted struct {
}
func (e DeviceAccepted) EventDescription() string {
// TODO: Use formattools.Asterisks
return fmt.Sprintf("DeviceAccepted(id:%s, apiKey:%s)", e.ID, e.APIKey)
if os.Getenv("DEV_SHOW_API_KEYS") == "true" {
return fmt.Sprintf("DeviceAccepted(id:%s, apiKey:%s)", e.ID, e.APIKey)
} else {
return fmt.Sprintf("DeviceAccepted(id:%s, apiKey:%s)", e.ID, formattools.Asterisks(e.APIKey))
}
}
type DeviceForgotten struct {
ID string `json:"id"`
}
func (e DeviceForgotten) EventDescription() string {
return fmt.Sprintf("DeviceForgotten(id:%s)", e.ID)
}
+1 -1
View File
@@ -3,7 +3,7 @@ package events
import "fmt"
type Log struct {
ID string `json:"id"`
ID string `json:"id,omitempty"`
Level string `json:"level"`
Code string `json:"code"`
Message string `json:"message"`
+7
View File
@@ -0,0 +1,7 @@
package events
type Started struct{}
func (Started) EventDescription() string {
return "Started()"
}