veza/veza-backend-api/internal/models/data_export.go
senke f2881ad865
Some checks failed
Backend API CI / test-unit (push) Failing after 1s
Frontend CI / test (push) Failing after 3s
Storybook Audit / Build & audit Storybook (push) Failing after 2s
Backend API CI / test-integration (push) Failing after 6s
feat(gdpr): v0.10.8 portabilité données - export ZIP async, suppression compte, hard delete cron
- Export: table data_exports, POST /me/export (202), GET /me/exports, messages+playback_history
- Notification email quand ZIP prêt, rate limit 3/jour
- Suppression: keep_public_tracks, anonymisation PII complète (users, user_profiles)
- HardDeleteWorker: final anonymization après 30 jours
- Frontend: POST export, checkbox keep_public_tracks
- MSW handlers pour Storybook
2026-03-10 13:57:04 +01:00

34 lines
1.1 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// DataExport represents a GDPR data export job (v0.10.8 F065)
type DataExport struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
UserID uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
Status string `gorm:"type:varchar(20);not null;default:'pending'" json:"status"` // pending, processing, completed, failed
S3Key *string `gorm:"type:text" json:"s3_key,omitempty"`
FileSizeBytes *int64 `json:"file_size_bytes,omitempty"`
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage *string `gorm:"type:text" json:"error_message,omitempty"`
}
// TableName returns the table name for DataExport
func (DataExport) TableName() string {
return "data_exports"
}
// BeforeCreate generates UUID if not set
func (e *DataExport) BeforeCreate(tx *gorm.DB) error {
if e.ID == uuid.Nil {
e.ID = uuid.New()
}
return nil
}