From 07620acc0e192d43fd31c41ed2a727ad247aeed3 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 26 Jun 2022 12:33:11 +0200 Subject: [feature] Use default instance thumbnail if instance account header not set (#672) --- internal/typeutils/internaltofrontend.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'internal/typeutils/internaltofrontend.go') 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 { -- cgit v1.2.3