Skip to content
Snippets Groups Projects
models.go 1.52 KiB
package db

import "time"

// User represents a user from the database.
type User struct {
	ID             string `json:"id"`
	Username       string `json:"username"`
	Email          string `json:"email"`
	IsAdmin        bool   `json:"is_admin"`
	IsBlocked      bool   `json:"is_blocked"`
	BucketCapacity int64  `json:"-"`
}

// Object represents an object from the database.
type Object struct {
	Bucket          string     `json:"bucket"`
	Key             string     `json:"key"`
	Directory       string     `json:"dir"`
	Type            int        `json:"type"`
	DestURL         *string    `json:"dest_url"`
	ContentType     *string    `json:"content_type"`
	ContentLength   *int64     `json:"content_length"`
	CreatedAt       time.Time  `json:"created_at"`
	DeletedAt       *time.Time `json:"deleted_at"`
	DeleteReason    *string    `json:"delete_reason"`
	AssociatedUser  *string    `json:"-"`
	MD5HashBytes    []byte     `json:"-"`
	SHA256HashBytes []byte     `json:"-"`

	// Computed fields
	MD5Hash                   *string `json:"md5_hash"`
	SHA256Hash                *string `json:"sha256_hash"`
	AssociatedWithCurrentUser *bool   `json:"associated_with_current_user,omitempty"`
}

// FileBan represents a banned file from the database.
type FileBan struct {
	SHA256HashBytes []byte  `json:"-"`
	DidQuarantine   bool    `json:"did_quarantine"`
	Reason          int     `json:"reason"`
	Description     *string `json:"description"`
	MalwareName     *string `json:"malware_name"`

	// Computed fields
	SHA256Hash *string `json:"sha256_hash"`
}