6cf466e5d1
* update deps * fix * wip * wip * wip * Update docker-compose.yml.example * Delete reviewer-lottery.yml * Update RepositoryModule.ts * wip * wip * clean up * update deps * wip * wip
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
import type { ClipFavoritesRepository } from '@/models/_.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { ClipEntityService } from '@/core/entities/ClipEntityService.js';
|
|
|
|
export const meta = {
|
|
tags: ['account', 'clip'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'read:clip-favorite',
|
|
|
|
res: {
|
|
type: 'array',
|
|
optional: false, nullable: false,
|
|
items: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
ref: 'Clip',
|
|
},
|
|
},
|
|
} as const;
|
|
|
|
export const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
},
|
|
required: [],
|
|
} as const;
|
|
|
|
@Injectable()
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
|
constructor(
|
|
@Inject(DI.clipFavoritesRepository)
|
|
private clipFavoritesRepository: ClipFavoritesRepository,
|
|
|
|
private clipEntityService: ClipEntityService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const query = this.clipFavoritesRepository.createQueryBuilder('favorite')
|
|
.andWhere('favorite.userId = :meId', { meId: me.id })
|
|
.leftJoinAndSelect('favorite.clip', 'clip');
|
|
|
|
const favorites = await query
|
|
.getMany();
|
|
|
|
return this.clipEntityService.packMany(favorites.map(x => x.clip!), me);
|
|
});
|
|
}
|
|
}
|