support v2 instance, fix #504

This commit is contained in:
Nicolas Constant 2023-04-23 16:20:00 -04:00
parent 2cb443dd4d
commit 232a86566c
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 7 additions and 2 deletions

View File

@ -13,8 +13,12 @@ export class MastodonService {
constructor(private readonly httpClient: HttpClient) { }
getInstance(instance: string): Promise<Instance> {
const route = `https://${instance}${this.apiRoutes.getInstance}`;
return this.httpClient.get<Instance>(route).toPromise();
let route = `https://${instance}${this.apiRoutes.getInstancev2}`;
return this.httpClient.get<Instance>(route).toPromise()
.catch(err => {
route = `https://${instance}${this.apiRoutes.getInstance}`;
return this.httpClient.get<Instance>(route).toPromise();
});
}
retrieveAccountDetails(account: AccountInfo): Promise<Account> {

View File

@ -25,6 +25,7 @@ export class ApiRoutes {
rejectFollowRequest = '/api/v1/follow_requests/{0}/reject';
followRemote = '/api/v1/follows';
getInstance = '/api/v1/instance';
getInstancev2 = '/api/v2/instance';
uploadMediaAttachment = '/api/v1/media';
updateMediaAttachment = '/api/v1/media/{0}';
getMutes = '/api/v1/mutes';