This commit is contained in:
parent
dc16eafea4
commit
d1e39c4c1e
@ -161,8 +161,10 @@ func MakeServiceForAccount(accountName string) vocab.ActivityStreamsService {
|
|||||||
// Profile properties
|
// Profile properties
|
||||||
|
|
||||||
// Avatar
|
// Avatar
|
||||||
|
uniquenessString := data.GetLogoUniquenessString()
|
||||||
userAvatarURLString := data.GetServerURL() + "/logo/external"
|
userAvatarURLString := data.GetServerURL() + "/logo/external"
|
||||||
userAvatarURL, err := url.Parse(userAvatarURLString)
|
userAvatarURL, err := url.Parse(userAvatarURLString)
|
||||||
|
userAvatarURL.RawQuery = "uc=" + uniquenessString
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("unable to parse user avatar url", userAvatarURLString, err)
|
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"
|
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)
|
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
|
var imageToAttach string
|
||||||
previewGif := filepath.Join(config.WebRoot, "preview.gif")
|
previewGif := filepath.Join(config.WebRoot, "preview.gif")
|
||||||
thumbnailJpg := filepath.Join(config.WebRoot, "thumbnail.jpg")
|
thumbnailJpg := filepath.Join(config.WebRoot, "thumbnail.jpg")
|
||||||
|
uniquenessString := shortid.MustGenerate()
|
||||||
if utils.DoesFileExists(previewGif) {
|
if utils.DoesFileExists(previewGif) {
|
||||||
imageToAttach = "preview.gif"
|
imageToAttach = "preview.gif"
|
||||||
} else if utils.DoesFileExists(thumbnailJpg) {
|
} else if utils.DoesFileExists(thumbnailJpg) {
|
||||||
@ -77,6 +77,7 @@ func SendLive() error {
|
|||||||
}
|
}
|
||||||
if imageToAttach != "" {
|
if imageToAttach != "" {
|
||||||
previewURL.Path = imageToAttach
|
previewURL.Path = imageToAttach
|
||||||
|
previewURL.RawQuery = "us=" + uniquenessString
|
||||||
apmodels.AddImageAttachmentToNote(note, previewURL.String())
|
apmodels.AddImageAttachmentToNote(note, previewURL.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
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.
|
// 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)
|
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())
|
controllers.WriteSimpleResponse(w, false, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -252,6 +253,10 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := data.SetLogoUniquenessString(shortid.MustGenerate()); err != nil {
|
||||||
|
log.Error("Error saving logo uniqueness string: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Update Fediverse followers about this change.
|
// Update Fediverse followers about this change.
|
||||||
if err := outbox.UpdateFollowersWithAccountUpdates(); err != nil {
|
if err := outbox.UpdateFollowersWithAccountUpdates(); err != nil {
|
||||||
controllers.WriteSimpleResponse(w, false, err.Error())
|
controllers.WriteSimpleResponse(w, false, err.Error())
|
||||||
|
@ -18,6 +18,7 @@ const (
|
|||||||
streamTitleKey = "stream_title"
|
streamTitleKey = "stream_title"
|
||||||
streamKeyKey = "stream_key"
|
streamKeyKey = "stream_key"
|
||||||
logoPathKey = "logo_path"
|
logoPathKey = "logo_path"
|
||||||
|
logoUniquenessKey = "logo_uniqueness"
|
||||||
serverSummaryKey = "server_summary"
|
serverSummaryKey = "server_summary"
|
||||||
serverWelcomeMessageKey = "server_welcome_message"
|
serverWelcomeMessageKey = "server_welcome_message"
|
||||||
serverNameKey = "server_name"
|
serverNameKey = "server_name"
|
||||||
@ -125,6 +126,22 @@ func SetLogoPath(logo string) error {
|
|||||||
return _datastore.SetString(logoPathKey, logo)
|
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.
|
// GetServerSummary will return the server summary text.
|
||||||
func GetServerSummary() string {
|
func GetServerSummary() string {
|
||||||
summary, err := _datastore.GetString(serverSummaryKey)
|
summary, err := _datastore.GetString(serverSummaryKey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user