forked from mirror/misskey
33 lines
949 B
TypeScript
33 lines
949 B
TypeScript
|
import { Inject, Injectable } from '@nestjs/common';
|
||
|
import { UsersRepository, MutingsRepository } from '@/models/index.js';
|
||
|
import { IdService } from '@/core/IdService.js';
|
||
|
import { QueueService } from '@/core/QueueService.js';
|
||
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||
|
import type { User } from '@/models/entities/User.js';
|
||
|
import { DI } from '@/di-symbols.js';
|
||
|
|
||
|
@Injectable()
|
||
|
export class UserMutingService {
|
||
|
constructor(
|
||
|
@Inject(DI.usersRepository)
|
||
|
private usersRepository: UsersRepository,
|
||
|
|
||
|
@Inject(DI.mutingsRepository)
|
||
|
private mutingsRepository: MutingsRepository,
|
||
|
|
||
|
private idService: IdService,
|
||
|
private queueService: QueueService,
|
||
|
private globalEventServie: GlobalEventService,
|
||
|
) {
|
||
|
}
|
||
|
|
||
|
public async mute(user: User, target: User): Promise<void> {
|
||
|
await this.mutingsRepository.insert({
|
||
|
id: this.idService.genId(),
|
||
|
createdAt: new Date(),
|
||
|
muterId: user.id,
|
||
|
muteeId: target.id,
|
||
|
});
|
||
|
}
|
||
|
}
|