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

#606 Implement v2 media endpoint #607

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Lastorder-DC
Copy link

https://docs.joinmastodon.org/methods/media/

It replaces v1 media endpoint with v2 media endpoint.

@NicolasConstant
Copy link
Owner

Thanks for contributing to Sengi!

Unfortunately we can't remove v1 support: since other software (like Pleroma) might rely on it, we could call v1 or v2 depending on the software/version used, a bit like how it's done in the search API call wrapping.

@Lastorder-DC Lastorder-DC changed the title #606 Stop using v1 media endpoint #606 Implement v2 media endpoint Aug 16, 2023
@Lastorder-DC
Copy link
Author

Okay. will change code to implement both v1 and v2.

@Lastorder-DC
Copy link
Author

Lastorder-DC commented Aug 16, 2023

Can I implement v1 as a fallback? since v2 is more reliable than v1(if supported), and both mastodon compatible sw I know(pleroma and its fork akkoma) supports v2 media endpoint.

(edit)
You can edit this PR to what you want. I can start working on this after 8/18

@NicolasConstant
Copy link
Owner

Take all the time you need. 🙂

Instead of a fallback (that would mean calling twice in the worth case) I would rather analyses the instance's version and call the appropriate version. For example the search api is called after this analysis was done;

this.toolsService.getInstanceInfo(selectedAccount)
.then(instance => {
let version: 'v1' | 'v2' = 'v1';
if(instance.major >= 3) version = 'v2';
return this.mastodonService.search(selectedAccount, pattern, version, false);
})
.then((results: Results) => {

I would reuse a similar pattern before calling the new media implementation.

(Of course, if we migrate more and more v2 implementation, that would be useful to regroup this particular logic in a dedicated layer, but lest keep things as they are for now)

@Lastorder-DC Lastorder-DC marked this pull request as draft September 9, 2023 03:25
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.

2 participants