diff options
author | 2022-06-26 12:33:11 +0200 | |
---|---|---|
committer | 2022-06-26 12:33:11 +0200 | |
commit | 07620acc0e192d43fd31c41ed2a727ad247aeed3 (patch) | |
tree | 8d92871546f4821d65e4b7c76e50a97e7be1506e /internal/typeutils/internaltofrontend.go | |
parent | [feature] add configuration to `/api/v1/instance` response (#670) (diff) | |
download | gotosocial-07620acc0e192d43fd31c41ed2a727ad247aeed3.tar.xz |
[feature] Use default instance thumbnail if instance account header not set (#672)
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index eb4bcf70d..068ba700c 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -576,6 +576,16 @@ func (c *converter) InstanceToAPIInstance(ctx context.Context, i *gtsmodel.Insta // if the requested instance is *this* instance, we can add some extra information if host := config.GetHost(); i.Domain == host { + if ia, err := c.db.GetInstanceAccount(ctx, ""); err == nil { + if ia.HeaderMediaAttachment != nil { + // take instance account header as instance thumbnail + mi.Thumbnail = ia.HeaderMediaAttachment.URL + } else { + // or just use a default + mi.Thumbnail = config.GetProtocol() + "://" + host + "/assets/logo.png" + } + } + userCount, err := c.db.CountInstanceUsers(ctx, host) if err == nil { mi.Stats["user_count"] = userCount @@ -624,14 +634,6 @@ func (c *converter) InstanceToAPIInstance(ctx context.Context, i *gtsmodel.Insta } } - // get the instance account if it exists and just skip if it doesn't - ia, err := c.db.GetInstanceAccount(ctx, "") - if err == nil { - if ia.HeaderMediaAttachment != nil { - mi.Thumbnail = ia.HeaderMediaAttachment.URL - } - } - // contact account is optional but let's try to get it if i.ContactAccountID != "" { if i.ContactAccount == nil { |