hostLowerは廃止してhostにlowerしたものを入れるように
This commit is contained in:
parent
26c979bcec
commit
d81c20f163
|
@ -66,7 +66,6 @@ export type INote = {
|
||||||
};
|
};
|
||||||
_user: {
|
_user: {
|
||||||
host: string;
|
host: string;
|
||||||
hostLower: string;
|
|
||||||
account: {
|
account: {
|
||||||
inbox?: string;
|
inbox?: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 },
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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');
|
||||||
|
|
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
|
@ -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, {
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue