Documentation
¶
Index ¶
- func ItemToJSON(item models.LibraryItem) map[string]interface{}
- type BlocklistEntry
- type DB
- func (d *DB) AddBlocklistEntry(title, source, downloadURL, infoHash, reason string) (int64, error)
- func (d *DB) AddItem(item *models.LibraryItem) (int64, error)
- func (d *DB) AddItemTag(itemID, tagID int64) error
- func (d *DB) AddMonitoredAuthor(name string, intervalDays int) (int64, error)
- func (d *DB) AddReadingHistory(userID int64, bookTitle, author, format string, ...) (int64, error)
- func (d *DB) AddWishlistItem(title, author, mediaType string) (int64, error)
- func (d *DB) ClearBlocklist() error
- func (d *DB) ClearFinishedJobs() (int, error)
- func (d *DB) Close() error
- func (d *DB) CountActivity() (int, error)
- func (d *DB) CountItems(mediaType string) (int, error)
- func (d *DB) CountRequests(userID int64, status string) (int, error)
- func (d *DB) CountUnreadNotifications(userID int64) (int, error)
- func (d *DB) CountUsers() (int, error)
- func (d *DB) CreateNotification(n *models.Notification) (int64, error)
- func (d *DB) CreateQualityProfile(qp *QualityProfile) (int64, error)
- func (d *DB) CreateReleaseProfile(rp *ReleaseProfile) (int64, error)
- func (d *DB) CreateRequest(req *models.Request) error
- func (d *DB) CreateTag(name, color string) (int64, error)
- func (d *DB) CreateUser(username, passwordHash, role string) (int64, error)
- func (d *DB) CreateWebhookConfig(c *webhook.Config) (int64, error)
- func (d *DB) DeleteBlocklistEntry(id int64) error
- func (d *DB) DeleteItem(id int64) error
- func (d *DB) DeleteJob(id string) error
- func (d *DB) DeleteMonitoredAuthor(id int64) error
- func (d *DB) DeleteNotification(id int64, userID int64) error
- func (d *DB) DeleteQualityProfile(id int64) error
- func (d *DB) DeleteReadingHistory(id, userID int64) error
- func (d *DB) DeleteReleaseProfile(id int64) error
- func (d *DB) DeleteRequest(id string) error
- func (d *DB) DeleteTag(id int64) error
- func (d *DB) DeleteUser(id int64) error
- func (d *DB) DeleteWebhookConfig(id int64) error
- func (d *DB) DeleteWishlistItem(id int64) error
- func (d *DB) DisableTOTP(userID int64) error
- func (d *DB) EnableTOTP(userID int64) error
- func (d *DB) FindByTitle(title string) ([]models.LibraryItem, error)
- func (d *DB) GetActivity(limit, offset int) ([]models.ActivityEvent, error)
- func (d *DB) GetActivityLog(user, action string, limit, offset int) ([]models.ActivityEntry, error)
- func (d *DB) GetActivityLogCount(user, action string) (int, error)
- func (d *DB) GetBlocklist(limit, offset int) ([]BlocklistEntry, error)
- func (d *DB) GetDBPath() string
- func (d *DB) GetItemTags(itemID int64) ([]Tag, error)
- func (d *DB) GetItems(mediaType string, limit, offset int) ([]models.LibraryItem, error)
- func (d *DB) GetItemsByTag(tagID int64, limit, offset int) ([]models.LibraryItem, error)
- func (d *DB) GetJob(id string) (*models.DownloadJob, error)
- func (d *DB) GetJobs() ([]models.DownloadJob, error)
- func (d *DB) GetMonitoredAuthors() ([]MonitoredAuthor, error)
- func (d *DB) GetNotifications(userID int64, limit, offset int) ([]models.Notification, error)
- func (d *DB) GetQualityProfile(id int64) (*QualityProfile, error)
- func (d *DB) GetQualityProfiles() ([]QualityProfile, error)
- func (d *DB) GetReadingHistory(userID int64, status string, limit, offset int) ([]ReadingHistoryEntry, error)
- func (d *DB) GetReadingStats(userID int64) (map[string]interface{}, error)
- func (d *DB) GetReleaseProfile(id int64) (*ReleaseProfile, error)
- func (d *DB) GetReleaseProfiles() ([]ReleaseProfile, error)
- func (d *DB) GetRequest(id string) (*models.Request, error)
- func (d *DB) GetSeriesTracking() ([]map[string]interface{}, error)
- func (d *DB) GetStats() (map[string]interface{}, error)
- func (d *DB) GetTags() ([]Tag, error)
- func (d *DB) GetUploads(limit, offset int) ([]models.UploadRecord, error)
- func (d *DB) GetUser(id int64) (*models.User, error)
- func (d *DB) GetUserByUsername(username string) (*models.User, error)
- func (d *DB) GetWebhookConfigs() ([]webhook.Config, error)
- func (d *DB) GetWishlist() ([]models.WishlistItem, error)
- func (d *DB) HasSourceID(sourceID string) bool
- func (d *DB) IsBlocklisted(downloadURL, infoHash string) bool
- func (d *DB) ListRequests(userID int64, status string, limit, offset int) ([]models.Request, error)
- func (d *DB) ListUsers() ([]models.User, error)
- func (d *DB) LogActivity(user, action, target, detail string)
- func (d *DB) LogEvent(eventType, title, detail string, libraryItemID *int64, jobID string) error
- func (d *DB) MarkAllNotificationsRead(userID int64) error
- func (d *DB) MarkNotificationRead(id int64, userID int64) error
- func (d *DB) RemoveItemTag(itemID, tagID int64) error
- func (d *DB) SaveBackupCodes(userID int64, codeHashes []string) error
- func (d *DB) SaveJob(job *models.DownloadJob) error
- func (d *DB) SaveUpload(user, filename, originalName, fileType string, fileSize int64, ...) (int64, error)
- func (d *DB) SetTOTPSecret(userID int64, secret string) error
- func (d *DB) UpdateJobStatus(id, status, detail, errMsg string) error
- func (d *DB) UpdateLastLogin(userID int64) error
- func (d *DB) UpdateMonitoredAuthorCheck(id int64, lastBookFound string) error
- func (d *DB) UpdateQualityProfile(qp *QualityProfile) error
- func (d *DB) UpdateReadingHistory(id, userID int64, finishedAt *time.Time, rating *int, notes *string) error
- func (d *DB) UpdateReleaseProfile(rp *ReleaseProfile) error
- func (d *DB) UpdateRequest(req *models.Request) error
- func (d *DB) UpdateRequestStatus(id, status string) error
- func (d *DB) UpdateUser(id int64, username, role string) error
- func (d *DB) UpdateUserPassword(id int64, passwordHash string) error
- func (d *DB) UpsertSeriesTracking(seriesName string, knownTotal, ownedCount int) (int64, error)
- func (d *DB) UseBackupCode(userID int64, codeHash string) (bool, error)
- type MonitoredAuthor
- type PreferredWord
- type QualityProfile
- type ReadingHistoryEntry
- type ReleaseProfile
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ItemToJSON ¶
func ItemToJSON(item models.LibraryItem) map[string]interface{}
ItemToJSON converts a LibraryItem to a JSON-friendly map.
Types ¶
type BlocklistEntry ¶ added in v1.0.0
type BlocklistEntry struct {
ID int64 `json:"id"`
Title string `json:"title"`
Source string `json:"source"`
DownloadURL string `json:"download_url"`
InfoHash string `json:"info_hash"`
Reason string `json:"reason"`
CreatedAt time.Time `json:"created_at"`
}
BlocklistEntry represents a blocklisted download.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database for library tracking and download jobs.
func (*DB) AddBlocklistEntry ¶ added in v1.0.0
func (*DB) AddItem ¶
func (d *DB) AddItem(item *models.LibraryItem) (int64, error)
AddItem records a successfully processed book.
func (*DB) AddItemTag ¶ added in v1.0.0
func (*DB) AddMonitoredAuthor ¶ added in v1.0.0
func (*DB) AddReadingHistory ¶ added in v1.0.0
func (d *DB) AddReadingHistory(userID int64, bookTitle, author, format string, startedAt, finishedAt *time.Time, rating *int, notes string, libraryItemID *int64) (int64, error)
AddReadingHistory inserts a reading history entry.
func (*DB) AddWishlistItem ¶
AddWishlistItem adds an item to the wishlist.
func (*DB) ClearBlocklist ¶ added in v1.0.0
func (*DB) ClearFinishedJobs ¶
ClearFinishedJobs removes completed, error, and dead_letter jobs.
func (*DB) CountActivity ¶
CountActivity returns the total number of activity events.
func (*DB) CountItems ¶
CountItems counts library items, optionally filtered by media type.
func (*DB) CountRequests ¶
CountRequests returns the number of requests matching the filters.
func (*DB) CountUnreadNotifications ¶
CountUnreadNotifications returns the number of unread notifications for a user.
func (*DB) CountUsers ¶
CountUsers returns the total number of users.
func (*DB) CreateNotification ¶
func (d *DB) CreateNotification(n *models.Notification) (int64, error)
CreateNotification inserts a new notification.
func (*DB) CreateQualityProfile ¶ added in v1.0.0
func (d *DB) CreateQualityProfile(qp *QualityProfile) (int64, error)
func (*DB) CreateReleaseProfile ¶ added in v1.0.0
func (d *DB) CreateReleaseProfile(rp *ReleaseProfile) (int64, error)
func (*DB) CreateRequest ¶
CreateRequest inserts a new book request.
func (*DB) CreateUser ¶
CreateUser inserts a new user. Returns the new user ID.
func (*DB) CreateWebhookConfig ¶ added in v1.0.0
CreateWebhookConfig inserts a new webhook config.
func (*DB) DeleteBlocklistEntry ¶ added in v1.0.0
func (*DB) DeleteItem ¶
DeleteItem removes a library item by ID.
func (*DB) DeleteMonitoredAuthor ¶ added in v1.0.0
func (*DB) DeleteNotification ¶
DeleteNotification removes a notification by ID (must belong to user).
func (*DB) DeleteQualityProfile ¶ added in v1.0.0
func (*DB) DeleteReadingHistory ¶ added in v1.0.0
DeleteReadingHistory removes a history entry by ID.
func (*DB) DeleteReleaseProfile ¶ added in v1.0.0
func (*DB) DeleteRequest ¶
DeleteRequest removes a request by ID.
func (*DB) DeleteWebhookConfig ¶ added in v1.0.0
DeleteWebhookConfig removes a webhook config by ID.
func (*DB) DeleteWishlistItem ¶
DeleteWishlistItem removes a wishlist item by ID.
func (*DB) DisableTOTP ¶
DisableTOTP disables TOTP and clears the secret.
func (*DB) EnableTOTP ¶
EnableTOTP enables TOTP for a user.
func (*DB) FindByTitle ¶
func (d *DB) FindByTitle(title string) ([]models.LibraryItem, error)
FindByTitle performs a case-insensitive title lookup.
func (*DB) GetActivity ¶
func (d *DB) GetActivity(limit, offset int) ([]models.ActivityEvent, error)
GetActivity returns recent activity, newest first.
func (*DB) GetActivityLog ¶
GetActivityLog returns paginated activity entries with optional filters.
func (*DB) GetActivityLogCount ¶
GetActivityLogCount returns the total number of activity entries matching filters.
func (*DB) GetBlocklist ¶ added in v1.0.0
func (d *DB) GetBlocklist(limit, offset int) ([]BlocklistEntry, error)
func (*DB) GetItemsByTag ¶ added in v1.0.0
func (*DB) GetJob ¶
func (d *DB) GetJob(id string) (*models.DownloadJob, error)
GetJob retrieves a download job by ID.
func (*DB) GetJobs ¶
func (d *DB) GetJobs() ([]models.DownloadJob, error)
GetJobs returns all download jobs.
func (*DB) GetMonitoredAuthors ¶ added in v1.0.0
func (d *DB) GetMonitoredAuthors() ([]MonitoredAuthor, error)
func (*DB) GetNotifications ¶
GetNotifications returns notifications for a user, newest first.
func (*DB) GetQualityProfile ¶ added in v1.0.0
func (d *DB) GetQualityProfile(id int64) (*QualityProfile, error)
func (*DB) GetQualityProfiles ¶ added in v1.0.0
func (d *DB) GetQualityProfiles() ([]QualityProfile, error)
func (*DB) GetReadingHistory ¶ added in v1.0.0
func (d *DB) GetReadingHistory(userID int64, status string, limit, offset int) ([]ReadingHistoryEntry, error)
GetReadingHistory returns paginated reading history for a user.
func (*DB) GetReadingStats ¶ added in v1.0.0
GetReadingStats returns reading statistics for a user.
func (*DB) GetReleaseProfile ¶ added in v1.0.0
func (d *DB) GetReleaseProfile(id int64) (*ReleaseProfile, error)
func (*DB) GetReleaseProfiles ¶ added in v1.0.0
func (d *DB) GetReleaseProfiles() ([]ReleaseProfile, error)
func (*DB) GetRequest ¶
GetRequest retrieves a request by ID.
func (*DB) GetSeriesTracking ¶ added in v1.0.0
GetSeriesTracking returns all tracked series.
func (*DB) GetUploads ¶
func (d *DB) GetUploads(limit, offset int) ([]models.UploadRecord, error)
GetUploads returns recent uploads.
func (*DB) GetUserByUsername ¶
GetUserByUsername retrieves a user by username (case-insensitive).
func (*DB) GetWebhookConfigs ¶ added in v1.0.0
GetWebhookConfigs returns all webhook configurations.
func (*DB) GetWishlist ¶
func (d *DB) GetWishlist() ([]models.WishlistItem, error)
GetWishlist returns all wishlist items.
func (*DB) HasSourceID ¶
HasSourceID checks if a source_id already exists.
func (*DB) IsBlocklisted ¶ added in v1.0.0
func (*DB) ListRequests ¶
ListRequests returns requests filtered by optional user ID and status. If userID is 0, all requests are returned (admin view).
func (*DB) LogActivity ¶
LogActivity appends a user-attributed event to the activity log.
func (*DB) MarkAllNotificationsRead ¶
MarkAllNotificationsRead marks all notifications as read for a user.
func (*DB) MarkNotificationRead ¶
MarkNotificationRead marks a single notification as read.
func (*DB) RemoveItemTag ¶ added in v1.0.0
func (*DB) SaveBackupCodes ¶
SaveBackupCodes stores hashed backup codes for a user.
func (*DB) SaveJob ¶
func (d *DB) SaveJob(job *models.DownloadJob) error
SaveJob persists a download job.
func (*DB) SaveUpload ¶
func (d *DB) SaveUpload(user, filename, originalName, fileType string, fileSize int64, organizedTo, status, errMsg string) (int64, error)
SaveUpload records a file upload.
func (*DB) SetTOTPSecret ¶
SetTOTPSecret stores the TOTP secret for a user (does not enable it yet).
func (*DB) UpdateJobStatus ¶
UpdateJobStatus updates the status and detail of a job.
func (*DB) UpdateLastLogin ¶
UpdateLastLogin updates the last_login timestamp for a user.
func (*DB) UpdateMonitoredAuthorCheck ¶ added in v1.0.0
func (*DB) UpdateQualityProfile ¶ added in v1.0.0
func (d *DB) UpdateQualityProfile(qp *QualityProfile) error
func (*DB) UpdateReadingHistory ¶ added in v1.0.0
func (d *DB) UpdateReadingHistory(id, userID int64, finishedAt *time.Time, rating *int, notes *string) error
UpdateReadingHistory updates a history entry (finish date, rating, notes).
func (*DB) UpdateReleaseProfile ¶ added in v1.0.0
func (d *DB) UpdateReleaseProfile(rp *ReleaseProfile) error
func (*DB) UpdateRequest ¶
UpdateRequest updates mutable fields on a request.
func (*DB) UpdateRequestStatus ¶
UpdateRequestStatus updates the status and optional fields of a request.
func (*DB) UpdateUser ¶
UpdateUser updates a user's username and role.
func (*DB) UpdateUserPassword ¶
UpdateUserPassword updates only the password hash.
func (*DB) UpsertSeriesTracking ¶ added in v1.0.0
UpsertSeriesTracking creates or updates a series tracking entry.
type MonitoredAuthor ¶ added in v1.0.0
type MonitoredAuthor struct {
ID int64 `json:"id"`
Name string `json:"name"`
LastChecked time.Time `json:"last_checked"`
LastBookFound string `json:"last_book_found"`
CheckIntervalDays int `json:"check_interval_days"`
}
MonitoredAuthor represents a monitored author record.
type PreferredWord ¶ added in v1.0.0
PreferredWord represents a word+score pair in a release profile.
type QualityProfile ¶ added in v1.0.0
type QualityProfile struct {
ID int64 `json:"id"`
Name string `json:"name"`
FormatRanking []string `json:"format_ranking"`
PreferredSizeMin int64 `json:"preferred_size_min"`
PreferredSizeMax int64 `json:"preferred_size_max"`
UpgradeAllowed bool `json:"upgrade_allowed"`
CutoffFormat string `json:"cutoff_format"`
}
QualityProfile represents a quality profile record.
type ReadingHistoryEntry ¶ added in v1.0.0
type ReadingHistoryEntry struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
BookTitle string `json:"book_title"`
Author string `json:"author"`
Format string `json:"format"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Rating *int `json:"rating,omitempty"`
Notes string `json:"notes"`
LibraryItemID *int64 `json:"library_item_id,omitempty"`
Status string `json:"status"`
}
ReadingHistoryEntry represents a reading history record.
type ReleaseProfile ¶ added in v1.0.0
type ReleaseProfile struct {
ID int64 `json:"id"`
Name string `json:"name"`
MustContain []string `json:"must_contain"`
MustNotContain []string `json:"must_not_contain"`
Preferred []PreferredWord `json:"preferred"`
Enabled bool `json:"enabled"`
}
ReleaseProfile represents a release profile record.