models

package
v1.11.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	ID int `gorm:"primaryKey;not null" json:"-"`
	// User is UUID of the user that triggered this event, or an empty string if the event
	// cannot be tied to a specific user, in which case we will assume it was the system
	// user.
	User JsonNullString `gorm:"type:uuid" json:"user"`
	// Server is the UUID of the server this event is associated with.
	Server string `gorm:"type:uuid;not null" json:"server"`
	// Event is a string that describes what occurred, and is used by the Panel instance to
	// properly associate this event in the activity logs.
	Event Event `gorm:"index;not null" json:"event"`
	// Metadata is either a null value, string, or a JSON blob with additional event specific
	// metadata that can be provided.
	Metadata ActivityMeta `gorm:"serializer:json" json:"metadata"`
	// IP is the IP address that triggered this event, or an empty string if it cannot be
	// determined properly. This should be the connecting user's IP address, and not the
	// internal system IP.
	IP        string    `gorm:"not null" json:"ip"`
	Timestamp time.Time `gorm:"not null" json:"timestamp"`
}

Activity defines an activity log event for a server entity performed by a user. This is used for tracking commands, power actions, and SFTP events so that they can be reconciled and sent back to the Panel instance to be displayed to the user.

func (*Activity) BeforeCreate

func (a *Activity) BeforeCreate(_ *gorm.DB) error

BeforeCreate executes before we create any activity entry to ensure the IP address is trimmed down to remove any extraneous data, and the timestamp is set to the current system time and then stored as UTC.

func (Activity) SetUser

func (a Activity) SetUser(u string) *Activity

SetUser sets the current user that performed the action. If an empty string is provided it is cast into a null value when stored.

type ActivityMeta

type ActivityMeta map[string]interface{}

type Event

type Event string

type JsonNullString

type JsonNullString struct {
	sql.NullString
}

func (JsonNullString) MarshalJSON

func (v JsonNullString) MarshalJSON() ([]byte, error)

func (*JsonNullString) UnmarshalJSON

func (v *JsonNullString) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL