This commit is contained in:
syuilo 2022-03-25 13:11:52 +09:00
parent 69702bc55e
commit b0eb9ea31e
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;

View File

@ -44,13 +44,8 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const note = await getNote(ps.noteId).catch(e => {
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
throw e;
});
const query = {
noteId: note.id,
noteId: ps.noteId,
} as DeepPartial<NoteReaction>;
if (ps.type) {

View File

@ -70,7 +70,7 @@ export default define(meta, paramDef, async (ps, me) => {
}).then(x => AbuseUserReports.findOneOrFail(x.identifiers[0]));
// Publish event to moderators
setTimeout(async () => {
setImmediate(async () => {
const moderators = await Users.find({
where: [{
isAdmin: true,
@ -94,5 +94,5 @@ export default define(meta, paramDef, async (ps, me) => {
sanitizeHtml(ps.comment),
sanitizeHtml(ps.comment));
}
}, 1);
});
});