Support server-rendered index.html for all clients. Closes #1871

This commit is contained in:
Gabe Kangas
2022-06-19 16:35:55 -07:00
parent 78c6189c02
commit ff968616ba
5 changed files with 69 additions and 57 deletions

View File

@ -15,7 +15,6 @@ import (
"strings"
"time"
"github.com/mssola/user_agent"
log "github.com/sirupsen/logrus"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
@ -98,34 +97,6 @@ func moveFallback(source, destination string) error {
return nil
}
// IsUserAgentABot returns if a web client user-agent is seen as a bot.
func IsUserAgentABot(userAgent string) bool {
if userAgent == "" {
return false
}
botStrings := []string{
"mastodon",
"pleroma",
"applebot",
"whatsapp",
"matrix",
"synapse",
"element",
"rocket.chat",
"duckduckbot",
}
for _, botString := range botStrings {
if strings.Contains(strings.ToLower(userAgent), botString) {
return true
}
}
ua := user_agent.New(userAgent)
return ua.Bot()
}
// IsUserAgentAPlayer returns if a web client user-agent is seen as a media player.
func IsUserAgentAPlayer(userAgent string) bool {
if userAgent == "" {