Documentation ¶
Overview ¶
Package models contains structs and default functions used all over the application to avoid circular dependencies
Index ¶
- type Account
- type Cookie
- type DatabaseInterface
- type DownloadQueueItem
- type Module
- func (t *Module) AddProxyCommands(command *cobra.Command)
- func (t *Module) AddProxyLoopCommands(command *cobra.Command)
- func (t *Module) GetFileExtension(uri string) string
- func (t *Module) GetFileName(uri string) string
- func (t *Module) GetProxySettings() (proxySettings *http.ProxySettings)
- func (t *Module) GetViperModuleKey() string
- func (t *Module) ModuleKey() string
- func (t *Module) ProcessDownloadQueue(downloadQueue []DownloadQueueItem, trackedItem *TrackedItem) error
- func (t *Module) RegisterURISchema(uriSchemas map[string][]*regexp.Regexp)
- func (t *Module) ReverseDownloadQueueItems(downloadQueue []DownloadQueueItem) []DownloadQueueItem
- func (t Module) SanitizePath(path string, allowSeparator bool) string
- func (t *Module) SetDbIO(io DatabaseInterface)
- type ModuleInterface
- type OAuthClient
- type ProxyLoopConfiguration
- type TrackedItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cookie ¶
type Cookie struct { ID int Name string Value string Expiration sql.NullTime Module string Disabled bool }
Cookie contains all the required details to set cookies for domains
func (*Cookie) GetDisplayExpirationDate ¶
GetDisplayExpirationDate returns an empty string if the date is null or else an RFC822 formatted string
type DatabaseInterface ¶
type DatabaseInterface interface { // tracked item storage functionality GetTrackedItems(module ModuleInterface, includeCompleted bool) []*TrackedItem GetFirstOrCreateTrackedItem(uri string, module ModuleInterface) *TrackedItem CreateTrackedItem(uri string, module ModuleInterface) ChangeTrackedItemCompleteStatus(trackedItem *TrackedItem, complete bool) // account storage functionality CreateAccount(user string, password string, module ModuleInterface) GetFirstOrCreateAccount(user string, password string, module ModuleInterface) *Account GetAccount(module ModuleInterface) *Account UpdateTrackedItem(trackedItem *TrackedItem, currentItem string) // OAuth2 client storage functionality CreateOAuthClient(id string, secret string, accessToken string, refreshToken string, module ModuleInterface) GetFirstOrCreateOAuthClient( id string, secret string, accessToken string, refreshToken string, module ModuleInterface, ) *OAuthClient GetOAuthClient(module ModuleInterface) *OAuthClient // cookie storage functionality GetAllCookies(module ModuleInterface) (cookies []*Cookie) GetCookie(name string, module ModuleInterface) *Cookie GetFirstOrCreateCookie(name string, value string, expirationString string, module ModuleInterface) *Cookie CreateCookie(name string, value string, expiration sql.NullTime, module ModuleInterface) UpdateCookie(name string, value string, expirationString string, module ModuleInterface) UpdateCookieDisabledStatus(name string, disabled bool, module ModuleInterface) }
DatabaseInterface of used functions from the application to eventually change the underlying library
type DownloadQueueItem ¶
DownloadQueueItem is a generic struct in case the module doesn't require special actions
type Module ¶
type Module struct { ModuleInterface DbIO DatabaseInterface Session http.SessionInterface Key string RequiresLogin bool LoggedIn bool TriedLogin bool URISchemas []*regexp.Regexp ProxyLoopIndex int }
Module is an implementation to the ModuleInterface to provide basic functions/variables
func (*Module) AddProxyCommands ¶
AddProxyCommands adds the module specific commands for the proxy server
func (*Module) AddProxyLoopCommands ¶
AddProxyLoopCommands adds the proxies sub command for the passed command
func (*Module) GetFileExtension ¶
GetFileExtension retrieves the file extension of a passed uri
func (*Module) GetFileName ¶
GetFileName retrieves the file name of a passed uri
func (*Module) GetProxySettings ¶
func (t *Module) GetProxySettings() (proxySettings *http.ProxySettings)
GetProxySettings returns the proxy settings for the module
func (*Module) GetViperModuleKey ¶
GetViperModuleKey returns the module key without "." characters since they'll ruin the generated tree structure
func (*Module) ModuleKey ¶
ModuleKey returns the key of the module required to use as interface to prevent import cycles
func (*Module) ProcessDownloadQueue ¶
func (t *Module) ProcessDownloadQueue(downloadQueue []DownloadQueueItem, trackedItem *TrackedItem) error
ProcessDownloadQueue processes the default download queue, can be used if the module doesn't require special actions
func (*Module) RegisterURISchema ¶
RegisterURISchema registers the URI schemas of the module to the passed map
func (*Module) ReverseDownloadQueueItems ¶
func (t *Module) ReverseDownloadQueueItems(downloadQueue []DownloadQueueItem) []DownloadQueueItem
ReverseDownloadQueueItems reverses the download queue items to get the oldest items first to be able to interrupt the update process anytime
func (Module) SanitizePath ¶
SanitizePath replaces reserved characters https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words and trims the result
func (*Module) SetDbIO ¶
func (t *Module) SetDbIO(io DatabaseInterface)
SetDbIO sets the database IO implementation
type ModuleInterface ¶
type ModuleInterface interface { // retrieve the module key ModuleKey() string // initializes the registered bare module InitializeModule() // option for the modules to register custom settings/commands AddSettingsCommand(command *cobra.Command) // Login logs us in for the current session if possible/account available Login(account *Account) (success bool) // Parse parses the tracked item Parse(item *TrackedItem) error }
ModuleInterface of used functions from the application for all modules
type OAuthClient ¶
type OAuthClient struct { ID int ClientID string ClientSecret string AccessToken string RefreshToken string Module string Disabled bool }
OAuthClient contains all the required details to create an OAuth client aside from URLs
type ProxyLoopConfiguration ¶
type ProxyLoopConfiguration struct { Loop bool `mapstructure:"loop"` Proxy http.ProxySettings `mapstructure:"proxy"` LoopProxies []http.ProxySettings `mapstructure:"loopproxies"` }
ProxyLoopConfiguration contains the configuration for loop proxy configurations