Remove a bunch more cruft

This commit is contained in:
James Mills
2022-10-05 11:19:27 +10:00
parent a07f747eb1
commit 2ba2451108
9 changed files with 10 additions and 85 deletions

View File

@@ -7,21 +7,12 @@ import (
"net/url"
"strings"
"time"
"github.com/gabstv/merger"
log "github.com/sirupsen/logrus"
)
var (
ErrConfigPathMissing = errors.New("error: config file missing")
)
// Settings contains Pod Settings that can be customised via the Web UI
type Settings struct {
Name string `yaml:"pod_name"`
Description string `yaml:"pod_description"`
}
// Config contains the server configuration parameters
type Config struct {
Debug bool
@@ -59,18 +50,6 @@ func (c *Config) IsLocalURL(url string) bool {
}
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.
func (c *Config) Settings() *Settings {
settings := &Settings{}
if err := merger.MergeOverwrite(settings, c); err != nil {
log.WithError(err).Warn("error creating pod settings")
}
return settings
}
// RandomSearchPrompt returns a random Search Prompt for display by the UI
func (c *Config) RandomSearchPrompt() string {
n := rand.Int() % len(c.SearchPrompts)

View File

@@ -23,9 +23,7 @@ const (
// DefaultBaseURL is the default Base URL for the app used to construct feed URLs
DefaultBaseURL = "http://0.0.0.0:8000"
// DefaultAdminXXX is the default admin user / pod operator
DefaultAdminUser = "admin"
DefaultAdminPass = "admiN"
// DefaultAdminXXX is the default admin user / operator
DefaultAdminName = "Administrator"
DefaultAdminEmail = "support@spyda.dev"
@@ -47,27 +45,15 @@ const (
// DefaultResultsPerPage is the server's default results per page to display
DefaultResultsPerPage = 10
// DefaultSessionCacheTTL is the server's default session cache ttl
DefaultSessionCacheTTL = 1 * time.Hour
// DefaultSessionExpiry is the server's default session expiry time
DefaultSessionExpiry = 240 * time.Hour // 10 days
// DefaultMagicLinkSecret is the jwt magic link secret
DefaultMagicLinkSecret = InvalidConfigValue
// Default SMTP configuration
DefaultSMTPHost = "smtp.gmail.com"
DefaultSMTPPort = 587
DefaultSMTPUser = InvalidConfigValue
DefaultSMTPPass = InvalidConfigValue
DefaultSMTPFrom = InvalidConfigValue
// DefaultAPISessionTime is the server's default session time for API tokens
DefaultAPISessionTime = 240 * time.Hour // 10 days
// DefaultAPISigningKey is the default API JWT signing key for tokens
DefaultAPISigningKey = InvalidConfigValue
)
var (
@@ -146,7 +132,7 @@ func WithBaseURL(baseURL string) Option {
}
}
// WithAdminName sets the Admin name used to identify the pod operator
// WithAdminName sets the Admin name used to identify the operator
func WithAdminName(adminName string) Option {
return func(cfg *Config) error {
cfg.AdminName = adminName
@@ -154,7 +140,7 @@ func WithAdminName(adminName string) Option {
}
}
// WithAdminEmail sets the Admin email used to contact the pod operator
// WithAdminEmail sets the Admin email used to contact the operator
func WithAdminEmail(adminEmail string) Option {
return func(cfg *Config) error {
cfg.AdminEmail = adminEmail

View File

@@ -1,6 +1,3 @@
// Copyright 2020-present Yarn.social
// SPDX-License-Identifier: AGPL-3.0-or-later
package internal
import (

View File

@@ -1,7 +1,6 @@
package internal
import (
"fmt"
"net/http"
"strings"
@@ -97,10 +96,7 @@ func (s *Server) SupportHandler() httprouter.Handle {
log.Infof("support message email sent for %s", email)
ctx.Error = false
ctx.Message = fmt.Sprintf(
"Thank you for your message! Pod operator %s will get back to you soon!",
s.config.AdminName,
)
ctx.Message = "Thank you for your message! We will get back to you soon!"
s.render("error", w, ctx)
}
}

View File

@@ -3,12 +3,6 @@
<div>
{{ .Content }}
<hr />
<footer class="container">
This is a <a href="https://twt.social">Twt.Social</a> pod.
If you would like your own pod, please contact <a href="https://twt.social/support">support</a>.
::
<a href="https://github.com/jointwt/twtxt/edit/master/internal/pages/{{ .Page }}.md">Edit on github</a>
</footer>
</div>
</article>
{{ end }}

View File

@@ -325,7 +325,7 @@ func NormalizeURL(url string) string {
}
// RedirectRefererURL constructs a Redirect URL from the given Request URL
// and possibly Referer, if the Referer's Base URL matches the Pod's Base URL
// and possibly Referer, if the Referer's Base URL matches the Server's Base URL
// will return the Referer URL otherwise the defaultURL. This is primarily used
// to redirect a user from a successful /login back to the page they were on.
func RedirectRefererURL(r *http.Request, conf *Config, defaultURL string) string {