2023-01-02 15:11:32 +01:00
|
|
|
package activity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-09-04 11:37:39 +02:00
|
|
|
const (
|
|
|
|
SystemInitiator = "sys"
|
|
|
|
)
|
|
|
|
|
2023-01-02 15:11:32 +01:00
|
|
|
// Event represents a network/system activity event.
|
|
|
|
type Event struct {
|
|
|
|
// Timestamp of the event
|
|
|
|
Timestamp time.Time
|
|
|
|
// Activity that was performed during the event
|
|
|
|
Activity Activity
|
|
|
|
// ID of the event (can be empty, meaning that it wasn't yet generated)
|
|
|
|
ID uint64
|
|
|
|
// InitiatorID is the ID of an object that initiated the event (e.g., a user)
|
|
|
|
InitiatorID string
|
2023-09-19 18:08:40 +02:00
|
|
|
// InitiatorEmail is the email address of an object that initiated the event. This will be set on deleted users only
|
|
|
|
InitiatorEmail string
|
2023-01-02 15:11:32 +01:00
|
|
|
// TargetID is the ID of an object that was effected by the event (e.g., a peer)
|
|
|
|
TargetID string
|
|
|
|
// AccountID is the ID of an account where the event happened
|
|
|
|
AccountID string
|
2023-09-19 18:08:40 +02:00
|
|
|
|
2023-01-02 15:11:32 +01:00
|
|
|
// Meta of the event, e.g. deleted peer information like name, IP, etc
|
|
|
|
Meta map[string]any
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the event
|
|
|
|
func (e *Event) Copy() *Event {
|
|
|
|
|
|
|
|
meta := make(map[string]any, len(e.Meta))
|
|
|
|
for key, value := range e.Meta {
|
|
|
|
meta[key] = value
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Event{
|
2023-09-19 18:08:40 +02:00
|
|
|
Timestamp: e.Timestamp,
|
|
|
|
Activity: e.Activity,
|
|
|
|
ID: e.ID,
|
|
|
|
InitiatorID: e.InitiatorID,
|
|
|
|
InitiatorEmail: e.InitiatorEmail,
|
|
|
|
TargetID: e.TargetID,
|
|
|
|
AccountID: e.AccountID,
|
|
|
|
Meta: meta,
|
2023-01-02 15:11:32 +01:00
|
|
|
}
|
|
|
|
}
|