From 6d49edc0ab7af36f5d0d54397ddb1eacbb9c18b4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 8 Apr 2018 15:25:17 +0900 Subject: [PATCH] :v: --- src/remote/resolve-user.ts | 5 +++++ src/server/api/endpoints/users/show.ts | 4 ---- src/server/webfinger.ts | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/remote/resolve-user.ts b/src/remote/resolve-user.ts index 9e1ae5195..0e7edd8e1 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 d272ce463..7e7f5dc48 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 fd7ebc3fb..dbf0999f3 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}` }] }); });