なんかもうめっちゃ変えた
This commit is contained in:
parent
d9ab03f086
commit
b75184ec8e
946 changed files with 41219 additions and 28839 deletions
|
@ -1,8 +1,11 @@
|
|||
import { In } from 'typeorm';
|
||||
import { ClipNotes, Clips } from '@/models/index.js';
|
||||
import define from '../../define.js';
|
||||
import { getNote } from '../../common/getters.js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ClipNotesRepository, ClipsRepository } from '@/models/index.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { ClipEntityService } from '@/core/entities/ClipEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../error.js';
|
||||
import { GetterService } from '../../common/GetterService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['clips', 'notes'],
|
||||
|
@ -37,20 +40,34 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const note = await getNote(ps.noteId).catch(e => {
|
||||
if (e.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw e;
|
||||
});
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.clipsRepository)
|
||||
private clipsRepository: ClipsRepository,
|
||||
|
||||
const clipNotes = await ClipNotes.findBy({
|
||||
noteId: note.id,
|
||||
});
|
||||
@Inject(DI.clipNotesRepository)
|
||||
private clipNotesRepository: ClipNotesRepository,
|
||||
|
||||
const clips = await Clips.findBy({
|
||||
id: In(clipNotes.map(x => x.clipId)),
|
||||
isPublic: true,
|
||||
});
|
||||
private clipEntityService: ClipEntityService,
|
||||
private getterService: GetterService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const note = await this.getterService.getNote(ps.noteId).catch(err => {
|
||||
if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw err;
|
||||
});
|
||||
|
||||
return await Promise.all(clips.map(x => Clips.pack(x)));
|
||||
});
|
||||
const clipNotes = await this.clipNotesRepository.findBy({
|
||||
noteId: note.id,
|
||||
});
|
||||
|
||||
const clips = await this.clipsRepository.findBy({
|
||||
id: In(clipNotes.map(x => x.clipId)),
|
||||
isPublic: true,
|
||||
});
|
||||
|
||||
return await Promise.all(clips.map(x => this.clipEntityService.pack(x)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue