diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/config/config.go | 1 | ||||
| -rw-r--r-- | internal/config/helpers.gen.go | 25 | ||||
| -rw-r--r-- | internal/typeutils/internaltofrontend.go | 13 | 
3 files changed, 39 insertions, 0 deletions
| diff --git a/internal/config/config.go b/internal/config/config.go index 53514e20b..cb158cdad 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -80,6 +80,7 @@ type Configuration struct {  	InstanceExposeSuspendedWeb     bool `name:"instance-expose-suspended-web" usage:"Expose list of suspended instances as webpage on /about/suspended"`  	InstanceExposePublicTimeline   bool `name:"instance-expose-public-timeline" usage:"Allow unauthenticated users to query /api/v1/timelines/public"`  	InstanceDeliverToSharedInboxes bool `name:"instance-deliver-to-shared-inboxes" usage:"Deliver federated messages to shared inboxes, if they're available."` +	InstanceInjectMastodonVersion  bool `name:"instance-inject-mastodon-version" usage:"This injects a Mastodon compatible version in /api/v1/instance to help Mastodon clients that use that version for feature detection"`  	AccountsRegistrationOpen bool `name:"accounts-registration-open" usage:"Allow anyone to submit an account signup request. If false, server will be invite-only."`  	AccountsApprovalRequired bool `name:"accounts-approval-required" usage:"Do account signups require approval by an admin or moderator before user can log in? If false, new registrations will be automatically approved."` diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 6cd2d6bd4..ceb115bba 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -849,6 +849,31 @@ func GetInstanceDeliverToSharedInboxes() bool { return global.GetInstanceDeliver  // SetInstanceDeliverToSharedInboxes safely sets the value for global configuration 'InstanceDeliverToSharedInboxes' field  func SetInstanceDeliverToSharedInboxes(v bool) { global.SetInstanceDeliverToSharedInboxes(v) } +// GetInstanceInjectMastodonVersion safely fetches the Configuration value for state's 'InstanceInjectMastodonVersion' field +func (st *ConfigState) GetInstanceInjectMastodonVersion() (v bool) { +	st.mutex.RLock() +	v = st.config.InstanceInjectMastodonVersion +	st.mutex.RUnlock() +	return +} + +// SetInstanceInjectMastodonVersion safely sets the Configuration value for state's 'InstanceInjectMastodonVersion' field +func (st *ConfigState) SetInstanceInjectMastodonVersion(v bool) { +	st.mutex.Lock() +	defer st.mutex.Unlock() +	st.config.InstanceInjectMastodonVersion = v +	st.reloadToViper() +} + +// InstanceInjectMastodonVersionFlag returns the flag name for the 'InstanceInjectMastodonVersion' field +func InstanceInjectMastodonVersionFlag() string { return "instance-inject-mastodon-version" } + +// GetInstanceInjectMastodonVersion safely fetches the value for global configuration 'InstanceInjectMastodonVersion' field +func GetInstanceInjectMastodonVersion() bool { return global.GetInstanceInjectMastodonVersion() } + +// SetInstanceInjectMastodonVersion safely sets the value for global configuration 'InstanceInjectMastodonVersion' field +func SetInstanceInjectMastodonVersion(v bool) { global.SetInstanceInjectMastodonVersion(v) } +  // GetAccountsRegistrationOpen safely fetches the Configuration value for state's 'AccountsRegistrationOpen' field  func (st *ConfigState) GetAccountsRegistrationOpen() (v bool) {  	st.mutex.RLock() diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index d6da9493f..17b8047e9 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -45,6 +45,7 @@ const (  	instanceAccountsMaxFeaturedTags             = 10  	instanceAccountsMaxProfileFields            = 6 // FIXME: https://github.com/superseriousbusiness/gotosocial/issues/1876  	instanceSourceURL                           = "https://github.com/superseriousbusiness/gotosocial" +	instanceMastodonVersion                     = "3.5.3"  )  var instanceStatusesSupportedMimeTypes = []string{ @@ -52,6 +53,10 @@ var instanceStatusesSupportedMimeTypes = []string{  	string(apimodel.StatusContentTypeMarkdown),  } +func toMastodonVersion(in string) string { +	return instanceMastodonVersion + "+" + strings.ReplaceAll(in, " ", "-") +} +  func (c *converter) AccountToAPIAccountSensitive(ctx context.Context, a *gtsmodel.Account) (*apimodel.Account, error) {  	// we can build this sensitive account easily by first getting the public account....  	apiAccount, err := c.AccountToAPIAccountPublic(ctx, a) @@ -740,6 +745,10 @@ func (c *converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins  		MaxTootChars:     uint(config.GetStatusesMaxChars()),  	} +	if config.GetInstanceInjectMastodonVersion() { +		instance.Version = toMastodonVersion(instance.Version) +	} +  	// configuration  	instance.Configuration.Statuses.MaxCharacters = config.GetStatusesMaxChars()  	instance.Configuration.Statuses.MaxMediaAttachments = config.GetStatusesMediaMaxFiles() @@ -839,6 +848,10 @@ func (c *converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins  		Rules:         []interface{}{},            // todo: not implemented  	} +	if config.GetInstanceInjectMastodonVersion() { +		instance.Version = toMastodonVersion(instance.Version) +	} +  	// thumbnail  	thumbnail := apimodel.InstanceV2Thumbnail{} | 
