Documentation
¶
Overview ¶
Package importexport provides data portability services for the Lesser ActivityPub server.
This service handles all operations related to data import and export including: - Creating and managing export requests (archive, followers, following, etc.) - Processing import requests from various formats (ActivityPub, Mastodon, CSV) - Handling large datasets asynchronously with progress tracking - Managing media attachments in exports/imports - Emitting progress events for real-time status updates
Index ¶
- type CancelExportCommand
- type CreateExportCommand
- type CreateImportCommand
- type DateRange
- type ExportListResult
- type ExportResult
- type GetExportQuery
- type GetImportQuery
- type ImportListResult
- type ImportResult
- type ListExportsQuery
- type ListImportsQuery
- type QueueService
- type Service
- func (s *Service) CancelExport(ctx context.Context, cmd *CancelExportCommand) (*ExportResult, error)
- func (s *Service) CompleteExport(ctx context.Context, exportID string, fileURL string, fileSize int64) error
- func (s *Service) CreateExport(ctx context.Context, cmd *CreateExportCommand) (*ExportResult, error)
- func (s *Service) CreateImport(ctx context.Context, cmd *CreateImportCommand) (*ImportResult, error)
- func (s *Service) GetExport(ctx context.Context, query *GetExportQuery) (*ExportResult, error)
- func (s *Service) GetImport(ctx context.Context, query *GetImportQuery) (*ImportResult, error)
- func (s *Service) ListExports(ctx context.Context, query *ListExportsQuery) (*ExportListResult, error)
- func (s *Service) ListImports(ctx context.Context, query *ListImportsQuery) (*ImportListResult, error)
- func (s *Service) UpdateExportProgress(ctx context.Context, exportID string, processed, total int) error
- type StorageClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelExportCommand ¶
type CancelExportCommand struct {
ExportID string `json:"export_id" validate:"required"`
Username string `json:"username" validate:"required"` // For authorization
}
CancelExportCommand contains data needed to cancel an export
type CreateExportCommand ¶
type CreateExportCommand struct {
Username string `json:"username" validate:"required"`
Type string `json:"type" validate:"required,oneof=archive followers following lists bookmarks mutes blocks"`
Format string `json:"format" validate:"required,oneof=activitypub mastodon csv"`
IncludeMedia bool `json:"include_media"`
DateRange *DateRange `json:"date_range"`
Options map[string]string `json:"options"`
RequestedBy string `json:"requested_by" validate:"required"`
}
CreateExportCommand contains data needed to create an export request
type CreateImportCommand ¶
type CreateImportCommand struct {
Username string `json:"username" validate:"required"`
Type string `json:"type" validate:"required,oneof=archive followers following lists bookmarks mutes blocks"`
Format string `json:"format" validate:"required,oneof=activitypub mastodon csv"`
FileURL string `json:"file_url" validate:"required,url"`
Options map[string]string `json:"options"`
MergeStrategy string `json:"merge_strategy" validate:"required,oneof=merge replace skip"`
RequestedBy string `json:"requested_by" validate:"required"`
}
CreateImportCommand contains data needed to create an import request
type ExportListResult ¶
type ExportListResult struct {
Exports []*models.Export `json:"exports"`
NextCursor string `json:"next_cursor"`
HasMore bool `json:"has_more"`
Events []streaming.Event `json:"-"`
}
ExportListResult contains a paginated list of exports
type ExportResult ¶
type ExportResult struct {
Export *models.Export `json:"export"`
DownloadURL string `json:"download_url,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
Events []streaming.Event `json:"-"` // Events emitted during operation
}
ExportResult contains the result of an export operation
type GetExportQuery ¶
type GetExportQuery struct {
ExportID string `json:"export_id" validate:"required"`
Username string `json:"username" validate:"required"` // For authorization
}
GetExportQuery contains parameters for retrieving an export
type GetImportQuery ¶
type GetImportQuery struct {
ImportID string `json:"import_id" validate:"required"`
Username string `json:"username" validate:"required"` // For authorization
}
GetImportQuery contains parameters for retrieving an import
type ImportListResult ¶
type ImportListResult struct {
Imports []*models.Import `json:"imports"`
NextCursor string `json:"next_cursor"`
HasMore bool `json:"has_more"`
Events []streaming.Event `json:"-"`
}
ImportListResult contains a paginated list of imports
type ImportResult ¶
type ImportResult struct {
Import *models.Import `json:"import"`
Processed int `json:"processed"`
Skipped int `json:"skipped"`
Failed int `json:"failed"`
Events []streaming.Event `json:"-"` // Events emitted during operation
}
ImportResult contains the result of an import operation
type ListExportsQuery ¶
type ListExportsQuery struct {
Username string `json:"username" validate:"required"`
Status string `json:"status"` // pending, processing, completed, failed
Pagination interfaces.PaginationOptions `json:"pagination"`
}
ListExportsQuery contains parameters for listing exports
type ListImportsQuery ¶
type ListImportsQuery struct {
Username string `json:"username" validate:"required"`
Status string `json:"status"` // pending, processing, completed, failed
Pagination interfaces.PaginationOptions `json:"pagination"`
}
ListImportsQuery contains parameters for listing imports
type QueueService ¶
type QueueService interface {
QueueExportJob(ctx context.Context, exportID string) error
QueueImportJob(ctx context.Context, importID string) error
}
QueueService defines the interface for queuing async operations
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides business logic for import/export operations
func NewService ¶
func NewService( exportRepo exportRepository, importRepo importRepository, statusRepo interfaces.StatusRepository, accountRepo accountRepository, mediaRepo *repositories.MediaRepository, socialRepo interfaces.SocialRepository, publisher streaming.Publisher, queueService QueueService, storageClient StorageClient, logger *zap.Logger, domain string, ) *Service
NewService creates a new import/export service
func (*Service) CancelExport ¶
func (s *Service) CancelExport(ctx context.Context, cmd *CancelExportCommand) (*ExportResult, error)
CancelExport cancels a pending or processing export operation
func (*Service) CompleteExport ¶
func (s *Service) CompleteExport(ctx context.Context, exportID string, fileURL string, fileSize int64) error
CompleteExport marks an export as completed (called by background processor)
func (*Service) CreateExport ¶
func (s *Service) CreateExport(ctx context.Context, cmd *CreateExportCommand) (*ExportResult, error)
CreateExport creates a new export request and queues it for processing
func (*Service) CreateImport ¶
func (s *Service) CreateImport(ctx context.Context, cmd *CreateImportCommand) (*ImportResult, error)
CreateImport creates a new import request for data portability
func (*Service) GetExport ¶
func (s *Service) GetExport(ctx context.Context, query *GetExportQuery) (*ExportResult, error)
GetExport retrieves an export by ID
func (*Service) GetImport ¶
func (s *Service) GetImport(ctx context.Context, query *GetImportQuery) (*ImportResult, error)
GetImport retrieves details of a specific import request
func (*Service) ListExports ¶
func (s *Service) ListExports(ctx context.Context, query *ListExportsQuery) (*ExportListResult, error)
ListExports lists exports for a user
func (*Service) ListImports ¶
func (s *Service) ListImports(ctx context.Context, query *ListImportsQuery) (*ImportListResult, error)
ListImports retrieves all imports for a user with optional filtering
type StorageClient ¶
type StorageClient interface {
GeneratePresignedURL(ctx context.Context, key string, expiry time.Duration) (string, error)
UploadFile(ctx context.Context, key string, data []byte) error
GetFile(ctx context.Context, key string) ([]byte, error)
}
StorageClient defines the interface for file storage operations