[bugfix] Extract description as summary first, fall back to name (#2303)

This commit is contained in:
tobi
2023-10-26 11:59:10 +02:00
committed by GitHub
parent 03732aca3b
commit 0b978f2c56
3 changed files with 52 additions and 1 deletions

View File

@@ -600,12 +600,23 @@ func ExtractAttachment(i Attachmentable) (*gtsmodel.MediaAttachment, error) {
return &gtsmodel.MediaAttachment{
RemoteURL: remoteURL.String(),
Description: ExtractName(i),
Description: ExtractDescription(i),
Blurhash: ExtractBlurhash(i),
Processing: gtsmodel.ProcessingStatusReceived,
}, nil
}
// ExtractDescription extracts the image description
// of an attachmentable, if present. Will try the
// 'summary' prop first, then fall back to 'name'.
func ExtractDescription(i Attachmentable) string {
if summary := ExtractSummary(i); summary != "" {
return summary
}
return ExtractName(i)
}
// ExtractBlurhash extracts the blurhash string value
// from the given WithBlurhash interface, or returns
// an empty string if nothing is found.