diff --git a/src/remote/resolve-user.ts b/src/remote/resolve-user.ts index 9e1ae51952..0e7edd8e12 100644 --- a/src/remote/resolve-user.ts +++ b/src/remote/resolve-user.ts @@ -2,12 +2,17 @@ import { toUnicode, toASCII } from 'punycode'; import User from '../models/user'; import resolvePerson from './activitypub/resolve-person'; import webFinger from './webfinger'; +import config from '../config'; export default async (username, host, option) => { const usernameLower = username.toLowerCase(); const hostLowerAscii = toASCII(host).toLowerCase(); const hostLower = toUnicode(hostLowerAscii); + if (config.host == hostLower) { + return await User.findOne({ usernameLower }); + } + let user = await User.findOne({ usernameLower, hostLower }, option); if (user === null) { diff --git a/src/server/api/endpoints/users/show.ts b/src/server/api/endpoints/users/show.ts index d272ce4639..7e7f5dc488 100644 --- a/src/server/api/endpoints/users/show.ts +++ b/src/server/api/endpoints/users/show.ts @@ -9,10 +9,6 @@ const cursorOption = { fields: { data: false } }; /** * Show a user - * - * @param {any} params - * @param {any} me - * @return {Promise} */ module.exports = (params, me) => new Promise(async (res, rej) => { let user; diff --git a/src/server/webfinger.ts b/src/server/webfinger.ts index fd7ebc3fb5..dbf0999f3e 100644 --- a/src/server/webfinger.ts +++ b/src/server/webfinger.ts @@ -4,9 +4,9 @@ import config from '../config'; import parseAcct from '../acct/parse'; import User from '../models/user'; -const app = express(); +const app = express.Router(); -app.get('/.well-known/webfinger', async (req: express.Request, res: express.Response) => { +app.get('/.well-known/webfinger', async (req, res) => { if (typeof req.query.resource !== 'string') { return res.sendStatus(400); } @@ -38,11 +38,14 @@ app.get('/.well-known/webfinger', async (req: express.Request, res: express.Resp links: [{ rel: 'self', type: 'application/activity+json', - href: `${config.url}/@${user.username}` + href: `${config.url}/users/${user._id}` }, { rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: `${config.url}/@${user.username}` + }, { + rel: 'http://ostatus.org/schema/1.0/subscribe', + template: `${config.url}/authorize-follow?acct={uri}` }] }); });