mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-13 14:18:10 +09:00
Better featured injection
This commit is contained in:
parent
aa0eef5f1d
commit
aa01f232a3
@ -1,7 +1,7 @@
|
|||||||
import rndstr from 'rndstr';
|
import rndstr from 'rndstr';
|
||||||
import { Note } from '../../../models/entities/note';
|
import { Note } from '../../../models/entities/note';
|
||||||
import { User } from '../../../models/entities/user';
|
import { User } from '../../../models/entities/user';
|
||||||
import { Notes, UserProfiles } from '../../../models';
|
import { Notes, UserProfiles, NoteReactions } from '../../../models';
|
||||||
import { generateMuteQuery } from './generate-mute-query';
|
import { generateMuteQuery } from './generate-mute-query';
|
||||||
import { ensure } from '../../../prelude/ensure';
|
import { ensure } from '../../../prelude/ensure';
|
||||||
|
|
||||||
@ -26,9 +26,17 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
|
|||||||
.andWhere(`note.visibility = 'public'`)
|
.andWhere(`note.visibility = 'public'`)
|
||||||
.leftJoinAndSelect('note.user', 'user');
|
.leftJoinAndSelect('note.user', 'user');
|
||||||
|
|
||||||
if (user) query.andWhere('note.userId != :userId', { userId: user.id });
|
if (user) {
|
||||||
|
query.andWhere('note.userId != :userId', { userId: user.id });
|
||||||
|
|
||||||
if (user) generateMuteQuery(query, 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
|
const notes = await query
|
||||||
.orderBy('note.score', 'DESC')
|
.orderBy('note.score', 'DESC')
|
||||||
|
Loading…
Reference in New Issue
Block a user