summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes
diff options
context:
space:
mode:
authorHazel K <acomputerdog@gmail.com>2024-10-02 15:02:22 -0400
committerHazel K <acomputerdog@gmail.com>2024-10-02 15:02:22 -0400
commit19d7d44d0e3d2df2dfe717eed8716404523cf989 (patch)
tree6d502b1bba8745e5074cc90035ddb262d618088f /packages/backend/src/server/api/endpoints/notes
parentMerge branch 'develop' into hazelnoot/following-timeline (diff)
downloadsharkey-19d7d44d0e3d2df2dfe717eed8716404523cf989.tar.gz
sharkey-19d7d44d0e3d2df2dfe717eed8716404523cf989.tar.bz2
sharkey-19d7d44d0e3d2df2dfe717eed8716404523cf989.zip
use QueryService for blocks and mutes
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/following.ts23
1 files changed, 4 insertions, 19 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/following.ts b/packages/backend/src/server/api/endpoints/notes/following.ts
index ac9730f631..89ffc83604 100644
--- a/packages/backend/src/server/api/endpoints/notes/following.ts
+++ b/packages/backend/src/server/api/endpoints/notes/following.ts
@@ -54,7 +54,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
let query = this.notesRepository
.createQueryBuilder('note')
- .innerJoin(MiUserProfile, 'user_profile', ':me = user_profile."userId"')
.setParameter('me', me.id)
// Limit to latest notes
@@ -68,24 +67,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('renote.user', 'renoteUser')
.leftJoinAndSelect('note.channel', 'channel')
- // Respect blocks and mutes for latest note
- .leftJoin(MiBlocking, 'blocking_note', 'note."userId" = blocking_note."blockerId"')
- .leftJoin(MiMuting, 'muting_note', 'note."userId" = muting_note."muteeId"')
- .andWhere('blocking_note.id IS NULL AND muting_note.id IS NULL')
- .andWhere('(note."userHost" IS NULL OR NOT user_profile."mutedInstances" ? note."userHost")')
-
- // Respect blocks and mutes for renote
- .leftJoin(MiBlocking, 'blocking_renote', 'renote."userId" IS NOT NULL AND renote."userId" = blocking_renote."blockerId"')
- .leftJoin(MiMuting, 'muting_renote', 'renote."userId" IS NOT NULL AND renote."userId" = muting_renote."muteeId"')
- .andWhere('blocking_renote.id IS NULL AND muting_renote.id IS NULL')
- .andWhere('(renote."userHost" IS NULL OR NOT user_profile."mutedInstances" ? renote."userHost")')
-
- // Respect blocks and mutes for reply
- .leftJoin(MiBlocking, 'blocking_reply', 'reply."userId" IS NOT NULL AND reply."userId" = blocking_reply."blockerId"')
- .leftJoin(MiMuting, 'muting_reply', 'reply."userId" IS NOT NULL AND reply."userId" = muting_reply."muteeId"')
- .andWhere('blocking_reply.id IS NULL AND muting_reply.id IS NULL')
- .andWhere('(reply."userHost" IS NULL OR NOT user_profile."mutedInstances" ? reply."userHost")')
-
// Limit to followers
.innerJoin(MiFollowing, 'following', 'latest.user_id = following."followeeId"')
.andWhere('following."followerId" = :me');
@@ -96,6 +77,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.innerJoin(MiFollowing, 'mutuals', 'latest.user_id = mutuals."followerId" AND mutuals."followeeId" = :me');
}
+ // Respect blocks and mutes
+ this.queryService.generateBlockedUserQuery(query, me)
+ this.queryService.generateMutedUserQuery(query, me);
+
// Support pagination
query = this.queryService
.makePaginationQuery(query, ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)