superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.83k stars 334 forks source link

[feature] Expose Mastodon API compatible version and identify platform as GotoSocial in the version string #2874

Closed technicat closed 6 months ago

technicat commented 6 months ago

Is your feature request related to a problem ?

My fediverse client determines platform feature support based on the Mastodon API version and the listed platform in Instance.version, e.g. Mastodon might return just "4.2.7" and Pixelfed returns 3.5.3 (compatible: Pixelfed 0.11.13). All the other platforms I sort of support more or less follow the latter pattern, including Pleroma/Akkoma, Friendica, the Misskey forks, and the Mastodon forks. However, GotoSocial just returns the GotoSocial version followed by a git commit identifier.

Describe the solution you'd like.

Instead of " 0.15.0+git-15733cd)" how about , for example if the Mastodon API compatibility is 4.2.8, "4.2.8 (compatible: GotoSocial 0.15.0+git-15733cd)"

Describe alternatives you've considered.

For now, I just look for "git" in the version string to determine if the platform is GotoSocial but that will fail as soon as any other platform includes "git in their version string.

Additional context.

IMG_6399 IMG_6400

CDN18 commented 6 months ago

For the "Expose Mastodon API compatible version" part, there's an optional setting called instance-inject-mastodon-version.

Plus, /api/v2/instance returns source_url, which may be considered as another alternative.

technicat commented 6 months ago

For the "Expose Mastodon API compatible version" part, there's an optional setting called instance-inject-mastodon-version.

Plus, /api/v2/instance returns source_url, which may be considered as another alternative.

Thanks, I'm operating on the client side so can't control the instance configuration, but source_url is a good option. TootSDK is only using the v1 instance but I can add v2 to my fork and try it out.

edit: I just looked in the gotosocial code and saw instanceMastodonVersion is harcoded to 3.5.3 so I will do the same!

tsmethurst commented 6 months ago

Shall I close this then, since we already have what you need? :)

technicat commented 6 months ago

Shall I close this then, since we already have what you need? :)

You can close this as a won't-fix, of course, but I wouldn't say I have what I need, more like I'm looking at workarounds. Currently I'm hardcoding the API version and string matching for "git" which is not so good for both parts.

Most gotosocial instances don't seem to have the mastodon version display flag turned on, and the one I found that does, displays a slightly older version (3.3.0) which also results in it being displayed as the GotoSocial version on its home page and FediDb, and that version string is just the version with no suffix so there's no way to distinguish from that string that it's gotosocial.

I'm working on querying for the v2 instance so I can get the source_url but that will only fix the platform issue and v2 instance was introduced with mastodon 4.0 so I don't know how many platforms have it implemented.

So I still think it would be preferable to have the version string conform to the pseudo-convention for Mastodon API-compatible platforms, and then you wouldn't need the instance-inject-mastodon-version option.

tsmethurst commented 6 months ago

Perhaps another alternative would be to look at the node-info page for the 'software' value?

For example: https://gts.superseriousbusiness.org/nodeinfo/2.0 returns:

{
  "version": "2.0",
  "software": {
    "name": "gotosocial",
    "version": "0.15.0+git-15733cd"
  },
  "protocols": [
    "activitypub"
  ],
  "services": {
    "inbound": [],
    "outbound": []
  },
  "openRegistrations": true,
  "usage": {
    "users": {
      "total": 5
    },
    "localPosts": 2769
  },
  "metadata": {}
}

By comparison, https://mastodon.social/nodeinfo/2.0 returns:

{
  "version": "2.0",
  "software": {
    "name": "mastodon",
    "version": "4.3.0-nightly.2024-04-29"
  },
  "protocols": [
    "activitypub"
  ],
  "services": {
    "outbound": [],
    "inbound": []
  },
  "usage": {
    "users": {
      "total": 1927427,
      "activeMonth": 239944,
      "activeHalfyear": 622063
    },
    "localPosts": 89637022
  },
  "openRegistrations": true,
  "metadata": {
    "nodeName": "Mastodon",
    "nodeDescription": "The original server operated by the Mastodon gGmbH non-profit"
  }
}
technicat commented 6 months ago

Thanks, examining nodeinfo does look like a better approach to figuring out what platform you're dealing with before making any API queries, and the nodeinfo README lists many of the ones I'm dealing with.

https://github.com/jhass/nodeinfo

Edit: and I see this is what feditext is doing.

daenney commented 6 months ago

I'll go ahead and close this then. The nodeinfo is ideally what clients should use to figure out the implementation.

The instance-inject-mastodon-version thing is a crutch but it's been helpful to nudge some fidgetty clients. But most admin's don't enable it since, well, most clients don't need it :smile:.