[backend] We don't need to check for visibility if we already filter for public posts only

This commit is contained in:
Laura Hausmann 2023-11-22 03:40:29 +01:00
parent 6bc42c2a9b
commit eff0f32dc1
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 4 additions and 9 deletions

View File

@ -88,7 +88,8 @@ export default define(meta, paramDef, async (ps, user) => {
ps.sinceDate, ps.sinceDate,
ps.untilDate, ps.untilDate,
) )
.andWhere("(note.visibility = 'public') AND (note.userHost IS NULL)") .andWhere("note.visibility = 'public'")
.andWhere("note.userHost IS NULL")
.innerJoinAndSelect("note.user", "user") .innerJoinAndSelect("note.user", "user")
.leftJoinAndSelect("user.avatar", "avatar") .leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner") .leftJoinAndSelect("user.banner", "banner")
@ -103,7 +104,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user); generateChannelQuery(query, user);
generateRepliesQuery(query, ps.withReplies, user); generateRepliesQuery(query, ps.withReplies, user);
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user); if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user); if (user) generateBlockedUserQuery(query, user);
@ -133,7 +133,6 @@ export default define(meta, paramDef, async (ps, user) => {
); );
} }
} }
query.andWhere("note.visibility != 'hidden'");
//#endregion //#endregion
process.nextTick(() => { process.nextTick(() => {

View File

@ -88,10 +88,8 @@ export default define(meta, paramDef, async (ps, user) => {
ps.sinceDate, ps.sinceDate,
ps.untilDate, ps.untilDate,
) )
.andWhere( .andWhere(`note.userHost IN (:...instances)`, { instances: m.recommendedInstances })
`(note.userHost = ANY ('{"${m.recommendedInstances.join('","')}"}'))`, .andWhere("note.visibility = 'public'")
)
.andWhere("(note.visibility = 'public')")
.innerJoinAndSelect("note.user", "user") .innerJoinAndSelect("note.user", "user")
.leftJoinAndSelect("user.avatar", "avatar") .leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner") .leftJoinAndSelect("user.banner", "banner")
@ -106,7 +104,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user); generateChannelQuery(query, user);
generateRepliesQuery(query, ps.withReplies, user); generateRepliesQuery(query, ps.withReplies, user);
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user); if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user); if (user) generateBlockedUserQuery(query, user);
@ -136,7 +133,6 @@ export default define(meta, paramDef, async (ps, user) => {
); );
} }
} }
query.andWhere("note.visibility != 'hidden'");
//#endregion //#endregion
process.nextTick(() => { process.nextTick(() => {