mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-24 19:23:33 -06:00
[feature] Use default instance thumbnail if instance account header not set (#672)
This commit is contained in:
parent
68736efd20
commit
07620acc0e
2 changed files with 14 additions and 12 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue