diff --git a/.config/docker_example.yml b/.config/docker_example.yml index afef8f650b..292f79e696 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -194,5 +194,6 @@ signToActivityPubGet: true # Upload or download file size limits (bytes) #maxFileSize: 262144000 -tagging: - defaultTag: null +defaultTag: + tag: null + append: true diff --git a/.config/example.yml b/.config/example.yml index d2f1660c77..42f460ed07 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -226,5 +226,6 @@ signToActivityPubGet: true # PID File of master process #pidFile: /tmp/misskey.pid -tagging: - defaultTag: null +defaultTag: + tag: null + append: true diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 281b0892e4..797fe5ae4d 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -56,8 +56,9 @@ type Source = { index: string; scope?: 'local' | 'global' | string[]; }; - tagging: { - defaultTag: string; + defaultTag: { + tag: string; + append: boolean; }; proxy?: string; @@ -127,8 +128,9 @@ export type Config = { index: string; scope?: 'local' | 'global' | string[]; } | undefined; - tagging: { - defaultTag: string; + defaultTag: { + tag: string; + append: boolean; }; proxy: string | undefined; proxySmtp: string | undefined; @@ -267,7 +269,7 @@ export function loadConfig(): Config { perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 500, deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7), pidFile: config.pidFile, - tagging: config.tagging, + defaultTag: config.defaultTag, }; } diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 5460735799..35694f727d 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -320,10 +320,10 @@ export class NoteCreateService implements OnApplicationShutdown { data.localOnly = true; } - // デフォルトハッシュタグ処理 - if (['public', 'home'].includes(data.visibility)) { - if (this.config.tagging?.defaultTag != null) { - const tag = `#${this.config.tagging?.defaultTag}`; + // デフォルトハッシュタグを本文末尾に書き足す + if (this.config.defaultTag?.append && ['public', 'home'].includes(data.visibility)) { + if (this.config.defaultTag?.tag != null) { + const tag = `#${this.config.defaultTag?.tag}`; if (String(data.text).match(tag)) { data.text = `${data.text}\n\n${tag}`; } @@ -923,10 +923,10 @@ export class NoteCreateService implements OnApplicationShutdown { } } - // デフォルトハッシュタグ - if (this.config.tagging?.defaultTag != null) { + // デフォルトハッシュタグを含む投稿は、リモートであってもローカルタイムラインに含める + if (this.config.defaultTag?.tag != null) { const noteTags = note.tags ? note.tags.map((t: string) => t.toLowerCase()) : []; - if (note.visibility === 'public' && noteTags.includes(normalizeForSearch(this.config.tagging?.defaultTag))) { + if (note.visibility === 'public' && noteTags.includes(normalizeForSearch(this.config.defaultTag?.tag))) { this.fanoutTimelineService.push('localTimelineWithReplies', note.id, 300, r); this.fanoutTimelineService.push('localTimeline', note.id, 1000, r); if (note.fileIds.length > 0) { diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index 2b25bec1c5..855cbd1852 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -201,7 +201,7 @@ export default class extends Endpoint { // eslint- } const config = loadConfig(); - const defaultTag: string | null = config.tagging?.defaultTag; + const defaultTag: string | null = config.defaultTag?.tag; if (defaultTag == null) { qb.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); } else { diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 1c49023073..8c6b605e67 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -152,7 +152,7 @@ export default class extends Endpoint { // eslint- withReplies: boolean, }, me: MiLocalUser | null) { const config = loadConfig(); - const defaultTag: string | null = config.tagging?.defaultTag; + const defaultTag: string | null = config.defaultTag?.tag; const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) .andWhere(new Brackets(qb => { diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 38196a9c68..d6759845ab 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -47,7 +47,7 @@ class HybridTimelineChannel extends Channel { this.withReplies = params.withReplies ?? false; this.withFiles = params.withFiles ?? false; const config = loadConfig(); - this.defaultTag = config.tagging?.defaultTag; + this.defaultTag = config.defaultTag?.tag; // Subscribe events this.subscriber.on('notesStream', this.onNote); diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index f8d97a6aab..15b4d60786 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -45,7 +45,7 @@ class LocalTimelineChannel extends Channel { this.withReplies = params.withReplies ?? false; this.withFiles = params.withFiles ?? false; const config = loadConfig(); - this.defaultTag = config.tagging?.defaultTag; + this.defaultTag = config.defaultTag?.tag; // Subscribe events this.subscriber.on('notesStream', this.onNote);