summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-06-03 15:17:55 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-06-03 15:17:55 -0400
commit4b58752a16e01f13950e13adfcc5a5069a05f716 (patch)
treed23904e0059621598a73b4a285ee4f075983d091 /packages/backend/src/server/api
parentsync up bubble timeline endpoint and stream (diff)
downloadsharkey-4b58752a16e01f13950e13adfcc5a5069a05f716.tar.gz
sharkey-4b58752a16e01f13950e13adfcc5a5069a05f716.tar.bz2
sharkey-4b58752a16e01f13950e13adfcc5a5069a05f716.zip
copy changes to global-timeline.ts
Diffstat (limited to 'packages/backend/src/server/api')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/global-timeline.ts38
1 files changed, 12 insertions, 26 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
index e82d9ca7af..6ebb3c1676 100644
--- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
@@ -12,7 +12,6 @@ import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
import { DI } from '@/di-symbols.js';
import { RoleService } from '@/core/RoleService.js';
-import { CacheService } from '@/core/CacheService.js';
import { ApiError } from '../../error.js';
export const meta = {
@@ -68,7 +67,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private queryService: QueryService,
private roleService: RoleService,
private activeUsersChart: ActiveUsersChart,
- private cacheService: CacheService,
) {
super(meta, paramDef, async (ps, me) => {
const policies = await this.roleService.getUserPolicies(me ? me.id : null);
@@ -76,8 +74,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.gtlDisabled);
}
- const followings = me ? await this.cacheService.userFollowingsCache.fetch(me.id) : {};
-
//#region Construct query
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
@@ -86,15 +82,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.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.generateBlockedHostQueryForNote(query);
-
+ this.queryService.generateSilencedUserQueryForNotes(query, me);
if (me) {
this.queryService.generateMutedUserQueryForNotes(query, me);
this.queryService.generateBlockedUserQueryForNotes(query, me);
- this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
}
if (ps.withFiles) {
@@ -103,29 +98,20 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (!ps.withBots) query.andWhere('user.isBot = FALSE');
- if (ps.withRenotes === false) {
- query.andWhere(new Brackets(qb => {
- qb.where('note.renoteId IS NULL');
- qb.orWhere(new Brackets(qb => {
- qb.where('note.text IS NOT NULL');
- qb.orWhere('note.fileIds != \'{}\'');
- }));
- }));
+ if (!ps.withRenotes) {
+ this.queryService.generateExcludedRenotesQueryForNotes(query);
+ } else if (me) {
+ this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
}
//#endregion
- let timeline = await query.limit(ps.limit).getMany();
+ const timeline = await query.limit(ps.limit).getMany();
- timeline = timeline.filter(note => {
- if (note.user?.isSilenced && me && followings && note.userId !== me.id && !followings[note.userId]) return false;
- return true;
- });
-
- process.nextTick(() => {
- if (me) {
+ if (me) {
+ process.nextTick(() => {
this.activeUsersChart.read(me);
- }
- });
+ });
+ }
return await this.noteEntityService.packMany(timeline, me);
});