デフォルトハッシュタグタイムライン

This commit is contained in:
Tatsuya Koishi 2024-01-28 00:11:04 +09:00
parent de32e55ee4
commit bc3899f56f
5 changed files with 18 additions and 11 deletions

View file

@ -59,7 +59,6 @@ import { UtilityService } from '@/core/UtilityService.js';
import { UserBlockingService } from '@/core/UserBlockingService.js'; import { UserBlockingService } from '@/core/UserBlockingService.js';
import { isReply } from '@/misc/is-reply.js'; import { isReply } from '@/misc/is-reply.js';
import { trackPromise } from '@/misc/promise-tracker.js'; import { trackPromise } from '@/misc/promise-tracker.js';
import { loadConfig } from '@/config.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -321,6 +320,16 @@ export class NoteCreateService implements OnApplicationShutdown {
data.localOnly = true; data.localOnly = true;
} }
// デフォルトハッシュタグ処理
if (['public', 'home'].includes(data.visibility)) {
if (this.config.tagging.defaultTag != null) {
const tag = `#${this.config.tagging.defaultTag}`;
if (String(data.text).match(tag)) {
data.text = `${data.text}\n\n${tag}`;
}
}
}
if (data.text) { if (data.text) {
if (data.text.length > DB_MAX_NOTE_TEXT_LENGTH) { if (data.text.length > DB_MAX_NOTE_TEXT_LENGTH) {
data.text = data.text.slice(0, DB_MAX_NOTE_TEXT_LENGTH); data.text = data.text.slice(0, DB_MAX_NOTE_TEXT_LENGTH);
@ -915,11 +924,9 @@ export class NoteCreateService implements OnApplicationShutdown {
} }
// デフォルトハッシュタグ // デフォルトハッシュタグ
const config = loadConfig(); if (this.config.tagging.defaultTag != null) {
let defaultTag:string | null = config.tagging.defaultTag;
if (defaultTag != 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(defaultTag))) { if (note.visibility === 'public' && noteTags.includes(normalizeForSearch(this.config.tagging.defaultTag))) {
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();
let defaultTag:string | null = config.tagging.defaultTag; const defaultTag: string | null = config.tagging.defaultTag;
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();
let defaultTag:string | null = config.tagging.defaultTag; const defaultTag: string | null = config.tagging.defaultTag;
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

@ -24,7 +24,7 @@ class HybridTimelineChannel extends Channel {
private withRenotes: boolean; private withRenotes: boolean;
private withReplies: boolean; private withReplies: boolean;
private withFiles: boolean; private withFiles: boolean;
private defaultTag: string; private defaultTag: string | null;
constructor( constructor(
private metaService: MetaService, private metaService: MetaService,

View file

@ -22,7 +22,7 @@ class LocalTimelineChannel extends Channel {
private withRenotes: boolean; private withRenotes: boolean;
private withReplies: boolean; private withReplies: boolean;
private withFiles: boolean; private withFiles: boolean;
private defaultTag: string; private defaultTag: string | null;
constructor( constructor(
private metaService: MetaService, private metaService: MetaService,