From 0b978f2c56c47ddbe0f611720d3605236f4e57d9 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:59:10 +0200 Subject: [bugfix] Extract description as `summary` first, fall back to `name` (#2303) --- internal/ap/extract.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'internal/ap/extract.go') diff --git a/internal/ap/extract.go b/internal/ap/extract.go index 41cc5dcbc..6d224e9a8 100644 --- a/internal/ap/extract.go +++ b/internal/ap/extract.go @@ -600,12 +600,23 @@ func ExtractAttachment(i Attachmentable) (*gtsmodel.MediaAttachment, error) { return >smodel.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. -- cgit v1.2.3