summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-03 15:44:50 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-03 15:44:50 -0400
commit6896bcea9dde208f8a7939d0f7949b82cf62eeb4 (patch)
treeb4049fa0d2379d33c04815475ac7e02f1551096e /packages/backend/src/server/api/endpoints
parentcopy changes to antennas/notes.ts (diff)
downloadsharkey-6896bcea9dde208f8a7939d0f7949b82cf62eeb4.tar.gz
sharkey-6896bcea9dde208f8a7939d0f7949b82cf62eeb4.tar.bz2
sharkey-6896bcea9dde208f8a7939d0f7949b82cf62eeb4.zip
copy changes to mentions.ts
Diffstat (limited to 'packages/backend/src/server/api/endpoints')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/mentions.ts30
1 files changed, 16 insertions, 14 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts
index 269b57366c..7c54bc69ab 100644
--- a/packages/backend/src/server/api/endpoints/notes/mentions.ts
+++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts
@@ -10,6 +10,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { QueryService } from '@/core/QueryService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { DI } from '@/di-symbols.js';
+import ActiveUsersChart from '@/core/chart/charts/active-users.js';
export const meta = {
tags: ['notes'],
@@ -57,43 +58,44 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private noteEntityService: NoteEntityService,
private queryService: QueryService,
+ private readonly activeUsersChart: ActiveUsersChart,
) {
super(meta, paramDef, async (ps, me) => {
- const followingQuery = this.followingsRepository.createQueryBuilder('following')
- .select('following.followeeId')
- .where('following.followerId = :followerId', { followerId: me.id });
-
- const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
- .andWhere(new Brackets(qb => {
- qb // このmeIdAsListパラメータはqueryServiceのgenerateVisibilityQueryでセットされる
- .where(':meIdAsList <@ note.mentions')
- .orWhere(':meIdAsList <@ note.visibleUserIds');
- }))
+ const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
+ ps.sinceId, ps.untilId)
+ .andWhere(new Brackets(qb => qb
+ .orWhere(':meId = ANY (note.mentions)')
+ .orWhere(':meId = ANY (note.visibleUserIds)')))
+ .setParameters({ meId: me.id })
// Avoid scanning primary key index
.orderBy('CONCAT(note.id)', 'DESC')
.innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply')
.leftJoinAndSelect('note.renote', 'renote')
- .leftJoinAndSelect('reply.user', 'replyUser')
- .leftJoinAndSelect('renote.user', 'renoteUser');
+ .leftJoinAndSelect('reply.user', 'replyUser', 'replyUser.id = note.replyUserId')
+ .leftJoinAndSelect('renote.user', 'renoteUser', 'renoteUser.id = note.renoteUserId');
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateBlockedHostQueryForNote(query);
this.queryService.generateMutedUserQueryForNotes(query, me);
this.queryService.generateMutedNoteThreadQuery(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
+ this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
if (ps.visibility) {
query.andWhere('note.visibility = :visibility', { visibility: ps.visibility });
}
if (ps.following) {
- query.andWhere(`((note.userId IN (${ followingQuery.getQuery() })) OR (note.userId = :meId))`, { meId: me.id });
- query.setParameters(followingQuery.getParameters());
+ this.queryService.andFollowingUser(query, ':meId', 'note.userId');
}
const mentions = await query.limit(ps.limit).getMany();
+ process.nextTick(() => {
+ this.activeUsersChart.read(me);
+ });
+
return await this.noteEntityService.packMany(mentions, me);
});
}