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
54 lines
1.4 KiB
TypeScript
54 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 { ChannelsRepository } from '@/models/_.js';
|
|
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
|
import { DI } from '@/di-symbols.js';
|
|
|
|
export const meta = {
|
|
tags: ['channels'],
|
|
|
|
requireCredential: false,
|
|
|
|
res: {
|
|
type: 'array',
|
|
optional: false, nullable: false,
|
|
items: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
ref: 'Channel',
|
|
},
|
|
},
|
|
} 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.channelsRepository)
|
|
private channelsRepository: ChannelsRepository,
|
|
|
|
private channelEntityService: ChannelEntityService,
|
|
) {
|
|
super(meta, paramDef, async (ps, me) => {
|
|
const query = this.channelsRepository.createQueryBuilder('channel')
|
|
.where('channel.lastNotedAt IS NOT NULL')
|
|
.andWhere('channel.isArchived = FALSE')
|
|
.orderBy('channel.lastNotedAt', 'DESC');
|
|
|
|
const channels = await query.limit(10).getMany();
|
|
|
|
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));
|
|
});
|
|
}
|
|
}
|