Documentation
¶
Index ¶
- Constants
- Variables
- type AgeRatingMap
- type AgeRatingMappings
- type CoverFallbackMethod
- type DownloadRequestMetadata
- type ManualMigration
- type Metadata
- type MetadataKey
- type MetadataRow
- type Model
- type Modifier
- type ModifierType
- type ModifierValue
- type Notification
- type NotificationColour
- type NotificationGroup
- type Notifications
- type Option
- type Page
- type Pages
- type PasswordReset
- type Preference
- type Preferences
- type Provider
- type RefreshFrequency
- type ServerSetting
- type SettingKey
- type Settings
- type Subscription
- type SubscriptionInfo
- type Subscriptions
- type Tag
- type TagMap
- type TagMaps
- type Tags
- type User
- type UserPermission
- type Users
Constants ¶
View Source
const ( PermWritePage = 1 << iota PermDeletePage PermWriteUser PermDeleteUser PermWriteConfig )
Variables ¶
View Source
var ( ALL_PERMS = PermWritePage | PermDeletePage | PermWriteConfig | PermWriteUser | PermDeleteUser | PermWriteConfig )
View Source
var DefaultPages = []Page{ { Title: "Anime", SortValue: 1, Providers: pq.Int64Array{int64(NYAA), int64(SUBSPLEASE)}, Modifiers: []Modifier{ { Title: "Category", Key: "categories", Type: DROPDOWN, Values: []ModifierValue{ { Key: "anime", Value: "Anime", }, { Key: "anime-amv", Value: "Music Video", }, { Key: "anime-eng", Value: "English Translated", }, { Key: "anime-non-eng", Value: "Non-English Translated", }, }, }, { Title: "Sort", Key: "sortBys", Type: DROPDOWN, Values: []ModifierValue{ { Key: "downloads", Value: "Downloads", }, { Key: "date", Value: "Date", }, { Key: "size", Value: "Size", }, { Key: "seeders", Value: "Seeders", }, { Key: "leechers", Value: "Leechers", }, { Key: "comments", Value: "Comments", }, }, }, }, Dirs: []string{"Anime"}, CustomRootDir: "Anime", }, { Title: "Mangadex", SortValue: 2, Providers: pq.Int64Array{int64(MANGADEX)}, Modifiers: []Modifier{ { Title: "Include Tags", Key: "includeTags", Type: MULTI, Values: []ModifierValue{ { Key: "Romance", Value: "Romance", }, { Key: "Ninja", Value: "Ninja", }, { Key: "Comedy", Value: "Comedy", }, { Key: "Mecha", Value: "Mecha", }, { Key: "Anthology", Value: "Anthology", }, }, }, { Title: "Exclude Tags", Key: "excludeTags", Type: MULTI, Values: []ModifierValue{ { Key: "Cooking", Value: "Cooking", }, { Key: "Supernatural", Value: "Supernatural", }, { Key: "Mystery", Value: "Mystery", }, { Key: "Adaptation", Value: "Adaptation", }, { Key: "Music", Value: "Music", }, { Key: "Full Color", Value: "Full Color", }, }, }, { Title: "Status", Key: "status", Type: MULTI, Values: []ModifierValue{ { Key: "ongoing", Value: "Ongoing", }, { Key: "completed", Value: "Completed", }, { Key: "hiatus", Value: "Hiatus", }, { Key: "cancelled", Value: "Cancelled", }, }, }, { Title: "Content Rating", Key: "contentRating", Type: MULTI, Values: []ModifierValue{ { Key: "safe", Value: "Safe", }, { Key: "suggestive", Value: "Suggestive", }, }, }, { Title: "Demographic", Key: "publicationDemographic", Type: MULTI, Values: []ModifierValue{ { Key: "shounen", Value: "Shounen", }, { Key: "shoujo", Value: "Shoujo", }, { Key: "josei", Value: "Josei", }, { Key: "seinen", Value: "Seinen", }, }, }, }, Dirs: []string{"Manga"}, CustomRootDir: "Manga", }, { Title: "Manga & Light Novels", SortValue: 3, Providers: pq.Int64Array{int64(NYAA)}, Modifiers: []Modifier{ { Title: "Category", Key: "categories", Type: DROPDOWN, Values: []ModifierValue{ { Key: "literature-eng", Value: "English Literature", }, { Key: "literature", Value: "Literature", }, { Key: "literature-non-eng", Value: "Non English Literature", }, { Key: "literature-raw", Value: "Raw Literature", }, }, }, { Title: "Sort by", Key: "sortBys", Type: DROPDOWN, Values: []ModifierValue{ { Key: "downloads", Value: "Downloads", }, { Key: "date", Value: "Date", }, { Key: "size", Value: "Size", }, { Key: "seeders", Value: "Seeders", }, { Key: "leechers", Value: "Leechers", }, { Key: "comments", Value: "Comments", }, }, }, }, Dirs: []string{"Manga", "LightNovels"}, CustomRootDir: "", }, { Title: "Movies", SortValue: 4, Providers: pq.Int64Array{int64(YTS)}, Modifiers: []Modifier{ { Title: "Sort By", Key: "sortBys", Type: DROPDOWN, Values: []ModifierValue{ { Key: "title", Value: "Title", }, { Key: "year", Value: "Year", }, { Key: "rating", Value: "Rating", }, { Key: "peers", Value: "Peers", }, { Key: "seeds", Value: "Seeders", }, { Key: "download_count", Value: "Downloads", }, { Key: "like_count", Value: "Likes", }, { Key: "date_added", Value: "Date Added", }, }, }, }, Dirs: []string{"Movies"}, CustomRootDir: "Movies", }, { Title: "Lime", SortValue: 5, Providers: pq.Int64Array{int64(LIME)}, Modifiers: []Modifier{ { Title: "Category", Key: "categories", Type: DROPDOWN, Values: []ModifierValue{ { Key: "ALL", Value: "All categories", }, { Key: "MOVIES", Value: "Movies", }, { Key: "TV", Value: "TV", }, { Key: "ANIME", Value: "Anime", }, { Key: "OTHER", Value: "Other", }, }, }, }, Dirs: []string{"Anime", "Movies", "Manga", "Series", "LightNovels"}, CustomRootDir: "", }, { Title: "WebToon", SortValue: 6, Providers: pq.Int64Array{int64(WEBTOON)}, Modifiers: []Modifier{}, Dirs: []string{"Manga"}, CustomRootDir: "Manga", }, }
View Source
var (
ErrFailedToLoadPreferences = errors.New("failed to load preferences")
)
View Source
var MODELS = []any{ &User{}, &PasswordReset{}, &Subscription{}, &SubscriptionInfo{}, &Page{}, &Modifier{}, &ModifierValue{}, &ManualMigration{}, &Preference{}, &Notification{}, &Tag{}, &MetadataRow{}, &TagMap{}, &ServerSetting{}, }
Functions ¶
This section is empty.
Types ¶
type AgeRatingMap ¶
type AgeRatingMappings ¶
type AgeRatingMappings []AgeRatingMap
func (AgeRatingMappings) GetAgeRating ¶
func (arm AgeRatingMappings) GetAgeRating(tag string) (comicinfo.AgeRating, bool)
type CoverFallbackMethod ¶
type CoverFallbackMethod int
const ( CoverFallbackFirst CoverFallbackMethod = iota CoverFallbackLast CoverFallbackNone )
type DownloadRequestMetadata ¶
type ManualMigration ¶
type Metadata ¶
type Metadata interface {
All() ([]MetadataRow, error)
GetRow(key MetadataKey) (*MetadataRow, error)
UpdateRow(metadata MetadataRow) error
Update([]MetadataRow) error
}
type MetadataKey ¶
type MetadataKey int
const ( InstalledVersion MetadataKey = iota FirstInstalledVersion InstallDate )
type MetadataRow ¶
type MetadataRow struct {
Key MetadataKey
Value string
}
type Modifier ¶
type Modifier struct {
Model
PageID uint
Title string `json:"title"`
Type ModifierType `json:"type"`
Key string `json:"key"`
Values []ModifierValue `json:"values"`
Sort int
}
type ModifierValue ¶
type Notification ¶
type Notification struct {
Model
Title string `json:"title"`
Summary string `json:"summary"`
Body string `json:"body"`
Colour NotificationColour `json:"colour"`
Group NotificationGroup `json:"group" gorm:"index"`
Read bool `json:"read"`
}
type NotificationColour ¶
type NotificationColour string
const ( Primary NotificationColour = "primary" Secondary NotificationColour = "secondary" Warning NotificationColour = "warning" Error NotificationColour = "error" )
type NotificationGroup ¶
type NotificationGroup string
const ( GroupContent NotificationGroup = "content" GroupSecurity NotificationGroup = "security" GroupGeneral NotificationGroup = "general" GroupError NotificationGroup = "error" )
type Notifications ¶
type Notifications interface {
Get(id uint) (Notification, error)
GetMany(ids []uint) ([]Notification, error)
All() ([]Notification, error)
AllAfter(time.Time) ([]Notification, error)
Recent(int, NotificationGroup) ([]Notification, error)
New(Notification) error
Delete(uint) error
DeleteMany([]uint) error
MarkRead(uint) error
MarkReadMany([]uint) error
MarkUnread(uint) error
Unread() (int64, error)
}
type Page ¶
type Page struct {
Model
Title string `json:"title"`
Icon string `json:"icon"`
SortValue int `json:"sortValue"`
Providers pq.Int64Array `gorm:"type:integer[]" json:"providers"`
Modifiers []Modifier `json:"modifiers"`
Dirs pq.StringArray `gorm:"type:string[]" json:"dirs"`
CustomRootDir string `json:"customRootDir"`
}
type Preference ¶
type Preference struct {
Model
SubscriptionRefreshHour int `json:"subscriptionRefreshHour" validate:"min=0,max=23"`
LogEmptyDownloads bool `json:"logEmptyDownloads" validate:"boolean"`
ConvertToWebp bool `json:"convertToWebp" validate:"boolean"`
CoverFallbackMethod CoverFallbackMethod `json:"coverFallbackMethod"`
DynastyGenreTags []Tag `json:"dynastyGenreTags" gorm:"many2many:preference_dynasty_genre_tags"`
BlackListedTags []Tag `json:"blackListedTags" gorm:"many2many:preference_black_list_tags"`
WhiteListedTags []Tag `json:"whiteListedTags" gorm:"many2many:preference_white_list_tags"`
AgeRatingMappings []AgeRatingMap `json:"ageRatingMappings" gorm:"many2many:preference_age_rating_mappings"`
TagMappings []TagMap `json:"tagMappings"`
}
type Preferences ¶
type Preferences interface {
// Get returns a pointer to Preference, with no relations loaded
Get() (*Preference, error)
// GetComplete returns a pointer to Preference, with all relations loaded
GetComplete() (*Preference, error)
Update(pref Preference) error
// Flush set the cached value for Get and GetComplete to nil
Flush() error
}
type RefreshFrequency ¶
type RefreshFrequency int
const ( Day RefreshFrequency = iota + 2 Week Month )
func (RefreshFrequency) AsDuration ¶
func (f RefreshFrequency) AsDuration() time.Duration
type ServerSetting ¶
type ServerSetting struct {
Key SettingKey `gorm:"unique"`
Value string `gorm:"type:text"`
}
type SettingKey ¶
type SettingKey int
const ( OidcAuthority SettingKey = iota OidcClientID BaseUrl CacheType RedisAddr MaxConcurrentTorrents MaxConcurrentImages DisableIpv6 RootDir OidcAutoLogin OidcDisablePasswordLogin )
type Settings ¶
type Settings interface {
All() ([]ServerSetting, error)
GetById(SettingKey) (ServerSetting, error)
Update([]ServerSetting) error
}
type Subscription ¶
type Subscription struct {
Model
Provider Provider `json:"provider" gorm:"type:int"`
ContentId string `json:"contentId"`
RefreshFrequency RefreshFrequency `json:"refreshFrequency" gorm:"type:int"`
Info SubscriptionInfo `json:"info"`
Metadata json.RawMessage `gorm:"type:jsonb" json:"-"`
Payload DownloadRequestMetadata `json:"metadata" gorm:"-:all"`
}
func (*Subscription) BeforeSave ¶
func (s *Subscription) BeforeSave(tx *gorm.DB) (err error)
func (*Subscription) NextExecution ¶
func (s *Subscription) NextExecution(hour int) time.Time
func (*Subscription) Normalize ¶
func (s *Subscription) Normalize(hour int)
func (*Subscription) ShouldRefresh ¶
func (s *Subscription) ShouldRefresh(old *Subscription) bool
type SubscriptionInfo ¶
type Subscriptions ¶
type Subscriptions interface {
All() ([]Subscription, error)
Get(uint) (*Subscription, error)
GetByContentId(string) (*Subscription, error)
New(Subscription) (*Subscription, error)
Update(Subscription) error
Delete(uint) error
}
type Tag ¶
type Tag struct {
Model
PreferenceID uint
AgeRatingMapID uint
Name string `json:"name"`
NormalizedName string `json:"normalizedName"`
}
func (*Tag) IsNotNormalized ¶
type User ¶
type User struct {
Model
Name string `gorm:"unique"`
Email sql.NullString `gorm:"unique"`
PasswordHash string
ApiKey string
Permission int
// Will not be updated in the UpdateUser method, should be set on creation. And only for the first account
Original bool
ExternalId sql.NullString `gorm:"unique,nullable"`
}
func (*User) HasPermission ¶
func (u *User) HasPermission(permission UserPermission) bool
type UserPermission ¶
type UserPermission int
type Users ¶
type Users interface {
All() ([]User, error)
ExistsAny() (bool, error)
GetById(id uint) (*User, error)
GetByExternalId(ExternalId string) (*User, error)
GetByEmail(email string) (*User, error)
GetByName(name string) (*User, error)
GetByApiKey(key string) (*User, error)
Create(name string, opts ...Option[User]) (*User, error)
Update(user User, opts ...Option[User]) (*User, error)
UpdateById(id uint, opts ...Option[User]) (*User, error)
GenerateReset(userId uint) (*PasswordReset, error)
GetResetByUserId(userId uint) (*PasswordReset, error)
GetReset(key string) (*PasswordReset, error)
DeleteReset(key string) error
Delete(id uint) error
}
Click to show internal directories.
Click to hide internal directories.