1
0
mirror of https://github.com/NicolasConstant/sengi synced 2025-01-18 11:53:58 +01:00

more resilient status search

This commit is contained in:
Nicolas Constant 2020-08-28 21:35:50 -04:00
parent f3f63f569a
commit 58c1f04609
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688

View File

@ -224,12 +224,17 @@ export class ToolsService {
if (!isProvider) {
statusPromise = statusPromise
.then((foreignStatus: Status) => {
const statusUrl = foreignStatus.url;
const statusUri = foreignStatus.uri;
const statusUrl = foreignStatus.url;
return this.getInstanceInfo(account)
.then(instance => {
let version: 'v1' | 'v2' = 'v1';
if (instance.major >= 3) version = 'v2';
return this.mastodonService.search(account, statusUrl, version, true);
return this.mastodonService.search(account, statusUri, version, true)
.then((results: Results) => {
if(results && results.statuses.length > 0) return results;
return this.mastodonService.search(account, statusUrl, version, true);
});
})
.then((results: Results) => {
return results.statuses[0];