fix: fetching remote users on elk via megalodon

This commit is contained in:
Mar0xy 2023-09-25 12:21:10 +02:00
parent 151fcb2d5c
commit f15b7fb250
No known key found for this signature in database
GPG Key ID: 56569BBE47D2C828
1 changed files with 21 additions and 0 deletions

View File

@ -2035,6 +2035,27 @@ export default class Misskey implements MegalodonInterface {
})
}
}
const match = q.match(/^@?(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/);
if (match) {
const lookupQuery = {
username: match.groups?.user,
host: match.groups?.host,
};
return await this.client.post<MisskeyAPI.Entity.UserDetail>('/api/users/show', lookupQuery).then((res) => ({
...res,
data: {
accounts: [
MisskeyAPI.Converter.userDetail(
res.data,
this.baseUrl,
),
],
statuses: [],
hashtags: [],
},
}));
}
return this.client.post<Array<MisskeyAPI.Entity.UserDetail>>('/api/users/search', params).then(res => ({
...res,
data: {