fix: exported antenna data cannot be imported in some cases (#15985)

* chore: add ExportedAntenna type

* chore: use ExportedAntenna on export and fix schema

* fix: excludeNotesInSensitiveChannel is not included

* chore: revert unnecessary changes

* chore: add doc for future developer

* docs: update changelog
This commit is contained in:
anatawa12 2025-05-09 17:48:01 +09:00 committed by GitHub
parent ebf291084f
commit 0bd44bca6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 5 deletions

View File

@ -15,7 +15,8 @@
- Enhance: メモリ使用量を軽減しました - Enhance: メモリ使用量を軽減しました
### Server ### Server
- - Fix: ユーザ除外アンテナをインポートできない問題を修正
- Fix: アンテナのセンシティブなチャンネルのノートを含むかどうかの情報がエクスポートされない問題を修正
## 2025.5.0 ## 2025.5.0

View File

@ -106,3 +106,6 @@ export class MiAntenna {
}) })
public excludeNotesInSensitiveChannel: boolean; public excludeNotesInSensitiveChannel: boolean;
} }
// Note for future developers: When you added a new column,
// You should update ExportAntennaProcessorService and ImportAntennaProcessorService
// to export and import antennas correctly.

View File

@ -15,6 +15,7 @@ import { bindThis } from '@/decorators.js';
import { createTemp } from '@/misc/create-temp.js'; import { createTemp } from '@/misc/create-temp.js';
import { UtilityService } from '@/core/UtilityService.js'; import { UtilityService } from '@/core/UtilityService.js';
import { NotificationService } from '@/core/NotificationService.js'; import { NotificationService } from '@/core/NotificationService.js';
import { ExportedAntenna } from '@/queue/processors/ImportAntennasProcessorService.js';
import { QueueLoggerService } from '../QueueLoggerService.js'; import { QueueLoggerService } from '../QueueLoggerService.js';
import type { DBExportAntennasData } from '../types.js'; import type { DBExportAntennasData } from '../types.js';
import type * as Bull from 'bullmq'; import type * as Bull from 'bullmq';
@ -86,7 +87,8 @@ export class ExportAntennasProcessorService {
excludeBots: antenna.excludeBots, excludeBots: antenna.excludeBots,
withReplies: antenna.withReplies, withReplies: antenna.withReplies,
withFile: antenna.withFile, withFile: antenna.withFile,
})); excludeNotesInSensitiveChannel: antenna.excludeNotesInSensitiveChannel,
} satisfies Required<ExportedAntenna>));
if (antennas.length - 1 !== index) { if (antennas.length - 1 !== index) {
write(', '); write(', ');
} }

View File

@ -11,17 +11,18 @@ import Logger from '@/logger.js';
import type { AntennasRepository } from '@/models/_.js'; import type { AntennasRepository } from '@/models/_.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { Schema, SchemaType } from '@/misc/json-schema.js';
import { QueueLoggerService } from '../QueueLoggerService.js'; import { QueueLoggerService } from '../QueueLoggerService.js';
import { DBAntennaImportJobData } from '../types.js'; import { DBAntennaImportJobData } from '../types.js';
import type * as Bull from 'bullmq'; import type * as Bull from 'bullmq';
const Ajv = _Ajv.default; const Ajv = _Ajv.default;
const validate = new Ajv().compile({ const exportedAntennaSchema = {
type: 'object', type: 'object',
properties: { properties: {
name: { type: 'string', minLength: 1, maxLength: 100 }, name: { type: 'string', minLength: 1, maxLength: 100 },
src: { type: 'string', enum: ['home', 'all', 'users', 'list'] }, src: { type: 'string', enum: ['home', 'all', 'users', 'list', 'users_blacklist'] },
userListAccts: { userListAccts: {
type: 'array', type: 'array',
items: { items: {
@ -47,9 +48,14 @@ const validate = new Ajv().compile({
excludeBots: { type: 'boolean' }, excludeBots: { type: 'boolean' },
withReplies: { type: 'boolean' }, withReplies: { type: 'boolean' },
withFile: { type: 'boolean' }, withFile: { type: 'boolean' },
excludeNotesInSensitiveChannel: { type: 'boolean' },
}, },
required: ['name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile'], required: ['name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile'],
}); } as const satisfies Schema;
export type ExportedAntenna = SchemaType<typeof exportedAntennaSchema>;
const validate = new Ajv().compile<ExportedAntenna>(exportedAntennaSchema);
@Injectable() @Injectable()
export class ImportAntennasProcessorService { export class ImportAntennasProcessorService {
@ -91,6 +97,7 @@ export class ImportAntennasProcessorService {
excludeBots: antenna.excludeBots, excludeBots: antenna.excludeBots,
withReplies: antenna.withReplies, withReplies: antenna.withReplies,
withFile: antenna.withFile, withFile: antenna.withFile,
excludeNotesInSensitiveChannel: antenna.excludeNotesInSensitiveChannel,
}); });
this.logger.succ('Antenna created: ' + result.id); this.logger.succ('Antenna created: ' + result.id);
this.globalEventService.publishInternalEvent('antennaCreated', result); this.globalEventService.publishInternalEvent('antennaCreated', result);