Force uniqueness with previews and logos on the fediverse. Closes #1777 and closes #1776

This commit is contained in:
Gabe Kangas
2022-03-17 13:09:38 -07:00
parent dc16eafea4
commit d1e39c4c1e
5 changed files with 33 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import (
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
"github.com/teris-io/shortid"
)
// ConfigValue is a container object that holds a value, is encoded, and saved to the database.
@ -242,7 +243,7 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
}
imgPath := filepath.Join("data", "logo"+extension)
if err := os.WriteFile(imgPath, bytes, 0600); err != nil {
if err := os.WriteFile(imgPath, bytes, 0o600); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
@ -252,6 +253,10 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
return
}
if err := data.SetLogoUniquenessString(shortid.MustGenerate()); err != nil {
log.Error("Error saving logo uniqueness string: ", err)
}
// Update Fediverse followers about this change.
if err := outbox.UpdateFollowersWithAccountUpdates(); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())