This commit is contained in:
parent
dc16eafea4
commit
d1e39c4c1e
@ -161,8 +161,10 @@ func MakeServiceForAccount(accountName string) vocab.ActivityStreamsService {
|
||||
// Profile properties
|
||||
|
||||
// Avatar
|
||||
uniquenessString := data.GetLogoUniquenessString()
|
||||
userAvatarURLString := data.GetServerURL() + "/logo/external"
|
||||
userAvatarURL, err := url.Parse(userAvatarURLString)
|
||||
userAvatarURL.RawQuery = "uc=" + uniquenessString
|
||||
if err != nil {
|
||||
log.Errorln("unable to parse user avatar url", userAvatarURLString, err)
|
||||
}
|
||||
|
@ -159,7 +159,12 @@ func TestMakeServiceForAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
expectedAvatar := "https://my.cool.site.biz/logo/external"
|
||||
if person.GetActivityStreamsIcon().At(0).GetActivityStreamsImage().GetActivityStreamsUrl().Begin().GetIRI().String() != expectedAvatar {
|
||||
u, err := url.Parse(person.GetActivityStreamsIcon().At(0).GetActivityStreamsImage().GetActivityStreamsUrl().Begin().GetIRI().String())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
u.RawQuery = ""
|
||||
if u.String() != expectedAvatar {
|
||||
t.Errorf("actor.Avatar = %v, want %v", person.GetActivityStreamsIcon().At(0).GetActivityStreamsImage().GetActivityStreamsUrl().Begin().GetIRI().String(), expectedAvatar)
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ func SendLive() error {
|
||||
var imageToAttach string
|
||||
previewGif := filepath.Join(config.WebRoot, "preview.gif")
|
||||
thumbnailJpg := filepath.Join(config.WebRoot, "thumbnail.jpg")
|
||||
|
||||
uniquenessString := shortid.MustGenerate()
|
||||
if utils.DoesFileExists(previewGif) {
|
||||
imageToAttach = "preview.gif"
|
||||
} else if utils.DoesFileExists(thumbnailJpg) {
|
||||
@ -77,6 +77,7 @@ func SendLive() error {
|
||||
}
|
||||
if imageToAttach != "" {
|
||||
previewURL.Path = imageToAttach
|
||||
previewURL.RawQuery = "us=" + uniquenessString
|
||||
apmodels.AddImageAttachmentToNote(note, previewURL.String())
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -18,6 +18,7 @@ const (
|
||||
streamTitleKey = "stream_title"
|
||||
streamKeyKey = "stream_key"
|
||||
logoPathKey = "logo_path"
|
||||
logoUniquenessKey = "logo_uniqueness"
|
||||
serverSummaryKey = "server_summary"
|
||||
serverWelcomeMessageKey = "server_welcome_message"
|
||||
serverNameKey = "server_name"
|
||||
@ -125,6 +126,22 @@ func SetLogoPath(logo string) error {
|
||||
return _datastore.SetString(logoPathKey, logo)
|
||||
}
|
||||
|
||||
// SetLogoUniquenessString will set the logo cache busting string.
|
||||
func SetLogoUniquenessString(uniqueness string) error {
|
||||
return _datastore.SetString(logoUniquenessKey, uniqueness)
|
||||
}
|
||||
|
||||
// GetLogoUniquenessString will return the logo cache busting string.
|
||||
func GetLogoUniquenessString() string {
|
||||
uniqueness, err := _datastore.GetString(logoUniquenessKey)
|
||||
if err != nil {
|
||||
log.Traceln(logoUniquenessKey, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return uniqueness
|
||||
}
|
||||
|
||||
// GetServerSummary will return the server summary text.
|
||||
func GetServerSummary() string {
|
||||
summary, err := _datastore.GetString(serverSummaryKey)
|
||||
|
Loading…
x
Reference in New Issue
Block a user