This commit is contained in:
syuilo
2022-03-25 13:11:52 +09:00
parent 6f5282058f
commit 22b56ac65c
4 changed files with 5 additions and 14 deletions

View File

@@ -1,6 +1,4 @@
import { Cache } from "@/misc/cache.js";
import { Note } from "@/models/entities/note.js";
import { User } from "@/models/entities/user.js";
export const userCache = new Cache<User | null>(1000 * 60 * 30);
export const noteCache = new Cache<Note | null>(1000 * 60 * 30);

View File

@@ -5,16 +5,14 @@ import renderOrderedCollection from '@/remote/activitypub/renderer/ordered-colle
import { setResponseType } from '../activitypub.js';
import renderNote from '@/remote/activitypub/renderer/note.js';
import { Users, Notes, UserNotePinings } from '@/models/index.js';
import { userCache } from './cache.js';
export default async (ctx: Router.RouterContext) => {
const userId = ctx.params.user;
// TODO: typeorm 3.0にしたら .then(x => x || null) は消せる
const user = await userCache.fetch(userId, () => Users.findOne({
const user = await Users.findOne({
id: userId,
host: null,
}).then(x => x || null));
});
if (user == null) {
ctx.status = 404;