feat: bootstrap from Fabric monorepo
This commit is contained in:
31
src/channels/channels.service.ts
Normal file
31
src/channels/channels.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Channel } from '../entities/channel.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ChannelsService {
|
||||
constructor(
|
||||
@InjectRepository(Channel)
|
||||
private readonly channelRepo: Repository<Channel>,
|
||||
) {}
|
||||
|
||||
listByGuild(guildId: string) {
|
||||
return this.channelRepo.find({
|
||||
where: { guildId },
|
||||
order: { createdAt: 'ASC' },
|
||||
take: 200,
|
||||
});
|
||||
}
|
||||
|
||||
create(input: Partial<Channel>) {
|
||||
const channel = this.channelRepo.create({
|
||||
guildId: String(input.guildId ?? ''),
|
||||
name: String(input.name ?? ''),
|
||||
kind: input.kind === 'announcement' ? 'announcement' : 'text',
|
||||
isPrivate: Boolean(input.isPrivate),
|
||||
lastSeq: 0,
|
||||
});
|
||||
return this.channelRepo.save(channel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user