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

This commit is contained in:
Tatsuya Koishi 2024-01-27 19:31:58 +09:00
parent 2d7a2a3d6a
commit 5667f5affd
2 changed files with 12 additions and 6 deletions

View File

@ -919,7 +919,8 @@ export class NoteCreateService implements OnApplicationShutdown {
const config = loadConfig(); const config = loadConfig();
let defaultTag:string | null = config.tagging.defaultTag; let defaultTag:string | null = config.tagging.defaultTag;
if (defaultTag != null) { if (defaultTag != null) {
if (note.visibility === 'public' && note.tags.includes(normalizeForSearch(defaultTag))) { const noteTags = note.tags ? note.tags.map((t: string) => t.toLowerCase()) : [];
if (note.visibility === 'public' && noteTags.includes(normalizeForSearch(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

@ -155,11 +155,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
let defaultTag:string | null = config.tagging.defaultTag; let 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( .andWhere(new Brackets(qb => {
(defaultTag == null) qb.andWhere('note.visibility = \'public\'');
? '(note.visibility = \'public\') AND (note.userHost IS NULL) AND (note.channelId IS NULL)' qb.andWhere('note.channelId IS NULL');
: `(note.visibility = 'public') AND ('${normalizeForSearch(defaultTag)}' = any(note.tags) AND (note.channelId IS NULL)` if (defaultTag == null) {
) qb.andWhere('note.userHost IS NULL');
} else {
qb.andWhere(`':t' = any(note.tags)`, { t: normalizeForSearch(defaultTag) });
}
}
))
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply') .leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote') .leftJoinAndSelect('note.renote', 'renote')