Replaced all other referenced to twt/twtxt
This commit is contained in:
@@ -7,13 +7,11 @@ import (
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gabstv/merger"
|
||||
"github.com/goccy/go-yaml"
|
||||
"git.mills.io/prologic/spyda/types"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -25,77 +23,50 @@ var (
|
||||
type Settings struct {
|
||||
Name string `yaml:"pod_name"`
|
||||
Description string `yaml:"pod_description"`
|
||||
|
||||
MaxTwtLength int `yaml:"max_twt_length"`
|
||||
|
||||
OpenProfiles bool `yaml:"open_profiles"`
|
||||
OpenRegistrations bool `yaml:"open_registrations"`
|
||||
}
|
||||
|
||||
// Config contains the server configuration parameters
|
||||
type Config struct {
|
||||
Debug bool
|
||||
|
||||
Data string
|
||||
Name string
|
||||
Description string
|
||||
Store string
|
||||
Theme string
|
||||
BaseURL string
|
||||
AdminUser string
|
||||
AdminName string
|
||||
AdminEmail string
|
||||
FeedSources []string
|
||||
RegisterMessage string
|
||||
CookieSecret string
|
||||
TwtPrompts []string
|
||||
TwtsPerPage int
|
||||
MaxUploadSize int64
|
||||
MaxTwtLength int
|
||||
MaxCacheTTL time.Duration
|
||||
MaxCacheItems int
|
||||
MsgsPerPage int
|
||||
OpenProfiles bool
|
||||
OpenRegistrations bool
|
||||
SessionExpiry time.Duration
|
||||
SessionCacheTTL time.Duration
|
||||
TranscoderTimeout time.Duration
|
||||
Data string
|
||||
Name string
|
||||
Description string
|
||||
Store string
|
||||
Theme string
|
||||
BaseURL string
|
||||
AdminUser string
|
||||
AdminPass string
|
||||
AdminName string
|
||||
AdminEmail string
|
||||
|
||||
SearchPrompts []string
|
||||
ResultsPerPage int
|
||||
|
||||
APISessionTime time.Duration
|
||||
SessionExpiry time.Duration
|
||||
SessionCacheTTL time.Duration
|
||||
|
||||
APISigningKey string
|
||||
CookieSecret string
|
||||
MagicLinkSecret string
|
||||
|
||||
SMTPBind string
|
||||
POP3Bind string
|
||||
|
||||
SMTPHost string
|
||||
SMTPPort int
|
||||
SMTPUser string
|
||||
SMTPPass string
|
||||
SMTPFrom string
|
||||
|
||||
MaxFetchLimit int64
|
||||
|
||||
APISessionTime time.Duration
|
||||
APISigningKey string
|
||||
|
||||
baseURL *url.URL
|
||||
|
||||
whitelistedDomains []*regexp.Regexp
|
||||
WhitelistedDomains []string
|
||||
|
||||
// path string
|
||||
}
|
||||
|
||||
var _ types.FmtOpts = (*Config)(nil)
|
||||
|
||||
func (c *Config) IsLocalURL(url string) bool {
|
||||
if NormalizeURL(url) == "" {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(NormalizeURL(url), NormalizeURL(c.BaseURL))
|
||||
}
|
||||
func (c *Config) LocalURL() *url.URL { return c.baseURL }
|
||||
func (c *Config) ExternalURL(nick, uri string) string { return URLForExternalProfile(c, nick, uri) }
|
||||
func (c *Config) UserURL(url string) string { return UserURL(url) }
|
||||
func (c *Config) LocalURL() *url.URL { return c.baseURL }
|
||||
|
||||
// Settings returns a `Settings` struct containing pod settings that can
|
||||
// then be persisted to disk to override some configuration options.
|
||||
@@ -109,28 +80,10 @@ func (c *Config) Settings() *Settings {
|
||||
return settings
|
||||
}
|
||||
|
||||
// WhitelistedDomain returns true if the domain provided is a whiltelisted
|
||||
// domain as per the configuration
|
||||
func (c *Config) WhitelistedDomain(domain string) (bool, bool) {
|
||||
// Always per mit our own domain
|
||||
ourDomain := strings.TrimPrefix(strings.ToLower(c.baseURL.Hostname()), "www.")
|
||||
if domain == ourDomain {
|
||||
return true, true
|
||||
}
|
||||
|
||||
// Check against list of whitelistedDomains (regexes)
|
||||
for _, re := range c.whitelistedDomains {
|
||||
if re.MatchString(domain) {
|
||||
return true, false
|
||||
}
|
||||
}
|
||||
return false, false
|
||||
}
|
||||
|
||||
// RandomTwtPrompt returns a random Twt Prompt for display by the UI
|
||||
func (c *Config) RandomTwtPrompt() string {
|
||||
n := rand.Int() % len(c.TwtPrompts)
|
||||
return c.TwtPrompts[n]
|
||||
// RandomSearchPrompt returns a random Search Prompt for display by the UI
|
||||
func (c *Config) RandomSearchPrompt() string {
|
||||
n := rand.Int() % len(c.SearchPrompts)
|
||||
return c.SearchPrompts[n]
|
||||
}
|
||||
|
||||
// Validate validates the configuration is valid which for the most part
|
||||
|
||||
Reference in New Issue
Block a user