1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-03 09:18:46 +09:00

hostLowerは廃止してhostにlowerしたものを入れるように

This commit is contained in:
syuilo 2018-04-14 14:39:07 +09:00
parent 26c979bcec
commit d81c20f163
9 changed files with 10 additions and 16 deletions

View File

@ -66,7 +66,6 @@ export type INote = {
}; };
_user: { _user: {
host: string; host: string;
hostLower: string;
account: { account: {
inbox?: string; inbox?: string;
}; };

View File

@ -49,7 +49,6 @@ type IUserBase = {
isSuspended: boolean; isSuspended: boolean;
keywords: string[]; keywords: string[];
host: string; host: string;
hostLower: string;
}; };
export interface ILocalUser extends IUserBase { export interface ILocalUser extends IUserBase {

View File

@ -32,7 +32,7 @@ export default async (job: kue.Job, done): Promise<void> => {
return; return;
} }
user = await User.findOne({ usernameLower: username, hostLower: host }) as IRemoteUser; user = await User.findOne({ usernameLower: username, host: host.toLowerCase() }) as IRemoteUser;
} else { } else {
user = await User.findOne({ user = await User.findOne({
host: { $ne: null }, host: { $ne: null },

View File

@ -74,8 +74,7 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
webFinger(person.id) webFinger(person.id)
]); ]);
const host = toUnicode(finger.subject.replace(/^.*?@/, '')); const host = toUnicode(finger.subject.replace(/^.*?@/, '')).toLowerCase();
const hostLower = host.replace(/[A-Z]+/, matched => matched.toLowerCase());
const summaryDOM = JSDOM.fragment(person.summary); const summaryDOM = JSDOM.fragment(person.summary);
// Create user // Create user
@ -92,7 +91,6 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
username: person.preferredUsername, username: person.preferredUsername,
usernameLower: person.preferredUsername.toLowerCase(), usernameLower: person.preferredUsername.toLowerCase(),
host, host,
hostLower,
publicKey: { publicKey: {
id: person.publicKey.id, id: person.publicKey.id,
publicKeyPem: person.publicKey.publicKeyPem publicKeyPem: person.publicKey.publicKeyPem

View File

@ -4,19 +4,19 @@ import webFinger from './webfinger';
import config from '../config'; import config from '../config';
import { createPerson } from './activitypub/objects/person'; import { createPerson } from './activitypub/objects/person';
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 hostAscii = toASCII(_host).toLowerCase();
const hostLower = toUnicode(hostLowerAscii); const host = toUnicode(hostAscii);
if (config.host == hostLower) { if (config.host == host) {
return await User.findOne({ usernameLower }); return await User.findOne({ usernameLower });
} }
let user = await User.findOne({ usernameLower, hostLower }, option); let user = await User.findOne({ usernameLower, host }, option);
if (user === null) { if (user === null) {
const acctLower = `${usernameLower}@${hostLowerAscii}`; const acctLower = `${usernameLower}@${hostAscii}`;
const finger = await webFinger(acctLower); const finger = await webFinger(acctLower);
const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self'); const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self');

View File

@ -1,5 +1,5 @@
import { toUnicode } from 'punycode'; import { toUnicode } from 'punycode';
export default host => { export default host => {
return toUnicode(host).replace(/[A-Z]+/, match => match.toLowerCase()); return toUnicode(host).toLowerCase();
}; };

View File

@ -65,7 +65,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const q = userId !== undefined const q = userId !== undefined
? { _id: userId } ? { _id: userId }
: { usernameLower: username.toLowerCase(), hostLower: getHostLower(host) } ; : { usernameLower: username.toLowerCase(), host: getHostLower(host) } ;
// Lookup user // Lookup user
const user = await User.findOne(q, { const user = await User.findOne(q, {

View File

@ -118,7 +118,6 @@ export default async (ctx: Koa.Context) => {
username: username, username: username,
usernameLower: username.toLowerCase(), usernameLower: username.toLowerCase(),
host: null, host: null,
hostLower: null,
keypair: generateKeypair(), keypair: generateKeypair(),
token: secret, token: secret,
email: null, email: null,

View File

@ -78,7 +78,6 @@ export default async (user: IUser, data: {
_renote: data.renote ? { userId: data.renote.userId } : null, _renote: data.renote ? { userId: data.renote.userId } : null,
_user: { _user: {
host: user.host, host: user.host,
hostLower: user.hostLower,
inbox: isRemoteUser(user) ? user.inbox : undefined inbox: isRemoteUser(user) ? user.inbox : undefined
} }
}; };