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

fix: replace deprecated v1.instance #3183

Merged
merged 4 commits into from
Feb 6, 2025
Merged

Conversation

Shinigami92
Copy link
Member

Copy link

netlify bot commented Feb 3, 2025

Deploy Preview for elk-zone ready!

Name Link
🔨 Latest commit 54b1eb3
🔍 Latest deploy log https://app.netlify.com/sites/elk-zone/deploys/67a3855f74ec5a0008834114
😎 Deploy Preview https://deploy-preview-3183--elk-zone.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 3, 2025

Deploy Preview for elk-docs canceled.

Name Link
🔨 Latest commit 54b1eb3
🔍 Latest deploy log https://app.netlify.com/sites/elk-docs/deploys/67a3855fd3c7ee00085e5a3d

@Shinigami92 Shinigami92 self-assigned this Feb 3, 2025
@Shinigami92 Shinigami92 added the c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs label Feb 3, 2025
@Shinigami92 Shinigami92 force-pushed the fix-replace-deprecated-v1-instance branch 2 times, most recently from d0c5910 to 18fce6b Compare February 3, 2025 20:32
Copy link
Member

@shuuji3 shuuji3 left a comment

Choose a reason for hiding this comment

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

The release date of v4.0.0 was a while ago (Nov 2022) but it seems some Mastodon-compatible servers have implemented only /api/v1/instance yet. So I think it's better to keep /api/v1/instance endpoint as a fallback to keep supporting them for now.

@shuuji3 shuuji3 force-pushed the fix-replace-deprecated-v1-instance branch from 8bd0f0a to d45cc84 Compare February 4, 2025 14:08
@shuuji3
Copy link
Member

shuuji3 commented Feb 4, 2025

(Netlify's build issue was solved by #3187)

@Shinigami92
Copy link
Member Author

The release date of v4.0.0 was a while ago (Nov 2022) but it seems some Mastodon-compatible servers have implemented only /api/v1/instance yet. So I think it's better to keep /api/v1/instance endpoint as a fallback to keep supporting them for now.

thx for pointing this out, I was not aware that there are still such deprecated/legacy instances, but now I can develop against these 👍 and implement the fallback

@shuuji3
Copy link
Member

shuuji3 commented Feb 5, 2025

Yeah, this is one of the difficult parts for fediverse server developers😅 If there are only Mastodon servers, probably we can drop its support and encourage the server admins to upgrade to the newer version of Mastodon. However, some non-Mastodon servers have separate main APIs and later add extra Mastodon-compatible API like this for Mastodon client compatibility. Often development resource is limited so it takes a while to adopt a newer interface, especially when the older one provides good enough functionality.

@Shinigami92 Shinigami92 requested a review from shuuji3 February 5, 2025 15:36
@Shinigami92 Shinigami92 marked this pull request as ready for review February 5, 2025 15:36
Copy link
Member

@shuuji3 shuuji3 left a comment

Choose a reason for hiding this comment

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

LGTM!

@shuuji3 shuuji3 added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 9f4945b Feb 6, 2025
15 checks passed
@shuuji3 shuuji3 deleted the fix-replace-deprecated-v1-instance branch February 6, 2025 16:59
@shuuji3
Copy link
Member

shuuji3 commented Feb 6, 2025

For records, here's two mastodon.v2.Instance objects.

https://mastodon.social/api/v2/instance

{
  "domain": "webtoo.ls",
  "title": "webtoo.ls",
  "version": "4.3.1",
  "sourceUrl": "https://github.com/mastodon/mastodon",
  "description": "webtoo.ls is a small server dedicated to Open Source tools in the Web ecosystem and their maintainers, collaborators, and close community members.",
  "usage": {
    "users": {
      "activeMonth": 33
    }
  },
  "thumbnail": {
    "url": "https://media.webtoo.ls/site_uploads/files/000/000/001/@1x/a0a1e37d6139dd8a.png",
    "blurhash": "UzGk.-j@0QR+xrWCRlt5NIfQoej@WCj@oKfQ",
    "versions": {
      "@1x": "https://media.webtoo.ls/site_uploads/files/000/000/001/@1x/a0a1e37d6139dd8a.png",
      "@2x": "https://media.webtoo.ls/site_uploads/files/000/000/001/@2x/a0a1e37d6139dd8a.png"
    }
  },
  "icon": [
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-36x36-4c61fdb42936428af85afdbf8c6a45a8.png",
      "size": "36x36"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-48x48-2027aead76dc906c981043d658a8258d.png",
      "size": "48x48"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-72x72-799d90b81f5b28cea7355a0c0b356381.png",
      "size": "72x72"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-96x96-c2dfcfa1268c56e59edddfe20d818b91.png",
      "size": "96x96"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-144x144-ff3110f7772743bdd0c1c47fb7b2d4e0.png",
      "size": "144x144"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-192x192-eddc1ed540e97b926202b7b857989d60.png",
      "size": "192x192"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-256x256-7b2b43926019259f7c9ddee627d80a0f.png",
      "size": "256x256"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-384x384-72068ed50b02828fc505a8d69b321dea.png",
      "size": "384x384"
    },
    {
      "src": "https://m.webtoo.ls/packs/media/icons/android-chrome-512x512-ccb53c9fcbb5f61bf741cc54998318f0.png",
      "size": "512x512"
    }
  ],
  "languages": [
    "en"
  ],
  "configuration": {
    "urls": {
      "streaming": "wss://m.webtoo.ls",
      "status": null
    },
    "vapid": {
      "publicKey": "BClch99aA-JfXidSbvcgvZnJVdXMf_XYHQAbll_e_tZTDGQU6JFQAeP_i7FORUlti55ni4KXTeeo8Tb9mMfeurw="
    },
    "accounts": {
      "maxFeaturedTags": 10,
      "maxPinnedStatuses": 5
    },
    "statuses": {
      "maxCharacters": 2500,
      "maxMediaAttachments": 4,
      "charactersReservedPerUrl": 23
    },
    "mediaAttachments": {
      "supportedMimeTypes": [
        "image/jpeg",
        "image/png",
        "image/gif",
        "image/heic",
        "image/heif",
        "image/webp",
        "image/avif",
        "video/webm",
        "video/mp4",
        "video/quicktime",
        "video/ogg",
        "audio/wave",
        "audio/wav",
        "audio/x-wav",
        "audio/x-pn-wave",
        "audio/vnd.wave",
        "audio/ogg",
        "audio/vorbis",
        "audio/mpeg",
        "audio/mp3",
        "audio/webm",
        "audio/flac",
        "audio/aac",
        "audio/m4a",
        "audio/x-m4a",
        "audio/mp4",
        "audio/3gpp",
        "video/x-ms-asf"
      ],
      "imageSizeLimit": 16777216,
      "imageMatrixLimit": 33177600,
      "videoSizeLimit": 103809024,
      "videoFrameRateLimit": 120,
      "videoMatrixLimit": 8294400
    },
    "polls": {
      "maxOptions": 4,
      "maxCharactersPerOption": 50,
      "minExpiration": 300,
      "maxExpiration": 2629746
    },
    "translation": {
      "enabled": false
    }
  },
  "registrations": {
    "enabled": false,
    "approvalRequired": false,
    "message": null,
    "url": null
  },
  "apiVersions": {
    "mastodon": 2
  },
  "contact": {
    "email": "server@webtoo.ls",
    "account": {
      "id": "109466772450961939",
      "username": "server",
      "acct": "server",
      "displayName": "webtoo.ls",
      "locked": false,
      "bot": false,
      "discoverable": true,
      "indexable": false,
      "group": false,
      "createdAt": "2022-12-06T00:00:00.000Z",
      "note": "<p>webtoo.ls is an invite-only server dedicated to Open Source tools in the Web ecosystem and their maintainers, collaborators, and close community members.</p><p>... run by <span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.roe.dev/@daniel\" class=\"u-url mention\">@<span>daniel</span></a></span>, <span class=\"h-card\" translate=\"no\"><a href=\"https://m.webtoo.ls/@patak\" class=\"u-url mention\">@<span>patak</span></a></span> and <span class=\"h-card\" translate=\"no\"><a href=\"https://m.webtoo.ls/@antfu\" class=\"u-url mention\">@<span>antfu</span></a></span></p>",
      "url": "https://m.webtoo.ls/@server",
      "uri": "https://m.webtoo.ls/users/server",
      "avatar": "https://media.webtoo.ls/accounts/avatars/109/466/772/450/961/939/original/172d8a7ba614d598.png",
      "avatarStatic": "https://media.webtoo.ls/accounts/avatars/109/466/772/450/961/939/original/172d8a7ba614d598.png",
      "header": "https://m.webtoo.ls/headers/original/missing.png",
      "headerStatic": "https://m.webtoo.ls/headers/original/missing.png",
      "followersCount": 111,
      "followingCount": 3,
      "statusesCount": 0,
      "lastStatusAt": "2023-11-18",
      "hideCollections": false,
      "noindex": false,
      "emojis": [],
      "roles": [
        {
          "id": "3",
          "name": "Owner",
          "color": ""
        }
      ],
      "fields": []
    }
  },
  "rules": [
    {
      "id": "1",
      "text": "No racism/white supremacy",
      "hint": ""
    },
    {
      "id": "2",
      "text": "No sexism",
      "hint": ""
    },
    {
      "id": "3",
      "text": "No ableism",
      "hint": ""
    },
    {
      "id": "4",
      "text": "No queer/trans-phobia",
      "hint": ""
    },
    {
      "id": "5",
      "text": "No fascism or nationalism",
      "hint": ""
    },
    {
      "id": "6",
      "text": "No violence or harassment",
      "hint": ""
    },
    {
      "id": "7",
      "text": "No spam",
      "hint": ""
    }
  ]
}

constructed mastodon.v2.Instance object from mastodon.v1.Instance data (from https://mastodon.social/api/v1/instance)

{
  "uri": "webtoo.ls",
  "title": "webtoo.ls",
  "shortDescription": "webtoo.ls is a small server dedicated to Open Source tools in the Web ecosystem and their maintainers, collaborators, and close community members.",
  "description": "",
  "email": "server@webtoo.ls",
  "version": "4.3.1",
  "urls": {
    "streamingApi": "wss://m.webtoo.ls"
  },
  "stats": {
    "userCount": 65,
    "statusCount": 8387,
    "domainCount": 25868
  },
  "thumbnail": "https://media.webtoo.ls/site_uploads/files/000/000/001/@1x/a0a1e37d6139dd8a.png",
  "languages": [
    "en"
  ],
  "registrations": false,
  "approvalRequired": false,
  "invitesEnabled": true,
  "configuration": {
    "accounts": {
      "maxFeaturedTags": 10
    },
    "statuses": {
      "maxCharacters": 2500,
      "maxMediaAttachments": 4,
      "charactersReservedPerUrl": 23
    },
    "mediaAttachments": {
      "supportedMimeTypes": [
        "image/jpeg",
        "image/png",
        "image/gif",
        "image/heic",
        "image/heif",
        "image/webp",
        "image/avif",
        "video/webm",
        "video/mp4",
        "video/quicktime",
        "video/ogg",
        "audio/wave",
        "audio/wav",
        "audio/x-wav",
        "audio/x-pn-wave",
        "audio/vnd.wave",
        "audio/ogg",
        "audio/vorbis",
        "audio/mpeg",
        "audio/mp3",
        "audio/webm",
        "audio/flac",
        "audio/aac",
        "audio/m4a",
        "audio/x-m4a",
        "audio/mp4",
        "audio/3gpp",
        "video/x-ms-asf"
      ],
      "imageSizeLimit": 16777216,
      "imageMatrixLimit": 33177600,
      "videoSizeLimit": 103809024,
      "videoFrameRateLimit": 120,
      "videoMatrixLimit": 8294400
    },
    "polls": {
      "maxOptions": 4,
      "maxCharactersPerOption": 50,
      "minExpiration": 300,
      "maxExpiration": 2629746
    },
    "urls": {
      "streaming": "wss://m.webtoo.ls"
    }
  },
  "contactAccount": {
    "id": "109466772450961939",
    "username": "server",
    "acct": "server",
    "displayName": "webtoo.ls",
    "locked": false,
    "bot": false,
    "discoverable": true,
    "indexable": false,
    "group": false,
    "createdAt": "2022-12-06T00:00:00.000Z",
    "note": "<p>webtoo.ls is an invite-only server dedicated to Open Source tools in the Web ecosystem and their maintainers, collaborators, and close community members.</p><p>... run by <span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.roe.dev/@daniel\" class=\"u-url mention\">@<span>daniel</span></a></span>, <span class=\"h-card\" translate=\"no\"><a href=\"https://m.webtoo.ls/@patak\" class=\"u-url mention\">@<span>patak</span></a></span> and <span class=\"h-card\" translate=\"no\"><a href=\"https://m.webtoo.ls/@antfu\" class=\"u-url mention\">@<span>antfu</span></a></span></p>",
    "url": "https://m.webtoo.ls/@server",
    "uri": "https://m.webtoo.ls/users/server",
    "avatar": "https://media.webtoo.ls/accounts/avatars/109/466/772/450/961/939/original/172d8a7ba614d598.png",
    "avatarStatic": "https://media.webtoo.ls/accounts/avatars/109/466/772/450/961/939/original/172d8a7ba614d598.png",
    "header": "https://m.webtoo.ls/headers/original/missing.png",
    "headerStatic": "https://m.webtoo.ls/headers/original/missing.png",
    "followersCount": 111,
    "followingCount": 3,
    "statusesCount": 0,
    "lastStatusAt": "2023-11-18",
    "hideCollections": false,
    "noindex": false,
    "emojis": [],
    "roles": [
      {
        "id": "3",
        "name": "Owner",
        "color": ""
      }
    ],
    "fields": []
  },
  "rules": [
    {
      "id": "1",
      "text": "No racism/white supremacy",
      "hint": ""
    },
    {
      "id": "2",
      "text": "No sexism",
      "hint": ""
    },
    {
      "id": "3",
      "text": "No ableism",
      "hint": ""
    },
    {
      "id": "4",
      "text": "No queer/trans-phobia",
      "hint": ""
    },
    {
      "id": "5",
      "text": "No fascism or nationalism",
      "hint": ""
    },
    {
      "id": "6",
      "text": "No violence or harassment",
      "hint": ""
    },
    {
      "id": "7",
      "text": "No spam",
      "hint": ""
    }
  ],
  "domain": "webtoo.ls",
  "sourceUrl": "",
  "usage": {
    "users": {
      "activeMonth": 0
    }
  },
  "icon": [],
  "apiVersions": {
    "mastodon": "4.3.1"
  },
  "contact": {
    "email": "server@webtoo.ls"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants