fiddle with instance display
This commit is contained in:
@ -34,5 +34,6 @@ func New(config *config.Config, processor processing.Processor, log *logrus.Logg
|
||||
// Route satisfies the ClientModule interface
|
||||
func (m *Module) Route(s router.Router) error {
|
||||
s.AttachHandler(http.MethodGet, InstanceInformationPath, m.InstanceInformationGETHandler)
|
||||
s.AttachHandler(http.MethodPatch, InstanceInformationPath, m.InstanceUpdatePATCHHandler)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ func (ps *postgresService) GetStatusCountForInstance(domain string) (int, error)
|
||||
} else {
|
||||
// join on the domain of the account
|
||||
q = q.Join("JOIN accounts AS account ON account.id = status.account_id").
|
||||
Where("account.domain = ?", domain)
|
||||
Where("account.domain = ?", domain)
|
||||
}
|
||||
|
||||
return q.Count()
|
||||
|
||||
@ -90,7 +90,7 @@ func (p *processor) InstancePatch(form *apimodel.InstanceSettingsUpdateRequest)
|
||||
return nil, gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
// contact account user must be admin or moderator otherwise what's the point of contacting them
|
||||
if !contactUser.Admin || !contactUser.Moderator {
|
||||
if !contactUser.Admin && !contactUser.Moderator {
|
||||
err := fmt.Errorf("user of selected contact account %s is neither admin nor moderator", contactAccount.Username)
|
||||
return nil, gtserror.NewErrorBadRequest(err, err.Error())
|
||||
}
|
||||
|
||||
@ -512,6 +512,7 @@ func (c *converter) InstanceToMasto(i *gtsmodel.Instance) (*model.Instance, erro
|
||||
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
|
||||
@ -542,7 +543,18 @@ func (c *converter) InstanceToMasto(i *gtsmodel.Instance) (*model.Instance, erro
|
||||
mi.URLS = &model.InstanceURLs{
|
||||
StreamingAPI: fmt.Sprintf("wss://%s", c.config.Host),
|
||||
}
|
||||
}aaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
}
|
||||
|
||||
// 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 != "" {
|
||||
|
||||
@ -24,7 +24,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
maximumEmailLength = 256
|
||||
maximumUsernameLength = 64
|
||||
maximumEmojiShortcodeLength = 30
|
||||
maximumHashtagLength = 30
|
||||
|
||||
Reference in New Issue
Block a user