Skip to content

Commit

Permalink
インポートで防げてないのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Oct 18, 2024
1 parent 48719eb commit d96b2b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import { Inject, Injectable } from '@nestjs/common';
import { IsNull } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { MiMeta } from '@/models/Meta.js';
import type { UsersRepository, DriveFilesRepository } from '@/models/_.js';
import type Logger from '@/logger.js';
import * as Acct from '@/misc/acct.js';
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
import { DownloadService } from '@/core/DownloadService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { RoleService } from '@/core/RoleService.js';
import { bindThis } from '@/decorators.js';
import { QueueService } from '@/core/QueueService.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
Expand All @@ -23,12 +25,16 @@ export class ImportBlockingProcessorService {
private logger: Logger;

constructor(
@Inject(DI.meta)
private serverSettings: MiMeta,

@Inject(DI.usersRepository)
private usersRepository: UsersRepository,

@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,

private roleService: RoleService,
private queueService: QueueService,
private utilityService: UtilityService,
private remoteUserResolveService: RemoteUserResolveService,
Expand Down Expand Up @@ -93,6 +99,15 @@ export class ImportBlockingProcessorService {
// skip myself
if (target.id === job.data.user.id) return;

// skip if server prohibits blocking
if (
this.serverSettings.forciblyFollowedUsers.includes(target.id) &&
!await this.roleService.isModerator({ id: user.id, isRoot: false })
) {
this.logger.warn(`Cannot block due to server policy: ${target.id}`);
return;
}

this.logger.info(`Block ${target.id} ...`);

this.queueService.createBlockJob([{ from: { id: user.id }, to: { id: target.id }, silent: true }]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import { Inject, Injectable } from '@nestjs/common';
import { IsNull } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { MiMeta } from '@/models/Meta.js';
import type { UsersRepository, DriveFilesRepository } from '@/models/_.js';
import type Logger from '@/logger.js';
import * as Acct from '@/misc/acct.js';
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
import { DownloadService } from '@/core/DownloadService.js';
import { UserMutingService } from '@/core/UserMutingService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { RoleService } from '@/core/RoleService.js';
import { bindThis } from '@/decorators.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
import type * as Bull from 'bullmq';
Expand All @@ -23,12 +25,16 @@ export class ImportMutingProcessorService {
private logger: Logger;

constructor(
@Inject(DI.meta)
private serverSettings: MiMeta,

@Inject(DI.usersRepository)
private usersRepository: UsersRepository,

@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,

private roleService: RoleService,
private utilityService: UtilityService,
private userMutingService: UserMutingService,
private remoteUserResolveService: RemoteUserResolveService,
Expand Down Expand Up @@ -88,6 +94,15 @@ export class ImportMutingProcessorService {
// skip myself
if (target.id === job.data.user.id) continue;

// skip if server prohibits muting
if (
this.serverSettings.forciblyFollowedUsers.includes(target.id) &&
!await this.roleService.isModerator({ id: user.id, isRoot: false })
) {
this.logger.info(`Skip[${linenum}] ${target.id} because of server policy ...`);
continue;
}

this.logger.info(`Mute[${linenum}] ${target.id} ...`);

await this.userMutingService.mute(user, target);
Expand Down

0 comments on commit d96b2b8

Please sign in to comment.