summaryrefslogtreecommitdiff
path: root/internal/ap/extract.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-10-26 11:59:10 +0200
committerLibravatar GitHub <noreply@github.com>2023-10-26 11:59:10 +0200
commit0b978f2c56c47ddbe0f611720d3605236f4e57d9 (patch)
treed5deece25e2aedebcacdff56900077688c6e6f7e /internal/ap/extract.go
parent[chore]: Bump google.golang.org/grpc from 1.58.2 to 1.58.3 (#2301) (diff)
downloadgotosocial-0b978f2c56c47ddbe0f611720d3605236f4e57d9.tar.xz
[bugfix] Extract description as `summary` first, fall back to `name` (#2303)
Diffstat (limited to 'internal/ap/extract.go')
-rw-r--r--internal/ap/extract.go13
1 files changed, 12 insertions, 1 deletions
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 &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.