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: non-compliant Mastodon Account endpoints #365

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

DataDrivenMD
Copy link
Contributor

@DataDrivenMD DataDrivenMD commented Mar 3, 2023

Completed

  • Define CustomEmoji type: formally defining this type helps with serialization of a Mastodon API-compliant version of the Mastodon Account entity
  • Add Mastodon ID utilities: these methods are necessary to generate numeric IDs that resemble those that are used in the official Mastodon project. Several of the most popular 3rd-party Mastodon apps, including Ivory, rely on these numeric account IDs. So, these methods lay the foundation for greatly-improved compatibility with 3rd-party apps.
  • MastodonAccount mostly aligns w/ Masto API spec and Add /api/v1/accounts/lookup + tests: these two commits bring the changes in this PR together. One key change here is the addition of the /api/v1/accounts/lookup endpoint, which was previously missing, and was contributing to various 3rd-party app incompatibilities. With these changes, I was able to refactor the accounts test suite, which was necessary because 3 tests were miscategorized as belonging to /api/v1/accounts/:id when they should have actually been tests for /api/v1/accounts/lookup.
  • Implement Mastodon account ID: Generate a Mastodon account ID when an AP actor is added to the actors table and add a mastodon_id to any preexisting entry in the actors table as it is retrieved (DB migration not possible in this setting because the value is derived using JS due to SQLite lacking the extensions necessary to build the user-defined function). Again, this is necessary for compatibility with 3rd-party apps and for compliance with Mastodon API specs.

WIP

  • Update the code in wildebeest/functions/api/v1/accounts/[id].ts and wildebeest/functions/api/v1/accounts/[id]/*.ts so that they actually use the Mastodon Account ID instead of the ActivityPub actor ID because as things stand now, the implementation is not-compliant with the Mastodon API spec, and it's breaking compatibility with several popular 3rd-party apps
  • Update test suite /api/v1/accounts/:id endpoints

cc @xtuc

This also refactors several tests previously under the `/api/v1/accounts/:id` endpoint to the newly-implemented `/api/v1/accounts/lookup` endpoint. This was done in order to be in compliance with Mastodon API specification
- [X] Generate a Mastodon account ID when an AP actor is added to the `actors` table
- [X] Ensure that every entry in the actors table has a `mastodon_id`
- [ ] Update the code in wildebeest/functions/api/v1/accounts/[id].ts and wildebeest/functions/api/v1/accounts/[id]/*.ts so that they actually use the Mastodon Account ID instead of the ActivityPub actor ID because as things stand now, the implementation is not-compliant with the Mastodon API spec, and it's breaking compatibility with several popular 3rd-party apps
- [ ] Update test suite /api/v1/accounts/:id endpoints

// Restore reblogged status
status.reblog = {
...status,
account,
account: mastodonAccount,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: rest property must be the last in the pattern, and must not have a trailing comma

ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#rest_property

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.

1 participant