From 232a86566c3023a943d08fe8391ba82fb7f9b87b Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 23 Apr 2023 16:20:00 -0400 Subject: [PATCH] support v2 instance, fix #504 --- src/app/services/mastodon.service.ts | 8 ++++++-- src/app/services/models/api.settings.ts | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/services/mastodon.service.ts b/src/app/services/mastodon.service.ts index 1cef131c..14adb701 100644 --- a/src/app/services/mastodon.service.ts +++ b/src/app/services/mastodon.service.ts @@ -13,8 +13,12 @@ export class MastodonService { constructor(private readonly httpClient: HttpClient) { } getInstance(instance: string): Promise { - const route = `https://${instance}${this.apiRoutes.getInstance}`; - return this.httpClient.get(route).toPromise(); + let route = `https://${instance}${this.apiRoutes.getInstancev2}`; + return this.httpClient.get(route).toPromise() + .catch(err => { + route = `https://${instance}${this.apiRoutes.getInstance}`; + return this.httpClient.get(route).toPromise(); + }); } retrieveAccountDetails(account: AccountInfo): Promise { diff --git a/src/app/services/models/api.settings.ts b/src/app/services/models/api.settings.ts index f0bb1c10..50e8d614 100644 --- a/src/app/services/models/api.settings.ts +++ b/src/app/services/models/api.settings.ts @@ -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';