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

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 => ({ return this.client.post<Array<MisskeyAPI.Entity.UserDetail>>('/api/users/search', params).then(res => ({
...res, ...res,
data: { data: {