Config repository (#3988)
* WIP * fix(test): fix ap test failing * fix: fix unkeyed fields being used * chore(tests): clean up browser tests by splitting out federation UI tests
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
@@ -23,7 +23,8 @@ func SetCustomColorVariableValues(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetCustomColorVariableValues(*values.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetCustomColorVariableValues(*values.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/chat/events"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/authrepository"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/persistence/userrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
@@ -62,7 +63,9 @@ func BanIPAddress(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.BanIPAddress(configValue.Value.(string), "manually added"); err != nil {
|
||||
authRepository := authrepository.Get()
|
||||
|
||||
if err := authRepository.BanIPAddress(configValue.Value.(string), "manually added"); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "error saving IP address ban")
|
||||
return
|
||||
}
|
||||
@@ -82,7 +85,9 @@ func UnBanIPAddress(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.RemoveIPAddressBan(configValue.Value.(string)); err != nil {
|
||||
authRepository := authrepository.Get()
|
||||
|
||||
if err := authRepository.RemoveIPAddressBan(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "error removing IP address ban")
|
||||
return
|
||||
}
|
||||
@@ -92,7 +97,9 @@ func UnBanIPAddress(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// GetIPAddressBans will return all the banned IP addresses.
|
||||
func GetIPAddressBans(w http.ResponseWriter, r *http.Request) {
|
||||
bans, err := data.GetIPAddressBans()
|
||||
authRepository := authrepository.Get()
|
||||
|
||||
bans, err := authRepository.GetIPAddressBans()
|
||||
if err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
@@ -168,11 +175,13 @@ func UpdateUserEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
localIP6Address := "::1"
|
||||
|
||||
// Ban this user's IP address.
|
||||
authRepository := authrepository.Get()
|
||||
|
||||
for _, client := range clients {
|
||||
ipAddress := client.IPAddress
|
||||
if ipAddress != localIP4Address && ipAddress != localIP6Address {
|
||||
reason := fmt.Sprintf("Banning of %s", disconnectedUser.DisplayName)
|
||||
if err := data.BanIPAddress(ipAddress, reason); err != nil {
|
||||
if err := authRepository.BanIPAddress(ipAddress, reason); err != nil {
|
||||
log.Errorln("error banning IP address: ", err)
|
||||
}
|
||||
}
|
||||
@@ -366,7 +375,8 @@ func SetEnableEstablishedChatUserMode(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetChatEstablishedUsersOnlyMode(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetChatEstablishedUsersOnlyMode(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/activitypub/outbox"
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/core/webhooks"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
@@ -44,7 +44,8 @@ func SetTags(w http.ResponseWriter, r *http.Request) {
|
||||
tagStrings = append(tagStrings, strings.TrimLeft(tag.Value.(string), "#"))
|
||||
}
|
||||
|
||||
if err := data.SetServerMetadataTags(tagStrings); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetServerMetadataTags(tagStrings); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -70,8 +71,9 @@ func SetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
value := configValue.Value.(string)
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := data.SetStreamTitle(value); err != nil {
|
||||
if err := configRepository.SetStreamTitle(value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -104,7 +106,8 @@ func SetServerName(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetServerName(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetServerName(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -129,7 +132,8 @@ func SetServerSummary(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetServerSummary(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetServerSummary(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -154,7 +158,8 @@ func SetCustomOfflineMessage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetCustomOfflineMessage(strings.TrimSpace(configValue.Value.(string))); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetCustomOfflineMessage(strings.TrimSpace(configValue.Value.(string))); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -173,7 +178,8 @@ func SetServerWelcomeMessage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetServerWelcomeMessage(strings.TrimSpace(configValue.Value.(string))); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetServerWelcomeMessage(strings.TrimSpace(configValue.Value.(string))); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -192,7 +198,8 @@ func SetExtraPageContent(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetExtraPageBodyContent(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetExtraPageBodyContent(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -211,7 +218,8 @@ func SetAdminPassword(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetAdminPassword(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetAdminPassword(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -247,12 +255,14 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetLogoPath("logo" + extension); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetLogoPath("logo" + extension); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetLogoUniquenessString(shortid.MustGenerate()); err != nil {
|
||||
if err := configRepository.SetLogoUniquenessString(shortid.MustGenerate()); err != nil {
|
||||
log.Error("Error saving logo uniqueness string: ", err)
|
||||
}
|
||||
|
||||
@@ -276,7 +286,8 @@ func SetNSFW(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetNSFW(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetNSFW(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -301,7 +312,8 @@ func SetFfmpegPath(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFfmpegPath(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetFfmpegPath(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -320,12 +332,13 @@ func SetWebServerPort(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
if port, ok := configValue.Value.(float64); ok {
|
||||
if (port < 1) || (port > 65535) {
|
||||
webutils.WriteSimpleResponse(w, false, "Port number must be between 1 and 65535")
|
||||
return
|
||||
}
|
||||
if err := data.SetHTTPPortNumber(port); err != nil {
|
||||
if err := configRepository.SetHTTPPortNumber(port); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -348,9 +361,10 @@ func SetWebServerIP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
if input, ok := configValue.Value.(string); ok {
|
||||
if ip := net.ParseIP(input); ip != nil {
|
||||
if err := data.SetHTTPListenAddress(ip.String()); err != nil {
|
||||
if err := configRepository.SetHTTPListenAddress(ip.String()); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -376,7 +390,8 @@ func SetRTMPServerPort(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetRTMPPortNumber(configValue.Value.(float64)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetRTMPPortNumber(configValue.Value.(float64)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -415,10 +430,12 @@ func SetServerURL(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
// Trim any trailing slash
|
||||
serverURL := strings.TrimRight(rawValue, "/")
|
||||
|
||||
if err := data.SetServerURL(serverURL); err != nil {
|
||||
if err := configRepository.SetServerURL(serverURL); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -437,7 +454,9 @@ func SetSocketHostOverride(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetWebsocketOverrideHost(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetWebsocketOverrideHost(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -456,7 +475,9 @@ func SetDirectoryEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetDirectoryEnabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetDirectoryEnabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -474,7 +495,9 @@ func SetStreamLatencyLevel(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetStreamLatencyLevel(configValue.Value.(float64)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetStreamLatencyLevel(configValue.Value.(float64)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "error setting stream latency "+err.Error())
|
||||
return
|
||||
}
|
||||
@@ -521,7 +544,8 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := data.SetS3Config(newS3Config.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetS3Config(newS3Config.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -545,7 +569,8 @@ func SetStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetStreamOutputVariants(videoVariants.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetStreamOutputVariants(videoVariants.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update video config with provided values "+err.Error())
|
||||
return
|
||||
}
|
||||
@@ -570,7 +595,8 @@ func SetSocialHandles(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetSocialHandles(socialHandles.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetSocialHandles(socialHandles.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update social handles with provided values")
|
||||
return
|
||||
}
|
||||
@@ -596,7 +622,8 @@ func SetChatDisabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetChatDisabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetChatDisabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -616,7 +643,8 @@ func SetVideoCodec(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetVideoCodec(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetVideoCodec(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update codec")
|
||||
return
|
||||
}
|
||||
@@ -637,7 +665,8 @@ func SetExternalActions(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetExternalActions(actions.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetExternalActions(actions.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update external actions with provided values")
|
||||
return
|
||||
}
|
||||
@@ -653,7 +682,8 @@ func SetCustomStyles(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetCustomStyles(customStyles.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetCustomStyles(customStyles.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -669,7 +699,8 @@ func SetCustomJavascript(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetCustomJavascript(customJavascript.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetCustomJavascript(customJavascript.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -687,7 +718,8 @@ func SetForbiddenUsernameList(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetForbiddenUsernameList(*request.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetForbiddenUsernameList(*request.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -705,7 +737,8 @@ func SetSuggestedUsernameList(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetSuggestedUsernamesList(*request.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetSuggestedUsernamesList(*request.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -725,7 +758,8 @@ func SetChatJoinMessagesEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetChatJoinMessagesEnabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetChatJoinMessagesEnabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -745,7 +779,8 @@ func SetHideViewerCount(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetHideViewerCount(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetHideViewerCount(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -765,7 +800,8 @@ func SetDisableSearchIndexing(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetDisableSearchIndexing(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetDisableSearchIndexing(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -787,7 +823,8 @@ func SetVideoServingEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetVideoServingEndpoint(value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetVideoServingEndpoint(value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -806,7 +843,8 @@ func SetChatSpamProtectionEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetChatSpamProtectionEnabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetChatSpamProtectionEnabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -824,7 +862,8 @@ func SetChatSlurFilterEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetChatSlurFilterEnabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetChatSlurFilterEnabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -900,7 +939,8 @@ func SetStreamKeys(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := data.SetStreamKeys(streamKeys.Value); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetStreamKeys(streamKeys.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/owncast/owncast/activitypub"
|
||||
"github.com/owncast/owncast/activitypub/outbox"
|
||||
"github.com/owncast/owncast/activitypub/persistence"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
|
||||
@@ -46,7 +46,9 @@ func SetFederationEnabled(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFederationEnabled(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetFederationEnabled(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -64,7 +66,9 @@ func SetFederationActivityPrivate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFederationIsPrivate(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
if err := configRepository.SetFederationIsPrivate(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -89,7 +93,8 @@ func SetFederationShowEngagement(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFederationShowEngagement(configValue.Value.(bool)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetFederationShowEngagement(configValue.Value.(bool)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -107,7 +112,8 @@ func SetFederationUsername(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFederationUsername(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetFederationUsername(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -126,7 +132,8 @@ func SetFederationGoLiveMessage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetFederationGoLiveMessage(configValue.Value.(string)); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetFederationGoLiveMessage(configValue.Value.(string)); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
@@ -151,7 +158,8 @@ func SetFederationBlockDomains(w http.ResponseWriter, r *http.Request) {
|
||||
domainStrings = append(domainStrings, domain.Value.(string))
|
||||
}
|
||||
|
||||
if err := data.SetBlockedFederatedDomains(domainStrings); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetBlockedFederatedDomains(domainStrings); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/activitypub/persistence"
|
||||
"github.com/owncast/owncast/activitypub/requests"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
@@ -36,7 +36,8 @@ func ApproveFollower(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
localAccountName := data.GetDefaultFederationUsername()
|
||||
configRepository := configrepository.Get()
|
||||
localAccountName := configRepository.GetDefaultFederationUsername()
|
||||
|
||||
followRequest, err := persistence.GetFollower(*approval.ActorIRI)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
|
||||
@@ -19,6 +19,8 @@ func SetDiscordNotificationConfiguration(w http.ResponseWriter, r *http.Request)
|
||||
Value models.DiscordConfiguration `json:"value"`
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
var config request
|
||||
if err := decoder.Decode(&config); err != nil {
|
||||
@@ -26,7 +28,7 @@ func SetDiscordNotificationConfiguration(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetDiscordConfig(config.Value); err != nil {
|
||||
if err := configRepository.SetDiscordConfig(config.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update discord config with provided values")
|
||||
return
|
||||
}
|
||||
@@ -44,6 +46,7 @@ func SetBrowserNotificationConfiguration(w http.ResponseWriter, r *http.Request)
|
||||
Value models.BrowserNotificationConfiguration `json:"value"`
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
decoder := json.NewDecoder(r.Body)
|
||||
var config request
|
||||
if err := decoder.Decode(&config); err != nil {
|
||||
@@ -51,7 +54,7 @@ func SetBrowserNotificationConfiguration(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
if err := data.SetBrowserPushConfig(config.Value); err != nil {
|
||||
if err := configRepository.SetBrowserPushConfig(config.Value); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "unable to update browser push config with provided values")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/core/transcoder"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -15,12 +15,13 @@ import (
|
||||
|
||||
// GetServerConfig gets the config details of the server.
|
||||
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
||||
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||
usernameBlocklist := data.GetForbiddenUsernameList()
|
||||
usernameSuggestions := data.GetSuggestedUsernamesList()
|
||||
configRepository := configrepository.Get()
|
||||
ffmpeg := utils.ValidatedFfmpegPath(configRepository.GetFfMpegPath())
|
||||
usernameBlocklist := configRepository.GetForbiddenUsernameList()
|
||||
usernameSuggestions := configRepository.GetSuggestedUsernamesList()
|
||||
|
||||
videoQualityVariants := make([]models.StreamOutputVariant, 0)
|
||||
for _, variant := range data.GetStreamOutputVariants() {
|
||||
for _, variant := range configRepository.GetStreamOutputVariants() {
|
||||
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
||||
Name: variant.GetName(),
|
||||
IsAudioPassthrough: variant.GetIsAudioPassthrough(),
|
||||
@@ -35,61 +36,61 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
response := serverConfigAdminResponse{
|
||||
InstanceDetails: webConfigResponse{
|
||||
Name: data.GetServerName(),
|
||||
Summary: data.GetServerSummary(),
|
||||
Tags: data.GetServerMetadataTags(),
|
||||
ExtraPageContent: data.GetExtraPageBodyContent(),
|
||||
StreamTitle: data.GetStreamTitle(),
|
||||
WelcomeMessage: data.GetServerWelcomeMessage(),
|
||||
OfflineMessage: data.GetCustomOfflineMessage(),
|
||||
Logo: data.GetLogoPath(),
|
||||
SocialHandles: data.GetSocialHandles(),
|
||||
NSFW: data.GetNSFW(),
|
||||
CustomStyles: data.GetCustomStyles(),
|
||||
CustomJavascript: data.GetCustomJavascript(),
|
||||
AppearanceVariables: data.GetCustomColorVariableValues(),
|
||||
Name: configRepository.GetServerName(),
|
||||
Summary: configRepository.GetServerSummary(),
|
||||
Tags: configRepository.GetServerMetadataTags(),
|
||||
ExtraPageContent: configRepository.GetExtraPageBodyContent(),
|
||||
StreamTitle: configRepository.GetStreamTitle(),
|
||||
WelcomeMessage: configRepository.GetServerWelcomeMessage(),
|
||||
OfflineMessage: configRepository.GetCustomOfflineMessage(),
|
||||
Logo: configRepository.GetLogoPath(),
|
||||
SocialHandles: configRepository.GetSocialHandles(),
|
||||
NSFW: configRepository.GetNSFW(),
|
||||
CustomStyles: configRepository.GetCustomStyles(),
|
||||
CustomJavascript: configRepository.GetCustomJavascript(),
|
||||
AppearanceVariables: configRepository.GetCustomColorVariableValues(),
|
||||
},
|
||||
FFmpegPath: ffmpeg,
|
||||
AdminPassword: data.GetAdminPassword(),
|
||||
StreamKeys: data.GetStreamKeys(),
|
||||
AdminPassword: configRepository.GetAdminPassword(),
|
||||
StreamKeys: configRepository.GetStreamKeys(),
|
||||
StreamKeyOverridden: config.TemporaryStreamKey != "",
|
||||
WebServerPort: config.WebServerPort,
|
||||
WebServerIP: config.WebServerIP,
|
||||
RTMPServerPort: data.GetRTMPPortNumber(),
|
||||
ChatDisabled: data.GetChatDisabled(),
|
||||
ChatJoinMessagesEnabled: data.GetChatJoinPartMessagesEnabled(),
|
||||
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
||||
VideoServingEndpoint: data.GetVideoServingEndpoint(),
|
||||
ChatEstablishedUserMode: data.GetChatEstbalishedUsersOnlyMode(),
|
||||
ChatSpamProtectionEnabled: data.GetChatSpamProtectionEnabled(),
|
||||
ChatSlurFilterEnabled: data.GetChatSlurFilterEnabled(),
|
||||
HideViewerCount: data.GetHideViewerCount(),
|
||||
DisableSearchIndexing: data.GetDisableSearchIndexing(),
|
||||
RTMPServerPort: configRepository.GetRTMPPortNumber(),
|
||||
ChatDisabled: configRepository.GetChatDisabled(),
|
||||
ChatJoinMessagesEnabled: configRepository.GetChatJoinPartMessagesEnabled(),
|
||||
SocketHostOverride: configRepository.GetWebsocketOverrideHost(),
|
||||
VideoServingEndpoint: configRepository.GetVideoServingEndpoint(),
|
||||
ChatEstablishedUserMode: configRepository.GetChatEstbalishedUsersOnlyMode(),
|
||||
ChatSpamProtectionEnabled: configRepository.GetChatSpamProtectionEnabled(),
|
||||
ChatSlurFilterEnabled: configRepository.GetChatSlurFilterEnabled(),
|
||||
HideViewerCount: configRepository.GetHideViewerCount(),
|
||||
DisableSearchIndexing: configRepository.GetDisableSearchIndexing(),
|
||||
VideoSettings: videoSettings{
|
||||
VideoQualityVariants: videoQualityVariants,
|
||||
LatencyLevel: data.GetStreamLatencyLevel().Level,
|
||||
LatencyLevel: configRepository.GetStreamLatencyLevel().Level,
|
||||
},
|
||||
YP: yp{
|
||||
Enabled: data.GetDirectoryEnabled(),
|
||||
InstanceURL: data.GetServerURL(),
|
||||
Enabled: configRepository.GetDirectoryEnabled(),
|
||||
InstanceURL: configRepository.GetServerURL(),
|
||||
},
|
||||
S3: data.GetS3Config(),
|
||||
ExternalActions: data.GetExternalActions(),
|
||||
S3: configRepository.GetS3Config(),
|
||||
ExternalActions: configRepository.GetExternalActions(),
|
||||
SupportedCodecs: transcoder.GetCodecs(ffmpeg),
|
||||
VideoCodec: data.GetVideoCodec(),
|
||||
VideoCodec: configRepository.GetVideoCodec(),
|
||||
ForbiddenUsernames: usernameBlocklist,
|
||||
SuggestedUsernames: usernameSuggestions,
|
||||
Federation: federationConfigResponse{
|
||||
Enabled: data.GetFederationEnabled(),
|
||||
IsPrivate: data.GetFederationIsPrivate(),
|
||||
Username: data.GetFederationUsername(),
|
||||
GoLiveMessage: data.GetFederationGoLiveMessage(),
|
||||
ShowEngagement: data.GetFederationShowEngagement(),
|
||||
BlockedDomains: data.GetBlockedFederatedDomains(),
|
||||
Enabled: configRepository.GetFederationEnabled(),
|
||||
IsPrivate: configRepository.GetFederationIsPrivate(),
|
||||
Username: configRepository.GetFederationUsername(),
|
||||
GoLiveMessage: configRepository.GetFederationGoLiveMessage(),
|
||||
ShowEngagement: configRepository.GetFederationShowEngagement(),
|
||||
BlockedDomains: configRepository.GetBlockedFederatedDomains(),
|
||||
},
|
||||
Notifications: notificationsConfigResponse{
|
||||
Discord: data.GetDiscordConfig(),
|
||||
Browser: data.GetBrowserPushConfig(),
|
||||
Discord: configRepository.GetDiscordConfig(),
|
||||
Browser: configRepository.GetBrowserPushConfig(),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,17 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/metrics"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Status gets the details of the inbound broadcaster.
|
||||
func Status(w http.ResponseWriter, r *http.Request) {
|
||||
configRepository := configrepository.Get()
|
||||
|
||||
broadcaster := core.GetBroadcaster()
|
||||
status := core.GetStatus()
|
||||
currentBroadcast := core.GetCurrentBroadcast()
|
||||
@@ -27,7 +29,7 @@ func Status(w http.ResponseWriter, r *http.Request) {
|
||||
OverallPeakViewerCount: status.OverallMaxViewerCount,
|
||||
SessionPeakViewerCount: status.SessionMaxViewerCount,
|
||||
VersionNumber: status.VersionNumber,
|
||||
StreamTitle: data.GetStreamTitle(),
|
||||
StreamTitle: configRepository.GetStreamTitle(),
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/metrics"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -40,8 +40,9 @@ func GetVideoPlaybackMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
availableBitrates = append(availableBitrates, variants.VideoBitrate)
|
||||
}
|
||||
} else {
|
||||
segmentLength = data.GetStreamLatencyLevel().SecondsPerSegment
|
||||
for _, variants := range data.GetStreamOutputVariants() {
|
||||
configRepository := configrepository.Get()
|
||||
segmentLength = configRepository.GetStreamLatencyLevel().SecondsPerSegment
|
||||
for _, variants := range configRepository.GetStreamOutputVariants() {
|
||||
availableBitrates = append(availableBitrates, variants.VideoBitrate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package admin
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
// ResetYPRegistration will clear the YP protocol registration key.
|
||||
func ResetYPRegistration(w http.ResponseWriter, r *http.Request) {
|
||||
log.Traceln("Resetting YP registration key")
|
||||
if err := data.SetDirectoryRegistrationKey(""); err != nil {
|
||||
configRepository := configrepository.Get()
|
||||
if err := configRepository.SetDirectoryRegistrationKey(""); err != nil {
|
||||
log.Errorln(err)
|
||||
webutils.WriteSimpleResponse(w, false, err.Error())
|
||||
return
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/owncast/owncast/activitypub"
|
||||
fediverseauth "github.com/owncast/owncast/auth/fediverse"
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/persistence/userrepository"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -39,7 +39,8 @@ func RegisterFediverseOTPRequest(u models.User, w http.ResponseWriter, r *http.R
|
||||
return
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("<p>One-time code from %s: %s. If you did not request this message please ignore or block.</p>", data.GetServerName(), reg.Code)
|
||||
configRepository := configrepository.Get()
|
||||
msg := fmt.Sprintf("<p>One-time code from %s: %s. If you did not request this message please ignore or block.</p>", configRepository.GetServerName(), reg.Code)
|
||||
if err := activitypub.SendDirectFederatedMessage(msg, reg.Account); err != nil {
|
||||
webutils.WriteSimpleResponse(w, false, "Could not send code to fediverse: "+err.Error())
|
||||
return
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/persistence/userrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
@@ -105,7 +105,8 @@ func RegisterAnonymousChatUser(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func generateDisplayName() string {
|
||||
suggestedUsernamesList := data.GetSuggestedUsernamesList()
|
||||
configRepository := configrepository.Get()
|
||||
suggestedUsernamesList := configRepository.GetSuggestedUsernamesList()
|
||||
minSuggestedUsernamePoolLength := 10
|
||||
|
||||
if len(suggestedUsernamesList) >= minSuggestedUsernamePoolLength {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/activitypub"
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
@@ -73,9 +73,10 @@ func GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func getConfigResponse() webConfigResponse {
|
||||
pageContent := utils.RenderPageContentMarkdown(data.GetExtraPageBodyContent())
|
||||
offlineMessage := utils.RenderSimpleMarkdown(data.GetCustomOfflineMessage())
|
||||
socialHandles := data.GetSocialHandles()
|
||||
configRepository := configrepository.Get()
|
||||
pageContent := utils.RenderPageContentMarkdown(configRepository.GetExtraPageBodyContent())
|
||||
offlineMessage := utils.RenderSimpleMarkdown(configRepository.GetCustomOfflineMessage())
|
||||
socialHandles := configRepository.GetSocialHandles()
|
||||
for i, handle := range socialHandles {
|
||||
platform := models.GetSocialHandle(handle.Platform)
|
||||
if platform != nil {
|
||||
@@ -84,16 +85,16 @@ func getConfigResponse() webConfigResponse {
|
||||
}
|
||||
}
|
||||
|
||||
serverSummary := data.GetServerSummary()
|
||||
serverSummary := configRepository.GetServerSummary()
|
||||
|
||||
var federationResponse federationConfigResponse
|
||||
federationEnabled := data.GetFederationEnabled()
|
||||
federationEnabled := configRepository.GetFederationEnabled()
|
||||
|
||||
followerCount, _ := activitypub.GetFollowerCount()
|
||||
if federationEnabled {
|
||||
serverURLString := data.GetServerURL()
|
||||
serverURLString := configRepository.GetServerURL()
|
||||
serverURL, _ := url.Parse(serverURLString)
|
||||
account := fmt.Sprintf("%s@%s", data.GetDefaultFederationUsername(), serverURL.Host)
|
||||
account := fmt.Sprintf("%s@%s", configRepository.GetDefaultFederationUsername(), serverURL.Host)
|
||||
federationResponse = federationConfigResponse{
|
||||
Enabled: federationEnabled,
|
||||
FollowerCount: int(followerCount),
|
||||
@@ -101,8 +102,8 @@ func getConfigResponse() webConfigResponse {
|
||||
}
|
||||
}
|
||||
|
||||
browserPushEnabled := data.GetBrowserPushConfig().Enabled
|
||||
browserPushPublicKey, err := data.GetBrowserPushPublicKey()
|
||||
browserPushEnabled := configRepository.GetBrowserPushConfig().Enabled
|
||||
browserPushPublicKey, err := configRepository.GetBrowserPushPublicKey()
|
||||
if err != nil {
|
||||
log.Errorln("unable to fetch browser push notifications public key", err)
|
||||
browserPushEnabled = false
|
||||
@@ -116,31 +117,31 @@ func getConfigResponse() webConfigResponse {
|
||||
}
|
||||
|
||||
authenticationResponse := authenticationConfigResponse{
|
||||
IndieAuthEnabled: data.GetServerURL() != "",
|
||||
IndieAuthEnabled: configRepository.GetServerURL() != "",
|
||||
}
|
||||
|
||||
return webConfigResponse{
|
||||
Name: data.GetServerName(),
|
||||
Name: configRepository.GetServerName(),
|
||||
Summary: serverSummary,
|
||||
OfflineMessage: offlineMessage,
|
||||
Logo: "/logo",
|
||||
Tags: data.GetServerMetadataTags(),
|
||||
Tags: configRepository.GetServerMetadataTags(),
|
||||
Version: config.GetReleaseString(),
|
||||
NSFW: data.GetNSFW(),
|
||||
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
||||
NSFW: configRepository.GetNSFW(),
|
||||
SocketHostOverride: configRepository.GetWebsocketOverrideHost(),
|
||||
ExtraPageContent: pageContent,
|
||||
StreamTitle: data.GetStreamTitle(),
|
||||
StreamTitle: configRepository.GetStreamTitle(),
|
||||
SocialHandles: socialHandles,
|
||||
ChatDisabled: data.GetChatDisabled(),
|
||||
ChatSpamProtectionDisabled: data.GetChatSpamProtectionEnabled(),
|
||||
ExternalActions: data.GetExternalActions(),
|
||||
CustomStyles: data.GetCustomStyles(),
|
||||
ChatDisabled: configRepository.GetChatDisabled(),
|
||||
ChatSpamProtectionDisabled: configRepository.GetChatSpamProtectionEnabled(),
|
||||
ExternalActions: configRepository.GetExternalActions(),
|
||||
CustomStyles: configRepository.GetCustomStyles(),
|
||||
MaxSocketPayloadSize: config.MaxSocketPayloadSize,
|
||||
Federation: federationResponse,
|
||||
Notifications: notificationsResponse,
|
||||
Authentication: authenticationResponse,
|
||||
AppearanceVariables: data.GetCustomColorVariableValues(),
|
||||
HideViewerCount: data.GetHideViewerCount(),
|
||||
AppearanceVariables: configRepository.GetCustomColorVariableValues(),
|
||||
HideViewerCount: configRepository.GetHideViewerCount(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
)
|
||||
|
||||
// ServeCustomJavascript will serve optional custom Javascript.
|
||||
func ServeCustomJavascript(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/javascript; charset=utf-8")
|
||||
|
||||
js := data.GetCustomJavascript()
|
||||
configRepository := configrepository.Get()
|
||||
js := configRepository.GetCustomJavascript()
|
||||
_, _ = w.Write([]byte(js))
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
)
|
||||
@@ -29,7 +29,8 @@ func HandleHLSRequest(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// If using external storage then only allow requests for the
|
||||
// master playlist at stream.m3u8, no variants or segments.
|
||||
if data.GetS3Config().Enabled && relativePath != "stream.m3u8" {
|
||||
configRepository := configrepository.Get()
|
||||
if configRepository.GetS3Config().Enabled && relativePath != "stream.m3u8" {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/cache"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/static"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
@@ -86,11 +86,12 @@ func renderIndexHtml(w http.ResponseWriter, nonce string) {
|
||||
return
|
||||
}
|
||||
|
||||
configRepository := configrepository.Get()
|
||||
content := serverSideContent{
|
||||
Name: data.GetServerName(),
|
||||
Summary: data.GetServerSummary(),
|
||||
RequestedURL: fmt.Sprintf("%s%s", data.GetServerURL(), "/"),
|
||||
TagsString: strings.Join(data.GetServerMetadataTags(), ","),
|
||||
Name: configRepository.GetServerName(),
|
||||
Summary: configRepository.GetServerSummary(),
|
||||
RequestedURL: fmt.Sprintf("%s%s", configRepository.GetServerURL(), "/"),
|
||||
TagsString: strings.Join(configRepository.GetServerMetadataTags(), ","),
|
||||
ThumbnailURL: "thumbnail.jpg",
|
||||
Thumbnail: "thumbnail.jpg",
|
||||
Image: "logo/external",
|
||||
@@ -145,8 +146,8 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
scheme := "http"
|
||||
|
||||
if siteURL := data.GetServerURL(); siteURL != "" {
|
||||
configRepository := configrepository.Get()
|
||||
if siteURL := configRepository.GetServerURL(); siteURL != "" {
|
||||
if parsed, err := url.Parse(siteURL); err == nil && parsed.Scheme != "" {
|
||||
scheme = parsed.Scheme
|
||||
}
|
||||
@@ -177,16 +178,16 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
|
||||
thumbnailURL = imageURL.String()
|
||||
}
|
||||
|
||||
tagsString := strings.Join(data.GetServerMetadataTags(), ",")
|
||||
tagsString := strings.Join(configRepository.GetServerMetadataTags(), ",")
|
||||
metadata := MetadataPage{
|
||||
Name: data.GetServerName(),
|
||||
Name: configRepository.GetServerName(),
|
||||
RequestedURL: fullURL.String(),
|
||||
Image: imageURL.String(),
|
||||
Summary: data.GetServerSummary(),
|
||||
Summary: configRepository.GetServerSummary(),
|
||||
Thumbnail: thumbnailURL,
|
||||
TagsString: tagsString,
|
||||
Tags: data.GetServerMetadataTags(),
|
||||
SocialHandles: data.GetSocialHandles(),
|
||||
Tags: configRepository.GetServerMetadataTags(),
|
||||
SocialHandles: configRepository.GetSocialHandles(),
|
||||
}
|
||||
|
||||
// Cache the rendered HTML
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/static"
|
||||
"github.com/owncast/owncast/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -17,7 +17,8 @@ var _hasWarnedSVGLogo = false
|
||||
|
||||
// GetLogo will return the logo image as a response.
|
||||
func GetLogo(w http.ResponseWriter, r *http.Request) {
|
||||
imageFilename := data.GetLogoPath()
|
||||
configRepository := configrepository.Get()
|
||||
imageFilename := configRepository.GetLogoPath()
|
||||
if imageFilename == "" {
|
||||
returnDefault(w)
|
||||
return
|
||||
@@ -47,7 +48,8 @@ func GetLogo(w http.ResponseWriter, r *http.Request) {
|
||||
// Used for sharing to external social networks that generally
|
||||
// don't support SVG.
|
||||
func GetCompatibleLogo(w http.ResponseWriter, r *http.Request) {
|
||||
imageFilename := data.GetLogoPath()
|
||||
configRepository := configrepository.Get()
|
||||
imageFilename := configRepository.GetLogoPath()
|
||||
|
||||
// If the logo image is not a SVG then we can return it
|
||||
// without any problems.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/owncast/owncast/activitypub/webfinger"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/webserver/handlers/generated"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
@@ -31,8 +31,9 @@ func RemoteFollow(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
localActorPath, _ := url.Parse(data.GetServerURL())
|
||||
localActorPath.Path = fmt.Sprintf("/federation/user/%s", data.GetDefaultFederationUsername())
|
||||
configRepository := configrepository.Get()
|
||||
localActorPath, _ := url.Parse(configRepository.GetServerURL())
|
||||
localActorPath.Path = fmt.Sprintf("/federation/user/%s", configRepository.GetDefaultFederationUsername())
|
||||
var template string
|
||||
links, err := webfinger.GetWebfingerLinks(*request.Account)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
)
|
||||
|
||||
// GetRobotsDotTxt returns the contents of our robots.txt.
|
||||
@@ -16,7 +16,8 @@ func GetRobotsDotTxt(w http.ResponseWriter, r *http.Request) {
|
||||
"Disallow: /api",
|
||||
}
|
||||
|
||||
if data.GetDisableSearchIndexing() {
|
||||
configRepository := configrepository.Get()
|
||||
if configRepository.GetDisableSearchIndexing() {
|
||||
contents = append(contents, "Disallow: /")
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
"github.com/owncast/owncast/webserver/router/middleware"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
@@ -34,7 +34,8 @@ func getStatusResponse() webStatusResponse {
|
||||
VersionNumber: status.VersionNumber,
|
||||
StreamTitle: status.StreamTitle,
|
||||
}
|
||||
if !data.GetHideViewerCount() {
|
||||
configRepository := configrepository.Get()
|
||||
if !configRepository.GetHideViewerCount() {
|
||||
response.ViewerCount = status.ViewerCount
|
||||
}
|
||||
return response
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
webutils "github.com/owncast/owncast/webserver/utils"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,8 @@ type variantsResponse struct {
|
||||
|
||||
// GetVideoStreamOutputVariants will return the video variants available.
|
||||
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
|
||||
outputVariants := data.GetStreamOutputVariants()
|
||||
configRepository := configrepository.Get()
|
||||
outputVariants := configRepository.GetStreamOutputVariants()
|
||||
|
||||
streamSortVariants := make([]variantsSort, len(outputVariants))
|
||||
for i, variant := range outputVariants {
|
||||
|
||||
@@ -4,15 +4,16 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
)
|
||||
|
||||
// RequireActivityPubOrRedirect will validate the requested content types and
|
||||
// redirect to the main Owncast page if it doesn't match.
|
||||
func RequireActivityPubOrRedirect(handler http.HandlerFunc) http.HandlerFunc {
|
||||
configRepository := configrepository.Get()
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !data.GetFederationEnabled() {
|
||||
if !configRepository.GetFederationEnabled() {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/models"
|
||||
"github.com/owncast/owncast/persistence/authrepository"
|
||||
"github.com/owncast/owncast/persistence/configrepository"
|
||||
"github.com/owncast/owncast/persistence/userrepository"
|
||||
"github.com/owncast/owncast/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -21,9 +22,10 @@ type UserAccessTokenHandlerFunc func(models.User, http.ResponseWriter, *http.Req
|
||||
// RequireAdminAuth wraps a handler requiring HTTP basic auth for it using the given
|
||||
// the stream key as the password and and a hardcoded "admin" for username.
|
||||
func RequireAdminAuth(handler http.HandlerFunc) http.HandlerFunc {
|
||||
configRepository := configrepository.Get()
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
username := "admin"
|
||||
password := data.GetAdminPassword()
|
||||
password := configRepository.GetAdminPassword()
|
||||
realm := "Owncast Authenticated Request"
|
||||
|
||||
// Alow CORS only for localhost:3000 to support Owncast development.
|
||||
@@ -102,6 +104,7 @@ func RequireExternalAPIAccessToken(scope string, handler ExternalAccessTokenHand
|
||||
// RequireUserAccessToken will validate a provided user's access token and make sure the associated user is enabled.
|
||||
// Not to be used for validating 3rd party access.
|
||||
func RequireUserAccessToken(handler UserAccessTokenHandlerFunc) http.HandlerFunc {
|
||||
authRepository := authrepository.Get()
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
accessToken := r.URL.Query().Get("accessToken")
|
||||
if accessToken == "" {
|
||||
@@ -111,7 +114,7 @@ func RequireUserAccessToken(handler UserAccessTokenHandlerFunc) http.HandlerFunc
|
||||
|
||||
ipAddress := utils.GetIPAddressFromRequest(r)
|
||||
// Check if this client's IP address is banned.
|
||||
if blocked, err := data.IsIPAddressBanned(ipAddress); blocked {
|
||||
if blocked, err := authRepository.IsIPAddressBanned(ipAddress); blocked {
|
||||
log.Debugln("Client ip address has been blocked. Rejecting.")
|
||||
accessDenied(w)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user