This commit is contained in:
syuilo 2018-04-08 15:25:17 +09:00
parent e63f884bc6
commit 6d49edc0ab
3 changed files with 11 additions and 7 deletions

View File

@ -2,12 +2,17 @@ import { toUnicode, toASCII } from 'punycode';
import User from '../models/user'; import User from '../models/user';
import resolvePerson from './activitypub/resolve-person'; import resolvePerson from './activitypub/resolve-person';
import webFinger from './webfinger'; import webFinger from './webfinger';
import config from '../config';
export default async (username, host, option) => { export default async (username, host, option) => {
const usernameLower = username.toLowerCase(); const usernameLower = username.toLowerCase();
const hostLowerAscii = toASCII(host).toLowerCase(); const hostLowerAscii = toASCII(host).toLowerCase();
const hostLower = toUnicode(hostLowerAscii); const hostLower = toUnicode(hostLowerAscii);
if (config.host == hostLower) {
return await User.findOne({ usernameLower });
}
let user = await User.findOne({ usernameLower, hostLower }, option); let user = await User.findOne({ usernameLower, hostLower }, option);
if (user === null) { if (user === null) {

View File

@ -9,10 +9,6 @@ const cursorOption = { fields: { data: false } };
/** /**
* Show a user * Show a user
*
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/ */
module.exports = (params, me) => new Promise(async (res, rej) => { module.exports = (params, me) => new Promise(async (res, rej) => {
let user; let user;

View File

@ -4,9 +4,9 @@ import config from '../config';
import parseAcct from '../acct/parse'; import parseAcct from '../acct/parse';
import User from '../models/user'; 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') { if (typeof req.query.resource !== 'string') {
return res.sendStatus(400); return res.sendStatus(400);
} }
@ -38,11 +38,14 @@ app.get('/.well-known/webfinger', async (req: express.Request, res: express.Resp
links: [{ links: [{
rel: 'self', rel: 'self',
type: 'application/activity+json', type: 'application/activity+json',
href: `${config.url}/@${user.username}` href: `${config.url}/users/${user._id}`
}, { }, {
rel: 'http://webfinger.net/rel/profile-page', rel: 'http://webfinger.net/rel/profile-page',
type: 'text/html', type: 'text/html',
href: `${config.url}/@${user.username}` href: `${config.url}/@${user.username}`
}, {
rel: 'http://ostatus.org/schema/1.0/subscribe',
template: `${config.url}/authorize-follow?acct={uri}`
}] }]
}); });
}); });