diff --git a/activitypub/apmodels/message.go b/activitypub/apmodels/message.go index 67d124982..646057c36 100644 --- a/activitypub/apmodels/message.go +++ b/activitypub/apmodels/message.go @@ -20,7 +20,7 @@ func CreateCreateActivity(id string, localAccountIRI *url.URL) vocab.ActivityStr } // AddImageAttachmentToNote will add the provided image URL to the provided note object. -func AddImageAttachmentToNote(note vocab.ActivityStreamsNote, image string) { +func AddImageAttachmentToNote(note vocab.ActivityStreamsNote, image, mediaType string) { imageURL, err := url.Parse(image) if err != nil { return @@ -40,9 +40,13 @@ func AddImageAttachmentToNote(note vocab.ActivityStreamsNote, image string) { imageProp := streams.NewActivityStreamsImageProperty() imageProp.AppendActivityStreamsImage(apImage) - imageDescription := streams.NewActivityStreamsContentProperty() + imageDescription := streams.NewActivityStreamsNameProperty() imageDescription.AppendXMLSchemaString("Live stream preview") - apImage.SetActivityStreamsContent(imageDescription) + apImage.SetActivityStreamsName(imageDescription) + + mediaTypeProperty := streams.NewActivityStreamsMediaTypeProperty() + mediaTypeProperty.Set(mediaType) + apImage.SetActivityStreamsMediaType(mediaTypeProperty) attachments.AppendActivityStreamsImage(apImage) diff --git a/activitypub/outbox/outbox.go b/activitypub/outbox/outbox.go index ed2486e57..13a5e11b4 100644 --- a/activitypub/outbox/outbox.go +++ b/activitypub/outbox/outbox.go @@ -76,18 +76,21 @@ func SendLive() error { previewURL, err := url.Parse(data.GetServerURL()) if err == nil { var imageToAttach string + var mediaType 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" + mediaType = "image/gif" } else if utils.DoesFileExists(thumbnailJpg) { imageToAttach = "thumbnail.jpg" + mediaType = "image/jpeg" } if imageToAttach != "" { previewURL.Path = imageToAttach previewURL.RawQuery = "us=" + uniquenessString - apmodels.AddImageAttachmentToNote(note, previewURL.String()) + apmodels.AddImageAttachmentToNote(note, previewURL.String(), mediaType) } }