mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 15:16:44 -06:00
refactor
This commit is contained in:
parent
6f5282058f
commit
22b56ac65c
4 changed files with 5 additions and 14 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue