From 996663d449a5b098c7c0ac0ffb404fdc0786e049 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 5 Jul 2023 20:58:54 +0200 Subject: [PATCH] Add user lookup --- megalodon/src/misskey.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/megalodon/src/misskey.ts b/megalodon/src/misskey.ts index 7a348d2..cc94478 100644 --- a/megalodon/src/misskey.ts +++ b/megalodon/src/misskey.ts @@ -2355,6 +2355,39 @@ export default class Misskey implements MegalodonInterface { limit: 20 }) } + + try { + const match = q.match(/^@(?.*?)(?:@(?.*?)|)$/); + if (match) { + const lookupQuery = { + username: match.groups?.user, + host: match.groups?.host + }; + + const result = await this.client.post('/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>('/api/users/search', params).then(res => ({ ...res, data: {