summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-14 14:39:07 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-14 14:39:07 +0900
commitd81c20f163f0884d04cd11e46221bfefc0ac9f22 (patch)
tree68a7b4120540f580975eb21978b19d5375fd61b3 /src
parentBetter indexes (diff)
downloadmisskey-d81c20f163f0884d04cd11e46221bfefc0ac9f22.tar.gz
misskey-d81c20f163f0884d04cd11e46221bfefc0ac9f22.tar.bz2
misskey-d81c20f163f0884d04cd11e46221bfefc0ac9f22.zip
hostLowerは廃止してhostにlowerしたものを入れるように
Diffstat (limited to 'src')
-rw-r--r--src/models/note.ts1
-rw-r--r--src/models/user.ts1
-rw-r--r--src/queue/processors/http/process-inbox.ts2
-rw-r--r--src/remote/activitypub/objects/person.ts4
-rw-r--r--src/remote/resolve-user.ts12
-rw-r--r--src/server/api/common/get-host-lower.ts2
-rw-r--r--src/server/api/endpoints/users/notes.ts2
-rw-r--r--src/server/api/private/signup.ts1
-rw-r--r--src/services/note/create.ts1
9 files changed, 10 insertions, 16 deletions
diff --git a/src/models/note.ts b/src/models/note.ts
index 3c1c2e18e1..6d315db4cf 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -66,7 +66,6 @@ export type INote = {
};
_user: {
host: string;
- hostLower: string;
account: {
inbox?: string;
};
diff --git a/src/models/user.ts b/src/models/user.ts
index 97b7a997e5..cf5a4a3616 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -49,7 +49,6 @@ type IUserBase = {
isSuspended: boolean;
keywords: string[];
host: string;
- hostLower: string;
};
export interface ILocalUser extends IUserBase {
diff --git a/src/queue/processors/http/process-inbox.ts b/src/queue/processors/http/process-inbox.ts
index ce5b7d5a89..a2c6bf4f90 100644
--- a/src/queue/processors/http/process-inbox.ts
+++ b/src/queue/processors/http/process-inbox.ts
@@ -32,7 +32,7 @@ export default async (job: kue.Job, done): Promise<void> => {
return;
}
- user = await User.findOne({ usernameLower: username, hostLower: host }) as IRemoteUser;
+ user = await User.findOne({ usernameLower: username, host: host.toLowerCase() }) as IRemoteUser;
} else {
user = await User.findOne({
host: { $ne: null },
diff --git a/src/remote/activitypub/objects/person.ts b/src/remote/activitypub/objects/person.ts
index f7ec064cdb..6c060f879c 100644
--- a/src/remote/activitypub/objects/person.ts
+++ b/src/remote/activitypub/objects/person.ts
@@ -74,8 +74,7 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
webFinger(person.id)
]);
- const host = toUnicode(finger.subject.replace(/^.*?@/, ''));
- const hostLower = host.replace(/[A-Z]+/, matched => matched.toLowerCase());
+ const host = toUnicode(finger.subject.replace(/^.*?@/, '')).toLowerCase();
const summaryDOM = JSDOM.fragment(person.summary);
// Create user
@@ -92,7 +91,6 @@ export async function createPerson(value: any, resolver?: Resolver): Promise<IUs
username: person.preferredUsername,
usernameLower: person.preferredUsername.toLowerCase(),
host,
- hostLower,
publicKey: {
id: person.publicKey.id,
publicKeyPem: person.publicKey.publicKeyPem
diff --git a/src/remote/resolve-user.ts b/src/remote/resolve-user.ts
index 346e134c9f..5cb35cadef 100644
--- a/src/remote/resolve-user.ts
+++ b/src/remote/resolve-user.ts
@@ -4,19 +4,19 @@ import webFinger from './webfinger';
import config from '../config';
import { createPerson } from './activitypub/objects/person';
-export default async (username, host, option) => {
+export default async (username, _host, option) => {
const usernameLower = username.toLowerCase();
- const hostLowerAscii = toASCII(host).toLowerCase();
- const hostLower = toUnicode(hostLowerAscii);
+ const hostAscii = toASCII(_host).toLowerCase();
+ const host = toUnicode(hostAscii);
- if (config.host == hostLower) {
+ if (config.host == host) {
return await User.findOne({ usernameLower });
}
- let user = await User.findOne({ usernameLower, hostLower }, option);
+ let user = await User.findOne({ usernameLower, host }, option);
if (user === null) {
- const acctLower = `${usernameLower}@${hostLowerAscii}`;
+ const acctLower = `${usernameLower}@${hostAscii}`;
const finger = await webFinger(acctLower);
const self = finger.links.find(link => link.rel && link.rel.toLowerCase() === 'self');
diff --git a/src/server/api/common/get-host-lower.ts b/src/server/api/common/get-host-lower.ts
index fc4b30439e..550c233001 100644
--- a/src/server/api/common/get-host-lower.ts
+++ b/src/server/api/common/get-host-lower.ts
@@ -1,5 +1,5 @@
import { toUnicode } from 'punycode';
export default host => {
- return toUnicode(host).replace(/[A-Z]+/, match => match.toLowerCase());
+ return toUnicode(host).toLowerCase();
};
diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts
index e91b75e1d3..bd4247c79c 100644
--- a/src/server/api/endpoints/users/notes.ts
+++ b/src/server/api/endpoints/users/notes.ts
@@ -65,7 +65,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const q = userId !== undefined
? { _id: userId }
- : { usernameLower: username.toLowerCase(), hostLower: getHostLower(host) } ;
+ : { usernameLower: username.toLowerCase(), host: getHostLower(host) } ;
// Lookup user
const user = await User.findOne(q, {
diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts
index 15257b869f..cf51dec4d2 100644
--- a/src/server/api/private/signup.ts
+++ b/src/server/api/private/signup.ts
@@ -118,7 +118,6 @@ export default async (ctx: Koa.Context) => {
username: username,
usernameLower: username.toLowerCase(),
host: null,
- hostLower: null,
keypair: generateKeypair(),
token: secret,
email: null,
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index b238cd5607..603851adb5 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -78,7 +78,6 @@ export default async (user: IUser, data: {
_renote: data.renote ? { userId: data.renote.userId } : null,
_user: {
host: user.host,
- hostLower: user.hostLower,
inbox: isRemoteUser(user) ? user.inbox : undefined
}
};