Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Report Masto version in /api/v1/instance #1977

Merged

Conversation

daenney
Copy link
Member

@daenney daenney commented Jul 10, 2023

Description

A number of applications use the version reported by /api/v1/instance as a way to do feature detection for the Mastodon client API. Due to the current GtS versions in 0.x, this often means GtS gets determined to be non-compatible by clients and libraries that only ever test against Mastodon proper.

This adds a configuration value that allows the admin to decide to inject a Mastodon version in that response instead, in order to cajole clients into working correctly with GtS. This is only done for /api/v1/instance as that's the Masto client API, nodeinfo is left as it is as that should not be used by Masto clients for feature detection.

Since the clients we recommend don't need to be tricked this way, this feature defaults to being off. Admins can enable it if so desired, which may be useful for small communities where admins might have less say over which clients people use.

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

@daenney
Copy link
Member Author

daenney commented Jul 10, 2023

This should fix #1069, I think this also would've fixed #113 . I also seem to recall an issue where Tobi and Blackle were discussing this and the solution of only optionally reporting the Masto version on this endpoint came up, but for the life of me I can't find it now.

)

var instanceStatusesSupportedMimeTypes = []string{
string(apimodel.StatusContentTypePlain),
string(apimodel.StatusContentTypeMarkdown),
}

func toMastodonVersion(in string) string {
return instanceMastodonVersion + "+" + strings.ReplaceAll(in, " ", "-")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for + here in order to turn our version into "build metadata" according to SemVer, so it should parse correctly for any clients that look at it. SemVer doesn't seem to like spaces which we have between the version and the git hash so that's replaced by a hyphen.

@tsmethurst
Copy link
Contributor

For context, this is where we had the discussion: #778

Since we resolved a while ago that we're only supporting the Mastodon API up to v4.1.x (https://gts.superseriousbusiness.org/@gotosocial/statuses/01GZEBDK1JGTNJZ8SCPXA274RY) we could use that version number instead of 3.5.3. Although we don't actually support all features from 4.1.x yet. But then again, we don't support all features from 3.5.3 yet either :D

@tsmethurst
Copy link
Contributor

Since version numbers are being fiddled with here, here's a link to a related issue: #1953

Not that we have to include the above in this PR necessarily, but it's worth bearing in mind for another PR.

@VyrCossont
Copy link
Contributor

nodeinfo is left as it is as that should not be used by Masto clients for feature detection

FWIW I'm now using nodeinfo in Feditext because it's the easier way to get the real server software name and version number, instead of a fake Mastodon version number that doesn't actually correspond to the features of that Mastodon version (see also: Pleroma, Akkoma). I'm in favor of this change, because as noted, not everybody is going to bother testing against non-Mastodon implementations, and a Mastodon 3 or 4 version number is a lie that's certainly closer to the truth. But smart cross-platform clients have to use nodeinfo software name and version as well as the instance API to get an idea of which APIs should be available.

@daenney
Copy link
Member Author

daenney commented Jul 12, 2023

For context, this is where we had the discussion: #778

Since we resolved a while ago that we're only supporting the Mastodon API up to v4.1.x (https://gts.superseriousbusiness.org/@gotosocial/statuses/01GZEBDK1JGTNJZ8SCPXA274RY) we could use that version number instead of 3.5.3. Although we don't actually support all features from 4.1.x yet. But then again, we don't support all features from 3.5.3 yet either :D

From what I've been able to see, most libraries seem to check for "at least v3" in order to use some v2 endpoints like instance and search. So as long as we report something in 3.x we're probably fine. Mastodon.py has a whole parade of version strings for certain features

A number of applications use the version reported by /api/v1/instance as
a way to do feature detection for the Mastodon client API. Due to the
current GtS versions in 0.x, this often means GtS gets determined to be
non-compatible by clients and libraries that only ever test against
Mastodon proper.

This adds a configuration value that allows the admin to decide to
inject a Mastodon version in that response instead, in order to cajool
clients into working correctly with GtS. This is only done for
/api/v1/instance as that's the Masto client API, nodeinfo is left as it
is as that should not be used by Masto clients for feature detection.

Since the clients we recommend don't need to be tricked this way, this
feature defaults to being off. Admins can enable it if so desired, which
may be useful for small communities where admins might have less say
over which clients people use.
@daenney daenney marked this pull request as ready for review July 21, 2023 15:43
@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit f8f0312 into superseriousbusiness:main Jul 21, 2023
2 checks passed
@daenney daenney deleted the fake-masto-version branch July 21, 2023 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants