Skip to content
Snippets Groups Projects
Commit 8aab828c authored by syuilo's avatar syuilo
Browse files

Better featured injection

parent c9f8c12f
No related branches found
No related tags found
No related merge requests found
import rndstr from 'rndstr';
import { Note } from '../../../models/entities/note';
import { User } from '../../../models/entities/user';
import { Notes, UserProfiles } from '../../../models';
import { Notes, UserProfiles, NoteReactions } from '../../../models';
import { generateMuteQuery } from './generate-mute-query';
import { ensure } from '../../../prelude/ensure';
......@@ -26,9 +26,17 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
.andWhere(`note.visibility = 'public'`)
.leftJoinAndSelect('note.user', 'user');
if (user) query.andWhere('note.userId != :userId', { userId: user.id });
if (user) {
query.andWhere('note.userId != :userId', { userId: user.id });
generateMuteQuery(query, user);
if (user) generateMuteQuery(query, user);
const reactionQuery = NoteReactions.createQueryBuilder('reaction')
.select('reaction.noteId')
.where('reaction.userId = :userId', { userId: user.id });
query.andWhere(`note.id NOT IN (${ reactionQuery.getQuery() })`);
}
const notes = await query
.orderBy('note.score', 'DESC')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment