モロヘイヤ使用の場合等、タグの追記はオフにできるように。

This commit is contained in:
Tatsuya Koishi 2024-01-28 11:14:44 +09:00
parent 36cfe398d2
commit f216585421
8 changed files with 24 additions and 20 deletions

View file

@ -194,5 +194,6 @@ signToActivityPubGet: true
# Upload or download file size limits (bytes) # Upload or download file size limits (bytes)
#maxFileSize: 262144000 #maxFileSize: 262144000
tagging: defaultTag:
defaultTag: null tag: null
append: true

View file

@ -226,5 +226,6 @@ signToActivityPubGet: true
# PID File of master process # PID File of master process
#pidFile: /tmp/misskey.pid #pidFile: /tmp/misskey.pid
tagging: defaultTag:
defaultTag: null tag: null
append: true

View file

@ -56,8 +56,9 @@ type Source = {
index: string; index: string;
scope?: 'local' | 'global' | string[]; scope?: 'local' | 'global' | string[];
}; };
tagging: { defaultTag: {
defaultTag: string; tag: string;
append: boolean;
}; };
proxy?: string; proxy?: string;
@ -127,8 +128,9 @@ export type Config = {
index: string; index: string;
scope?: 'local' | 'global' | string[]; scope?: 'local' | 'global' | string[];
} | undefined; } | undefined;
tagging: { defaultTag: {
defaultTag: string; tag: string;
append: boolean;
}; };
proxy: string | undefined; proxy: string | undefined;
proxySmtp: string | undefined; proxySmtp: string | undefined;
@ -267,7 +269,7 @@ export function loadConfig(): Config {
perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 500, perUserNotificationsMaxCount: config.perUserNotificationsMaxCount ?? 500,
deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7), deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7),
pidFile: config.pidFile, pidFile: config.pidFile,
tagging: config.tagging, defaultTag: config.defaultTag,
}; };
} }

View file

@ -320,10 +320,10 @@ export class NoteCreateService implements OnApplicationShutdown {
data.localOnly = true; data.localOnly = true;
} }
// デフォルトハッシュタグ処理 // デフォルトハッシュタグを本文末尾に書き足す
if (['public', 'home'].includes(data.visibility)) { if (this.config.defaultTag?.append && ['public', 'home'].includes(data.visibility)) {
if (this.config.tagging?.defaultTag != null) { if (this.config.defaultTag?.tag != null) {
const tag = `#${this.config.tagging?.defaultTag}`; const tag = `#${this.config.defaultTag?.tag}`;
if (String(data.text).match(tag)) { if (String(data.text).match(tag)) {
data.text = `${data.text}\n\n${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()) : []; 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('localTimelineWithReplies', note.id, 300, r);
this.fanoutTimelineService.push('localTimeline', note.id, 1000, r); this.fanoutTimelineService.push('localTimeline', note.id, 1000, r);
if (note.fileIds.length > 0) { if (note.fileIds.length > 0) {

View file

@ -201,7 +201,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} }
const config = loadConfig(); const config = loadConfig();
const defaultTag: string | null = config.tagging?.defaultTag; const defaultTag: string | null = config.defaultTag?.tag;
if (defaultTag == null) { if (defaultTag == null) {
qb.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); qb.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');
} else { } else {

View file

@ -152,7 +152,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withReplies: boolean, withReplies: boolean,
}, me: MiLocalUser | null) { }, me: MiLocalUser | null) {
const config = loadConfig(); 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'), const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
ps.sinceId, ps.untilId) ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => { .andWhere(new Brackets(qb => {

View file

@ -47,7 +47,7 @@ class HybridTimelineChannel extends Channel {
this.withReplies = params.withReplies ?? false; this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles ?? false; this.withFiles = params.withFiles ?? false;
const config = loadConfig(); const config = loadConfig();
this.defaultTag = config.tagging?.defaultTag; this.defaultTag = config.defaultTag?.tag;
// Subscribe events // Subscribe events
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);

View file

@ -45,7 +45,7 @@ class LocalTimelineChannel extends Channel {
this.withReplies = params.withReplies ?? false; this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles ?? false; this.withFiles = params.withFiles ?? false;
const config = loadConfig(); const config = loadConfig();
this.defaultTag = config.tagging?.defaultTag; this.defaultTag = config.defaultTag?.tag;
// Subscribe events // Subscribe events
this.subscriber.on('notesStream', this.onNote); this.subscriber.on('notesStream', this.onNote);