mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-23 22:53:32 -06:00
Instance settings updates (#59)
Allow admins to set instance settings through a PATCH to /api/v1/instance Update templates to reflect some of the new fields
This commit is contained in:
parent
fd57cca437
commit
8c9a853343
13 changed files with 340 additions and 29 deletions
|
|
@ -511,9 +511,31 @@ func (c *converter) InstanceToMasto(i *gtsmodel.Instance) (*model.Instance, erro
|
|||
ShortDescription: i.ShortDescription,
|
||||
Email: i.ContactEmail,
|
||||
Version: i.Version,
|
||||
Stats: make(map[string]int),
|
||||
ContactAccount: &model.Account{},
|
||||
}
|
||||
|
||||
// if the requested instance is *this* instance, we can add some extra information
|
||||
if i.Domain == c.config.Host {
|
||||
userCountKey := "user_count"
|
||||
statusCountKey := "status_count"
|
||||
domainCountKey := "domain_count"
|
||||
|
||||
userCount, err := c.db.GetUserCountForInstance(c.config.Host)
|
||||
if err == nil {
|
||||
mi.Stats[userCountKey] = userCount
|
||||
}
|
||||
|
||||
statusCount, err := c.db.GetStatusCountForInstance(c.config.Host)
|
||||
if err == nil {
|
||||
mi.Stats[statusCountKey] = statusCount
|
||||
}
|
||||
|
||||
domainCount, err := c.db.GetDomainCountForInstance(c.config.Host)
|
||||
if err == nil {
|
||||
mi.Stats[domainCountKey] = domainCount
|
||||
}
|
||||
|
||||
mi.Registrations = c.config.AccountsConfig.OpenRegistration
|
||||
mi.ApprovalRequired = c.config.AccountsConfig.RequireApproval
|
||||
mi.InvitesEnabled = false // TODO
|
||||
|
|
@ -523,6 +545,17 @@ func (c *converter) InstanceToMasto(i *gtsmodel.Instance) (*model.Instance, erro
|
|||
}
|
||||
}
|
||||
|
||||
// get the instance account if it exists and just skip if it doesn't
|
||||
ia := >smodel.Account{}
|
||||
if err := c.db.GetWhere([]db.Where{{Key: "username", Value: i.Domain}}, ia); err == nil {
|
||||
// instance account exists, get the header for the account if it exists
|
||||
attachment := >smodel.MediaAttachment{}
|
||||
if err := c.db.GetHeaderForAccountID(attachment, ia.ID); err == nil {
|
||||
// header exists, set it on the api model
|
||||
mi.Thumbnail = attachment.URL
|
||||
}
|
||||
}
|
||||
|
||||
// contact account is optional but let's try to get it
|
||||
if i.ContactAccountID != "" {
|
||||
ia := >smodel.Account{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue