Add user lookup

This commit is contained in:
Laura Hausmann 2023-07-05 20:58:54 +02:00
parent f8c328ff55
commit 996663d449
Signed by: zotan
GPG key ID: D044E84C5BE01605

View file

@ -2355,6 +2355,39 @@ export default class Misskey implements MegalodonInterface {
limit: 20
})
}
try {
const match = q.match(/^@(?<user>.*?)(?:@(?<host>.*?)|)$/);
if (match) {
const lookupQuery = {
username: match.groups?.user,
host: match.groups?.host
};
const result = await this.client.post<MisskeyAPI.Entity.UserDetail>('/api/users/show', lookupQuery).then(res => ({
...res,
data: {
accounts: [this.converter.userDetail(res.data, this.baseUrlToHost(this.baseUrl))],
statuses: [],
hashtags: []
}
}));
if (result.status !== 200) {
result.status = 200;
result.statusText = "OK";
result.data = {
accounts: [],
statuses: [],
hashtags: []
};
}
return result;
}
}
catch {}
return this.client.post<Array<MisskeyAPI.Entity.UserDetail>>('/api/users/search', params).then(res => ({
...res,
data: {