Documentation
¶
Index ¶
- Constants
- func CheckPasswordHash(password, hash string) bool
- func CountBackupsByStatus(db *gorm.DB, status BackupStatus) (int64, error)
- func CreateNotification(db *gorm.DB, userID uint, notificationType string, content string, ...) error
- func DeleteVariantsByImageID(db *gorm.DB, imageID uint) error
- func GetBackupStats(db *gorm.DB) (map[BackupStatus]int64, error)
- func GetVariantTypes(db *gorm.DB, imageID uint) ([]string, error)
- func HasVariant(db *gorm.DB, imageID uint, variantType string) bool
- func HashPassword(password string) (string, error)
- func LoadSettings(db *gorm.DB) error
- func SaveSettings(db *gorm.DB, settings *AppSettings) error
- func ToggleLike(db *gorm.DB, userID, imageID uint) error
- type Album
- type AlbumImage
- type AppSettings
- func (s *AppSettings) FromJSON(data []byte) error
- func (s *AppSettings) GetAPIRateLimitPerMinute() int
- func (s *AppSettings) GetJobQueueWorkerCount() int
- func (s *AppSettings) GetS3BackupCheckInterval() int
- func (s *AppSettings) GetS3BackupDelayMinutes() int
- func (s *AppSettings) GetS3RetryInterval() int
- func (s *AppSettings) GetSiteDescription() string
- func (s *AppSettings) GetSiteTitle() string
- func (s *AppSettings) GetUploadRateLimitPerMinute() int
- func (s *AppSettings) GetUploadUserRateLimitPerMinute() int
- func (s *AppSettings) IsDirectUploadEnabled() bool
- func (s *AppSettings) IsImageUploadEnabled() bool
- func (s *AppSettings) IsReplicationChecksumRequired() bool
- func (s *AppSettings) IsS3BackupEnabled() bool
- func (s *AppSettings) IsThumbnailAVIFEnabled() bool
- func (s *AppSettings) IsThumbnailOriginalEnabled() bool
- func (s *AppSettings) IsThumbnailWebPEnabled() bool
- func (s *AppSettings) ToJSON() ([]byte, error)
- func (s *AppSettings) Validate() error
- type BackupProvider
- type BackupStatus
- type Comment
- type DailyStats
- type Image
- type ImageBackup
- func CreateBackupRecord(db *gorm.DB, imageID uint, provider BackupProvider) (*ImageBackup, error)
- func FindBackupByImageAndProvider(db *gorm.DB, imageID uint, provider BackupProvider) (*ImageBackup, error)
- func FindBackupsByStatus(db *gorm.DB, status BackupStatus) ([]ImageBackup, error)
- func FindCompletedBackupsByImageID(db *gorm.DB, imageID uint) ([]ImageBackup, error)
- func FindFailedRetryableBackups(db *gorm.DB) ([]ImageBackup, error)
- func FindPendingBackups(db *gorm.DB) ([]ImageBackup, error)
- func (ib *ImageBackup) BeforeCreate(tx *gorm.DB) error
- func (ib *ImageBackup) IsRetryable() bool
- func (ib *ImageBackup) MarkAsCompleted(db *gorm.DB, bucketName, objectKey string, size int64) error
- func (ib *ImageBackup) MarkAsDeleted(db *gorm.DB, message string) error
- func (ib *ImageBackup) MarkAsFailed(db *gorm.DB, errorMsg string) error
- func (ib *ImageBackup) MarkAsUploading(db *gorm.DB) error
- func (ImageBackup) TableName() string
- type ImageMetadata
- type ImageReport
- type ImageTag
- type ImageVariant
- type JSON
- type Like
- type News
- type Notification
- type Page
- type ProviderAccount
- type Setting
- type StoragePool
- func FindActiveStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindActiveStoragePoolsByTier(db *gorm.DB, tier string) ([]StoragePool, error)
- func FindActiveStoragePoolsByType(db *gorm.DB, storageType string) ([]StoragePool, error)
- func FindAllStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindBackupTargetS3Pool(db *gorm.DB) (*StoragePool, error)
- func FindColdStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindDefaultStoragePool(db *gorm.DB) (*StoragePool, error)
- func FindHighestPriorityS3Pool(db *gorm.DB) (*StoragePool, error)
- func FindHotStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindLocalStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindNFSStoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindS3StoragePools(db *gorm.DB) ([]StoragePool, error)
- func FindStoragePoolByID(db *gorm.DB, id uint) (*StoragePool, error)
- func FindStoragePoolByName(db *gorm.DB, name string) (*StoragePool, error)
- func SelectOptimalPool(db *gorm.DB, fileSize int64) (*StoragePool, error)
- func SelectOptimalPoolForUpload(db *gorm.DB, fileSize int64) (*StoragePool, error)
- func (sp *StoragePool) BeforeCreate(tx *gorm.DB) error
- func (sp *StoragePool) BeforeUpdate(tx *gorm.DB) error
- func (sp *StoragePool) CanAcceptFile(size int64) bool
- func (sp *StoragePool) GetAvailableSize() int64
- func (sp *StoragePool) GetS3AccessKeyID() string
- func (sp *StoragePool) GetS3BucketName() string
- func (sp *StoragePool) GetS3EndpointURL() string
- func (sp *StoragePool) GetS3PathPrefix() string
- func (sp *StoragePool) GetS3Region() string
- func (sp *StoragePool) GetS3SecretAccessKey() string
- func (sp *StoragePool) GetUsagePercentage() float64
- func (sp *StoragePool) HasS3Credentials() bool
- func (sp *StoragePool) IsColdStorage() bool
- func (sp *StoragePool) IsHealthy() bool
- func (sp *StoragePool) IsHotStorage() bool
- func (sp *StoragePool) IsS3Storage() bool
- func (sp *StoragePool) SetS3Configuration(region, bucketName, endpointURL, pathPrefix string)
- func (sp *StoragePool) SetS3Credentials(accessKeyID, secretAccessKey string)
- func (sp *StoragePool) UpdateUsedSize(db *gorm.DB, sizeDelta int64) error
- func (sp *StoragePool) ValidateBasePath() error
- func (sp *StoragePool) ValidateS3Configuration() error
- func (sp *StoragePool) ValidateStorageConfiguration() error
- func (sp *StoragePool) ValidateStorageType() error
- type StoragePoolStats
- type Tag
- type User
- func (u *User) CheckPassword(password string) bool
- func (u *User) ClearEmailChangeRequest()
- func (u *User) GenerateActivationToken() error
- func (u *User) GenerateEmailChangeToken() error
- func (u *User) HasPendingEmailChange() bool
- func (u *User) IsActive() bool
- func (u *User) IsEmailChangeTokenValid(token string) bool
- func (u *User) SetPassword(password string) error
- func (u *User) Validate() error
- type UserSettings
Constants ¶
const ( ReportStatusOpen = "open" ReportStatusResolved = "resolved" ReportStatusDismissed = "dismissed" )
const ( VariantTypeWebP = "webp" VariantTypeAVIF = "avif" VariantTypeThumbnailSmallWebP = "thumbnail_small_webp" VariantTypeThumbnailSmallAVIF = "thumbnail_small_avif" VariantTypeThumbnailSmallOrig = "thumbnail_small_original" VariantTypeThumbnailMediumWebP = "thumbnail_medium_webp" VariantTypeThumbnailMediumAVIF = "thumbnail_medium_avif" VariantTypeThumbnailMediumOrig = "thumbnail_medium_original" VariantTypeOriginal = "original" )
Image variant type constants
const ( StorageTierHot = "hot" // High-performance storage (SSD, fast access) StorageTierWarm = "warm" // Medium performance storage StorageTierCold = "cold" // Archive storage (HDD, slower access) StorageTierArchive = "archive" // Long-term archive (tape, very slow) )
Storage tier constants
const ( StorageTypeLocal = "local" // Local filesystem storage StorageTypeNFS = "nfs" // Network File System storage StorageTypeS3 = "s3" // S3-compatible storage (AWS S3, Backblaze B2, MinIO, etc.) )
Storage type constants
const ( ROLE_USER = "user" ROLE_ADMIN = "admin" STATUS_ACTIVE = "active" STATUS_INACTIVE = "inactive" STATUS_DISABLED = "disabled" )
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash compares the given password with the stored hash.
func CountBackupsByStatus ¶
func CountBackupsByStatus(db *gorm.DB, status BackupStatus) (int64, error)
CountBackupsByStatus returns the count of backups by status
func CreateNotification ¶
func CreateNotification(db *gorm.DB, userID uint, notificationType string, content string, referenceID uint) error
CreateNotification erstellt eine neue Benachrichtigung
func DeleteVariantsByImageID ¶
DeleteVariantsByImageID deletes all variants for a specific image
func GetBackupStats ¶
func GetBackupStats(db *gorm.DB) (map[BackupStatus]int64, error)
GetBackupStats returns statistics about backup status
func GetVariantTypes ¶
GetVariantTypes returns all variant types for an image
func HasVariant ¶
HasVariant checks if a specific variant exists for an image
func HashPassword ¶
func LoadSettings ¶
LoadSettings loads settings from database into memory
func SaveSettings ¶
func SaveSettings(db *gorm.DB, settings *AppSettings) error
SaveSettings saves current settings to database
Types ¶
type Album ¶
type Album struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Title string `gorm:"type:varchar(255);not null" json:"title" validate:"required,min=3,max=255"`
Description string `gorm:"type:text" json:"description"`
CoverImageID uint `json:"cover_image_id"`
IsPublic bool `gorm:"default:false" json:"is_public"`
ViewCount int `gorm:"default:0" json:"view_count"`
Images []Image `gorm:"many2many:album_images;" json:"images,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (*Album) BeforeCreate ¶
BeforeCreate wird vor dem Erstellen eines neuen Datensatzes aufgerufen
func (*Album) IncrementViewCount ¶
IncrementViewCount erhöht den Zähler für Aufrufe
func (*Album) RemoveImage ¶
RemoveImage entfernt ein Bild aus dem Album
type AlbumImage ¶
type AppSettings ¶
type AppSettings struct {
SiteTitle string `json:"site_title" validate:"required,min=1,max=255"`
SiteDescription string `json:"site_description" validate:"max=500"`
ImageUploadEnabled bool `json:"image_upload_enabled"`
DirectUploadEnabled bool `json:"direct_upload_enabled"`
UploadRateLimitPerMinute int `json:"upload_rate_limit_per_minute" validate:"min=0,max=100000"`
UploadUserRateLimitPerMinute int `json:"upload_user_rate_limit_per_minute" validate:"min=0,max=100000"`
// Thumbnail format settings
ThumbnailOriginalEnabled bool `json:"thumbnail_original_enabled"`
ThumbnailWebPEnabled bool `json:"thumbnail_webp_enabled"`
ThumbnailAVIFEnabled bool `json:"thumbnail_avif_enabled"`
// S3 Backup settings
S3BackupEnabled bool `json:"s3_backup_enabled"`
S3BackupDelayMinutes int `json:"s3_backup_delay_minutes" validate:"min=0,max=43200"` // Max 30 days (43200 minutes)
S3BackupCheckInterval int `json:"s3_backup_check_interval" validate:"min=1,max=60"` // How often to check for delayed backups (1-60 minutes)
S3RetryInterval int `json:"s3_retry_interval" validate:"min=1,max=60"` // How often to retry failed backups (1-60 minutes)
JobQueueWorkerCount int `json:"job_queue_worker_count" validate:"min=1,max=20"` // Number of job queue workers (1-20)
// API rate limiting
APIRateLimitPerMinute int `json:"api_rate_limit_per_minute" validate:"min=0,max=100000"` // Global API limiter for /api routes (0 = unlimited)
// Replication/Storage settings
ReplicationRequireChecksum bool `json:"replication_require_checksum"`
// contains filtered or unexported fields
}
AppSettings represents the application settings structure
func GetAppSettings ¶
func GetAppSettings() *AppSettings
GetAppSettings returns the current application settings
func (*AppSettings) FromJSON ¶
func (s *AppSettings) FromJSON(data []byte) error
FromJSON loads settings from JSON
func (*AppSettings) GetAPIRateLimitPerMinute ¶
func (s *AppSettings) GetAPIRateLimitPerMinute() int
GetAPIRateLimitPerMinute returns the API limiter value for /api routes (0 = unlimited)
func (*AppSettings) GetJobQueueWorkerCount ¶
func (s *AppSettings) GetJobQueueWorkerCount() int
GetJobQueueWorkerCount returns the job queue worker count
func (*AppSettings) GetS3BackupCheckInterval ¶
func (s *AppSettings) GetS3BackupCheckInterval() int
GetS3BackupCheckInterval returns the S3 backup check interval in minutes
func (*AppSettings) GetS3BackupDelayMinutes ¶
func (s *AppSettings) GetS3BackupDelayMinutes() int
GetS3BackupDelayMinutes returns the S3 backup delay in minutes
func (*AppSettings) GetS3RetryInterval ¶
func (s *AppSettings) GetS3RetryInterval() int
GetS3RetryInterval returns the S3 retry interval in minutes
func (*AppSettings) GetSiteDescription ¶
func (s *AppSettings) GetSiteDescription() string
GetSiteDescription returns the site description
func (*AppSettings) GetSiteTitle ¶
func (s *AppSettings) GetSiteTitle() string
GetSiteTitle returns the site title
func (*AppSettings) GetUploadRateLimitPerMinute ¶
func (s *AppSettings) GetUploadRateLimitPerMinute() int
GetUploadRateLimitPerMinute returns API rate limit for uploads (0 = unlimited)
func (*AppSettings) GetUploadUserRateLimitPerMinute ¶
func (s *AppSettings) GetUploadUserRateLimitPerMinute() int
GetUploadUserRateLimitPerMinute returns per-user upload rate limit per minute (0 = unlimited)
func (*AppSettings) IsDirectUploadEnabled ¶
func (s *AppSettings) IsDirectUploadEnabled() bool
IsDirectUploadEnabled returns whether direct-to-storage upload is enabled
func (*AppSettings) IsImageUploadEnabled ¶
func (s *AppSettings) IsImageUploadEnabled() bool
IsImageUploadEnabled returns whether image upload is enabled
func (*AppSettings) IsReplicationChecksumRequired ¶
func (s *AppSettings) IsReplicationChecksumRequired() bool
IsReplicationChecksumRequired returns whether replication checksum validation is required
func (*AppSettings) IsS3BackupEnabled ¶
func (s *AppSettings) IsS3BackupEnabled() bool
IsS3BackupEnabled returns whether S3 backups are enabled via admin settings
func (*AppSettings) IsThumbnailAVIFEnabled ¶
func (s *AppSettings) IsThumbnailAVIFEnabled() bool
IsThumbnailAVIFEnabled returns whether AVIF format thumbnails are enabled
func (*AppSettings) IsThumbnailOriginalEnabled ¶
func (s *AppSettings) IsThumbnailOriginalEnabled() bool
IsThumbnailOriginalEnabled returns whether original format thumbnails are enabled
func (*AppSettings) IsThumbnailWebPEnabled ¶
func (s *AppSettings) IsThumbnailWebPEnabled() bool
IsThumbnailWebPEnabled returns whether WebP format thumbnails are enabled
func (*AppSettings) ToJSON ¶
func (s *AppSettings) ToJSON() ([]byte, error)
ToJSON converts settings to JSON
func (*AppSettings) Validate ¶
func (s *AppSettings) Validate() error
Validate validates the settings
type BackupProvider ¶
type BackupProvider string
BackupProvider defines the supported backup providers
const ( BackupProviderS3 BackupProvider = "s3" BackupProviderGCS BackupProvider = "gcs" BackupProviderAzure BackupProvider = "azure" )
type BackupStatus ¶
type BackupStatus string
BackupStatus defines the possible backup states
const ( BackupStatusPending BackupStatus = "pending" BackupStatusUploading BackupStatus = "uploading" BackupStatusCompleted BackupStatus = "completed" BackupStatusFailed BackupStatus = "failed" BackupStatusDeleted BackupStatus = "deleted" )
type Comment ¶
type Comment struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
ImageID uint `gorm:"index" json:"image_id"`
Image Image `gorm:"foreignKey:ImageID" json:"image,omitempty"`
Content string `gorm:"type:text" json:"content" validate:"required,min=1"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
type DailyStats ¶
DailyStats repräsentiert Statistiken für einen einzelnen Tag
type Image ¶
type Image struct {
ID uint `gorm:"primaryKey" json:"id"`
UUID string `gorm:"type:char(36) CHARACTER SET utf8 COLLATE utf8_bin;uniqueIndex;not null" json:"uuid"`
UserID uint `gorm:"index;index:idx_user_file_hash,composite" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Title string `gorm:"type:varchar(255)" json:"title"`
Description string `gorm:"type:text" json:"description"`
FilePath string `gorm:"type:varchar(255);not null" json:"file_path"`
FileName string `gorm:"type:varchar(255);not null" json:"file_name"`
FileSize int64 `gorm:"type:bigint" json:"file_size"`
FileType string `gorm:"type:varchar(50)" json:"file_type"`
Width int `gorm:"type:int" json:"width"`
Height int `gorm:"type:int" json:"height"`
IsPublic bool `gorm:"default:false" json:"is_public"`
ViewCount int `gorm:"default:0" json:"view_count"`
DownloadCount int `gorm:"default:0" json:"download_count"`
IPv4 string `gorm:"type:varchar(15);default:null" json:"-"` // IPv4 address of the uploader
IPv6 string `gorm:"type:varchar(45);default:null" json:"-"` // IPv6 address of the uploader
FileHash string `gorm:"type:varchar(64);not null;default:'';index:idx_user_file_hash,composite" json:"file_hash"` // SHA-256 hash for duplicate detection
StoragePoolID uint `gorm:"index;default:null" json:"storage_pool_id"` // Reference to storage pool
StoragePool *StoragePool `gorm:"foreignKey:StoragePoolID" json:"storage_pool,omitempty"`
// relations
Metadata *ImageMetadata `gorm:"foreignKey:ImageID" json:"metadata,omitempty"`
Tags []Tag `gorm:"many2many:image_tags;" json:"tags,omitempty"`
Comments []Comment `gorm:"foreignKey:ImageID" json:"comments,omitempty"`
Likes []Like `gorm:"foreignKey:ImageID" json:"likes,omitempty"`
Albums []Album `gorm:"many2many:album_images;" json:"albums,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func FindImageByFilename ¶
FindByFilename findet ein Bild anhand seines Dateinamens
func FindImageByUUID ¶
FindByUUID findet ein Bild anhand seiner UUID
func (*Image) AfterCreate ¶
AfterCreate wird nach dem Erstellen eines neuen Datensatzes aufgerufen
func (*Image) BeforeCreate ¶
BeforeCreate wird vor dem Erstellen eines neuen Datensatzes aufgerufen
func (*Image) IncrementDownloadCount ¶
IncrementDownloadCount erhöht den Zähler für Downloads
func (*Image) IncrementViewCount ¶
IncrementViewCount erhöht den Zähler für Aufrufe
type ImageBackup ¶
type ImageBackup struct {
ID uint `gorm:"primaryKey" json:"id"`
ImageID uint `gorm:"not null;index:idx_image_id" json:"image_id"`
Image Image `gorm:"foreignKey:ImageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"image,omitempty"`
Provider BackupProvider `gorm:"type:varchar(20);not null;default:'s3';index:idx_provider" json:"provider"`
Status BackupStatus `gorm:"type:varchar(20);not null;default:'pending';index:idx_status" json:"status"`
BucketName string `gorm:"type:varchar(100)" json:"bucket_name"`
ObjectKey string `gorm:"type:varchar(500)" json:"object_key"`
BackupSize int64 `gorm:"type:bigint unsigned" json:"backup_size"`
BackupDate *time.Time `json:"backup_date"`
ErrorMessage string `gorm:"type:text" json:"error_message"`
RetryCount int `gorm:"type:int unsigned;default:0" json:"retry_count"`
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_created_at" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
ImageBackup represents a backup of an image to cloud storage
func CreateBackupRecord ¶
func CreateBackupRecord(db *gorm.DB, imageID uint, provider BackupProvider) (*ImageBackup, error)
CreateBackupRecord creates a new backup record for an image
func FindBackupByImageAndProvider ¶
func FindBackupByImageAndProvider(db *gorm.DB, imageID uint, provider BackupProvider) (*ImageBackup, error)
FindBackupByImageAndProvider finds a backup record by image ID and provider
func FindBackupsByStatus ¶
func FindBackupsByStatus(db *gorm.DB, status BackupStatus) ([]ImageBackup, error)
FindBackupsByStatus finds all backup records by status
func FindCompletedBackupsByImageID ¶
func FindCompletedBackupsByImageID(db *gorm.DB, imageID uint) ([]ImageBackup, error)
FindCompletedBackupsByImageID finds all completed backup records for an image
func FindFailedRetryableBackups ¶
func FindFailedRetryableBackups(db *gorm.DB) ([]ImageBackup, error)
FindFailedRetryableBackups finds all failed backups that can be retried
func FindPendingBackups ¶
func FindPendingBackups(db *gorm.DB) ([]ImageBackup, error)
FindPendingBackups finds all pending backup records
func (*ImageBackup) BeforeCreate ¶
func (ib *ImageBackup) BeforeCreate(tx *gorm.DB) error
BeforeCreate sets default values before creating a new backup record
func (*ImageBackup) IsRetryable ¶
func (ib *ImageBackup) IsRetryable() bool
IsRetryable checks if the backup can be retried (max 3 retries)
func (*ImageBackup) MarkAsCompleted ¶
MarkAsCompleted updates the backup status to completed with metadata
func (*ImageBackup) MarkAsDeleted ¶
func (ib *ImageBackup) MarkAsDeleted(db *gorm.DB, message string) error
MarkAsDeleted updates the backup status to deleted
func (*ImageBackup) MarkAsFailed ¶
func (ib *ImageBackup) MarkAsFailed(db *gorm.DB, errorMsg string) error
MarkAsFailed updates the backup status to failed with error message
func (*ImageBackup) MarkAsUploading ¶
func (ib *ImageBackup) MarkAsUploading(db *gorm.DB) error
MarkAsUploading updates the backup status to uploading
func (ImageBackup) TableName ¶
func (ImageBackup) TableName() string
TableName returns the table name for ImageBackup
type ImageMetadata ¶
type ImageMetadata struct {
ID uint `gorm:"primaryKey" json:"id"`
ImageID uint `gorm:"index;not null" json:"image_id"`
CameraModel *string `gorm:"type:varchar(255)" json:"camera_model"`
TakenAt *time.Time `gorm:"type:datetime" json:"taken_at"`
Latitude *float64 `gorm:"type:decimal(10,8)" json:"latitude"`
Longitude *float64 `gorm:"type:decimal(11,8)" json:"longitude"`
ExposureTime *string `gorm:"type:varchar(50)" json:"exposure_time"`
Aperture *string `gorm:"type:varchar(20)" json:"aperture"`
ISO *int `gorm:"type:int" json:"iso"`
FocalLength *string `gorm:"type:varchar(20)" json:"focal_length"`
Metadata *JSON `gorm:"type:json" json:"metadata"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
ImageMetadata contains the metadata information of an image
func FindMetadataByImageID ¶
func FindMetadataByImageID(db *gorm.DB, imageID uint) (*ImageMetadata, error)
FindMetadataByImageID finds metadata for an image by its ID
type ImageReport ¶
type ImageReport struct {
ID uint `gorm:"primaryKey" json:"id"`
ImageID uint `gorm:"index;not null" json:"image_id"`
Image *Image `gorm:"foreignKey:ImageID" json:"image,omitempty"`
ReporterID *uint `gorm:"index" json:"reporter_id,omitempty"`
Reporter *User `gorm:"foreignKey:ReporterID" json:"reporter,omitempty"`
Reason string `gorm:"type:varchar(50);not null" json:"reason"`
Details string `gorm:"type:text" json:"details"`
Status string `gorm:"type:varchar(20);default:'open'" json:"status"`
ReporterIPv4 string `gorm:"type:varchar(15);default:null" json:"-"`
ReporterIPv6 string `gorm:"type:varchar(45);default:null" json:"-"`
ResolvedByID *uint `gorm:"index" json:"resolved_by_id,omitempty"`
ResolvedBy *User `gorm:"foreignKey:ResolvedByID" json:"resolved_by,omitempty"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
type ImageVariant ¶
type ImageVariant struct {
ID uint `gorm:"primaryKey" json:"id"`
ImageID uint `gorm:"index;not null" json:"image_id"`
Image Image `gorm:"foreignKey:ImageID" json:"image,omitempty"`
VariantType string `gorm:"type:varchar(50);not null" json:"variant_type"` // thumbnail_small_webp, thumbnail_medium_webp, thumbnail_small_avif, thumbnail_medium_avif, webp, avif
FilePath string `gorm:"type:varchar(255);not null" json:"file_path"`
FileName string `gorm:"type:varchar(255);not null" json:"file_name"`
FileType string `gorm:"type:varchar(50);not null" json:"file_type"`
FileSize int64 `gorm:"type:bigint;not null" json:"file_size"`
Width int `gorm:"type:int" json:"width"`
Height int `gorm:"type:int" json:"height"`
Quality int `gorm:"type:int" json:"quality"` // Compression quality for formats that support it
StoragePoolID uint `gorm:"index;default:null" json:"storage_pool_id"` // Reference to storage pool
StoragePool *StoragePool `gorm:"foreignKey:StoragePoolID" json:"storage_pool,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func FindVariantByImageIDAndType ¶
func FindVariantByImageIDAndType(db *gorm.DB, imageID uint, variantType string) (*ImageVariant, error)
FindVariantByImageIDAndType finds a specific variant for an image
func FindVariantsByImageID ¶
func FindVariantsByImageID(db *gorm.DB, imageID uint) ([]ImageVariant, error)
FindVariantsByImageID finds all variants for a specific image
func (*ImageVariant) BeforeCreate ¶
func (iv *ImageVariant) BeforeCreate(tx *gorm.DB) error
BeforeCreate is called before creating a new record
func (ImageVariant) TableName ¶
func (ImageVariant) TableName() string
TableName returns the table name for the ImageVariant model
type JSON ¶
type JSON json.RawMessage
JSON ist ein Typ für die Speicherung von JSON-Daten in der Datenbank
func (JSON) MarshalJSON ¶
MarshalJSON implementiert das json.Marshaler Interface
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON implementiert das json.Unmarshaler Interface
type Like ¶
type Like struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
ImageID uint `gorm:"index" json:"image_id"`
Image Image `gorm:"foreignKey:ImageID" json:"image,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
type News ¶
type News struct {
ID uint64 `gorm:"primaryKey" json:"id"`
Title string `gorm:"type:varchar(255)" json:"title" validate:"required,min=3,max=255"`
Content string `gorm:"type:text" json:"content" validate:"required"`
Slug string `gorm:"uniqueIndex;type:varchar(255)" json:"slug" validate:"required,min=3,max=255"`
Published bool `gorm:"type:tinyint(1);default:0" json:"published"`
UserID uint64 `gorm:"index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
News represents a news article in the system
type Notification ¶
type Notification struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Type string `gorm:"type:varchar(50)" json:"type" validate:"oneof=like comment follow system"`
Content string `gorm:"type:text" json:"content"`
IsRead bool `gorm:"default:false" json:"is_read"`
ReferenceID uint `json:"reference_id"` // ID des Objekts, auf das sich die Benachrichtigung bezieht
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (*Notification) MarkAsRead ¶
func (n *Notification) MarkAsRead(db *gorm.DB) error
MarkAsRead markiert eine Benachrichtigung als gelesen
type Page ¶
type Page struct {
ID uint `gorm:"primaryKey" json:"id"`
Title string `gorm:"type:varchar(255);not null" json:"title" validate:"required,min=1,max=255"`
Slug string `gorm:"type:varchar(255);uniqueIndex;not null" json:"slug" validate:"required,min=1,max=255"`
Content string `gorm:"type:longtext;not null" json:"content" validate:"required,min=1"`
IsActive bool `gorm:"default:true" json:"is_active"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
type ProviderAccount ¶
type ProviderAccount struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"index" json:"user_id"`
Provider string `gorm:"index:provider_uid,unique;type:varchar(50)" json:"provider"`
ProviderUserID string `gorm:"index:provider_uid,unique;type:varchar(191)" json:"provider_user_id"`
AccessToken string `gorm:"type:text" json:"-"`
RefreshToken string `gorm:"type:text" json:"-"`
ExpiresAt *time.Time `gorm:"type:timestamp;default:null" json:"expires_at,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
ProviderAccount stores external OAuth provider identities linked to a user
type Setting ¶
type Setting struct {
ID uint `gorm:"primaryKey" json:"id"`
Key string `gorm:"column:setting_key;size:255;not null;uniqueIndex" json:"key" validate:"required,min=1,max=255"`
Value string `gorm:"type:text" json:"value"`
Type string `gorm:"size:50;not null" json:"type" validate:"required"` // string, boolean, integer, float
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Setting represents a system setting
type StoragePool ¶
type StoragePool struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"type:varchar(100);not null;uniqueIndex" json:"name"`
BasePath string `gorm:"type:varchar(500);not null" json:"base_path"`
MaxSize int64 `gorm:"type:bigint;not null" json:"max_size"` // Maximum size in bytes
UsedSize int64 `gorm:"type:bigint;default:0" json:"used_size"` // Currently used size in bytes
IsActive bool `gorm:"default:true" json:"is_active"` // Whether this pool is available for new files
IsDefault bool `gorm:"default:false" json:"is_default"` // Whether this is the default fallback pool
IsBackupTarget bool `gorm:"default:false" json:"is_backup_target"` // If true, S3 backups prefer this pool
Priority int `gorm:"default:100" json:"priority"` // Lower number = higher priority
StorageType string `gorm:"type:varchar(50);default:'local'" json:"storage_type"` // local, nfs, s3, etc.
StorageTier string `` // hot, warm, cold, archive
/* 135-byte string literal not displayed */
Description string `gorm:"type:text" json:"description"` // Optional description
// S3-specific configuration fields (only used when StorageType = 's3')
// Note: These credentials should be encrypted at rest in production
S3AccessKeyID *string `gorm:"type:varchar(255)" json:"s3_access_key_id,omitempty"` // S3 Access Key ID (nullable for security)
S3SecretAccessKey *string `gorm:"type:varchar(500)" json:"-"` // S3 Secret Key (excluded from JSON for security)
S3Region *string `gorm:"type:varchar(100)" json:"s3_region,omitempty"` // S3 Region (e.g., us-west-2, us-west-001 for Backblaze B2)
S3BucketName *string `gorm:"type:varchar(255)" json:"s3_bucket_name,omitempty"` // S3 Bucket name
S3EndpointURL *string `gorm:"type:varchar(500)" json:"s3_endpoint_url,omitempty"` // S3 Endpoint URL (for S3-compatible services like Backblaze B2, MinIO)
S3PathPrefix *string `gorm:"type:varchar(500);default:''" json:"s3_path_prefix,omitempty"` // Optional path prefix within bucket for organizing files
// Node-aware multi-VPS fields
PublicBaseURL string `gorm:"type:varchar(500);default:''" json:"public_base_url,omitempty"` // Public base URL for serving files, e.g. https://s01.pixelfox.cc
UploadAPIURL string `gorm:"type:varchar(500);default:''" json:"upload_api_url,omitempty"` // Internal/public upload API endpoint for direct-to-storage
NodeID string `gorm:"type:varchar(100);default:'';index" json:"node_id,omitempty"` // Logical node identifier, e.g. s01
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
StoragePool represents a storage location for images and variants
func FindActiveStoragePools ¶
func FindActiveStoragePools(db *gorm.DB) ([]StoragePool, error)
FindActiveStoragePools returns all active storage pools ordered by priority
func FindActiveStoragePoolsByTier ¶
func FindActiveStoragePoolsByTier(db *gorm.DB, tier string) ([]StoragePool, error)
FindActiveStoragePoolsByTier returns active storage pools filtered by tier
func FindActiveStoragePoolsByType ¶
func FindActiveStoragePoolsByType(db *gorm.DB, storageType string) ([]StoragePool, error)
FindActiveStoragePoolsByType returns active storage pools filtered by storage type
func FindAllStoragePools ¶
func FindAllStoragePools(db *gorm.DB) ([]StoragePool, error)
FindAllStoragePools returns all storage pools
func FindBackupTargetS3Pool ¶
func FindBackupTargetS3Pool(db *gorm.DB) (*StoragePool, error)
FindBackupTargetS3Pool returns the active S3 storage pool explicitly marked as backup target If multiple are marked, the one with the highest priority (lowest number) is returned. Returns nil if none found.
func FindColdStoragePools ¶
func FindColdStoragePools(db *gorm.DB) ([]StoragePool, error)
FindColdStoragePools returns all active cold storage pools
func FindDefaultStoragePool ¶
func FindDefaultStoragePool(db *gorm.DB) (*StoragePool, error)
FindDefaultStoragePool finds the default storage pool
func FindHighestPriorityS3Pool ¶
func FindHighestPriorityS3Pool(db *gorm.DB) (*StoragePool, error)
FindHighestPriorityS3Pool returns the S3 storage pool with the highest priority (lowest number) Returns nil if no active S3 storage pools are found
func FindHotStoragePools ¶
func FindHotStoragePools(db *gorm.DB) ([]StoragePool, error)
FindHotStoragePools returns all active hot storage pools
func FindLocalStoragePools ¶
func FindLocalStoragePools(db *gorm.DB) ([]StoragePool, error)
FindLocalStoragePools returns all active local storage pools
func FindNFSStoragePools ¶
func FindNFSStoragePools(db *gorm.DB) ([]StoragePool, error)
FindNFSStoragePools returns all active NFS storage pools
func FindS3StoragePools ¶
func FindS3StoragePools(db *gorm.DB) ([]StoragePool, error)
FindS3StoragePools returns all active S3 storage pools
func FindStoragePoolByID ¶
func FindStoragePoolByID(db *gorm.DB, id uint) (*StoragePool, error)
FindStoragePoolByID finds a storage pool by ID
func FindStoragePoolByName ¶
func FindStoragePoolByName(db *gorm.DB, name string) (*StoragePool, error)
FindStoragePoolByName finds a storage pool by name
func SelectOptimalPool ¶
func SelectOptimalPool(db *gorm.DB, fileSize int64) (*StoragePool, error)
SelectOptimalPool selects the best storage pool for a file of given size DEPRECATED: Use SelectOptimalPoolForUpload for new uploads with tier-aware selection
func SelectOptimalPoolForUpload ¶
func SelectOptimalPoolForUpload(db *gorm.DB, fileSize int64) (*StoragePool, error)
SelectOptimalPoolForUpload selects the best hot storage pool for new uploads All new uploads should go to hot storage first for optimal performance
func (*StoragePool) BeforeCreate ¶
func (sp *StoragePool) BeforeCreate(tx *gorm.DB) error
BeforeCreate validates the storage pool before creation
func (*StoragePool) BeforeUpdate ¶
func (sp *StoragePool) BeforeUpdate(tx *gorm.DB) error
BeforeUpdate validates the storage pool before update
func (*StoragePool) CanAcceptFile ¶
func (sp *StoragePool) CanAcceptFile(size int64) bool
CanAcceptFile checks if this pool can accept a file of given size
func (*StoragePool) GetAvailableSize ¶
func (sp *StoragePool) GetAvailableSize() int64
GetAvailableSize returns the available space in this pool
func (*StoragePool) GetS3AccessKeyID ¶
func (sp *StoragePool) GetS3AccessKeyID() string
GetS3AccessKeyID safely returns the S3 Access Key ID
func (*StoragePool) GetS3BucketName ¶
func (sp *StoragePool) GetS3BucketName() string
GetS3BucketName safely returns the S3 bucket name
func (*StoragePool) GetS3EndpointURL ¶
func (sp *StoragePool) GetS3EndpointURL() string
GetS3EndpointURL safely returns the S3 endpoint URL
func (*StoragePool) GetS3PathPrefix ¶
func (sp *StoragePool) GetS3PathPrefix() string
GetS3PathPrefix safely returns the S3 path prefix
func (*StoragePool) GetS3Region ¶
func (sp *StoragePool) GetS3Region() string
GetS3Region safely returns the S3 region
func (*StoragePool) GetS3SecretAccessKey ¶
func (sp *StoragePool) GetS3SecretAccessKey() string
GetS3SecretAccessKey safely returns the S3 Secret Access Key
func (*StoragePool) GetUsagePercentage ¶
func (sp *StoragePool) GetUsagePercentage() float64
GetUsagePercentage returns the usage percentage of this pool
func (*StoragePool) HasS3Credentials ¶
func (sp *StoragePool) HasS3Credentials() bool
HasS3Credentials checks if S3 credentials are configured
func (*StoragePool) IsColdStorage ¶
func (sp *StoragePool) IsColdStorage() bool
IsColdStorage checks if this pool is cold storage
func (*StoragePool) IsHealthy ¶
func (sp *StoragePool) IsHealthy() bool
IsHealthy checks if the storage pool is healthy
func (*StoragePool) IsHotStorage ¶
func (sp *StoragePool) IsHotStorage() bool
IsHotStorage checks if this pool is hot storage
func (*StoragePool) IsS3Storage ¶
func (sp *StoragePool) IsS3Storage() bool
IsS3Storage checks if this pool uses S3 storage
func (*StoragePool) SetS3Configuration ¶
func (sp *StoragePool) SetS3Configuration(region, bucketName, endpointURL, pathPrefix string)
SetS3Configuration sets S3 configuration (helper method)
func (*StoragePool) SetS3Credentials ¶
func (sp *StoragePool) SetS3Credentials(accessKeyID, secretAccessKey string)
SetS3Credentials sets S3 credentials (helper method for safe credential handling)
func (*StoragePool) UpdateUsedSize ¶
func (sp *StoragePool) UpdateUsedSize(db *gorm.DB, sizeDelta int64) error
UpdateUsedSize updates the used size of the pool
func (*StoragePool) ValidateBasePath ¶
func (sp *StoragePool) ValidateBasePath() error
ValidateBasePath checks if the base path is valid and writable
func (*StoragePool) ValidateS3Configuration ¶
func (sp *StoragePool) ValidateS3Configuration() error
ValidateS3Configuration validates S3-specific configuration
func (*StoragePool) ValidateStorageConfiguration ¶
func (sp *StoragePool) ValidateStorageConfiguration() error
ValidateStorageConfiguration validates storage-specific configuration
func (*StoragePool) ValidateStorageType ¶
func (sp *StoragePool) ValidateStorageType() error
ValidateStorageType validates that the storage type is supported
type StoragePoolStats ¶
type StoragePoolStats struct {
ID uint `json:"id"`
Name string `json:"name"`
UsedSize int64 `json:"used_size"`
MaxSize int64 `json:"max_size"`
AvailableSize int64 `json:"available_size"`
UsagePercentage float64 `json:"usage_percentage"`
ImageCount int64 `json:"image_count"`
VariantCount int64 `json:"variant_count"`
IsHealthy bool `json:"is_healthy"`
LastHealthCheck time.Time `json:"last_health_check"`
}
StoragePoolStats represents statistics for a storage pool
func GetAllStoragePoolStats ¶
func GetAllStoragePoolStats(db *gorm.DB) ([]StoragePoolStats, error)
GetAllStoragePoolStats returns statistics for all storage pools
func GetStoragePoolStats ¶
func GetStoragePoolStats(db *gorm.DB, poolID uint) (*StoragePoolStats, error)
GetStoragePoolStats returns statistics for a storage pool
type Tag ¶
type Tag struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"type:varchar(100) CHARACTER SET utf8 COLLATE utf8_bin;uniqueIndex" json:"name" validate:"required,min=2,max=100"`
Images []Image `gorm:"many2many:image_tags;" json:"images,omitempty"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"type:varchar(150)" json:"name" validate:"required,min=3,max=150"`
Email string `gorm:"uniqueIndex;type:varchar(200) CHARACTER SET utf8 COLLATE utf8_bin" json:"email" validate:"required,email,min=5,max=200"`
Password string `gorm:"type:text" json:"-" validate:"required,min=6"`
Role string `gorm:"type:varchar(50);default:'user'" json:"role" validate:"oneof=user admin"`
Status string `gorm:"type:varchar(50);default:'active'" json:"status" validate:"oneof=active inactive disabled"`
Bio string `gorm:"type:text;default:null" json:"bio" validate:"max=1000"`
AvatarURL string `gorm:"type:varchar(255);default:null" json:"avatar_url" validate:"max=255"`
IPv4 string `gorm:"type:varchar(15);default:null" json:"-"`
IPv6 string `gorm:"type:varchar(45);default:null" json:"-"`
ActivationToken string `gorm:"type:varchar(100);index" json:"-"`
ActivationSentAt *time.Time `gorm:"type:timestamp;default:null" json:"-"`
PendingEmail string `gorm:"type:varchar(200);default:null" json:"-"` // New email waiting for verification
EmailChangeToken string `gorm:"type:varchar(100);default:null;index" json:"-"` // Token for email change verification
EmailChangeSentAt *time.Time `gorm:"type:timestamp;default:null" json:"-"` // When email change token was sent
LastLoginAt *time.Time `gorm:"type:timestamp;default:null" json:"last_login_at"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Accounts []ProviderAccount `gorm:"foreignKey:UserID" json:"accounts,omitempty"`
}
func (*User) CheckPassword ¶
CheckPassword verifies if the provided password matches the user's stored password
func (*User) ClearEmailChangeRequest ¶
func (u *User) ClearEmailChangeRequest()
ClearEmailChangeRequest clears all email change related fields
func (*User) GenerateActivationToken ¶
GenerateActivationToken creates a random token and sets ActivationSentAt
func (*User) GenerateEmailChangeToken ¶
GenerateEmailChangeToken creates a random token for email change verification
func (*User) HasPendingEmailChange ¶
HasPendingEmailChange returns true if user has a pending email change
func (*User) IsEmailChangeTokenValid ¶
IsEmailChangeTokenValid checks if the email change token is valid and not expired (24 hours)
func (*User) SetPassword ¶
SetPassword hashes and sets a new password for the user
type UserSettings ¶
type UserSettings struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"uniqueIndex" json:"user_id"`
Plan string `gorm:"type:varchar(50);default:'free'" json:"plan"`
PrefThumbOriginal bool `gorm:"default:true" json:"pref_thumb_original"`
PrefThumbWebP bool `gorm:"default:false" json:"pref_thumb_webp"`
PrefThumbAVIF bool `gorm:"default:false" json:"pref_thumb_avif"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
UserSettings stores per-user preferences and plan info
func GetOrCreateUserSettings ¶
func GetOrCreateUserSettings(db *gorm.DB, userID uint) (*UserSettings, error)
GetOrCreateUserSettings returns existing settings or creates defaults