diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-22 06:49:12 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-22 06:49:12 +0900 |
| commit | 8aab828c65f432898a7844caf86d6732a3c758fc (patch) | |
| tree | a841a28fc987c9ff6e207918859ad229e55a067e /src/server/api/common | |
| parent | :pizza: (diff) | |
| download | sharkey-8aab828c65f432898a7844caf86d6732a3c758fc.tar.gz sharkey-8aab828c65f432898a7844caf86d6732a3c758fc.tar.bz2 sharkey-8aab828c65f432898a7844caf86d6732a3c758fc.zip | |
Better featured injection
Diffstat (limited to 'src/server/api/common')
| -rw-r--r-- | src/server/api/common/inject-featured.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/server/api/common/inject-featured.ts b/src/server/api/common/inject-featured.ts index 91b12cadce..92e1e3b396 100644 --- a/src/server/api/common/inject-featured.ts +++ b/src/server/api/common/inject-featured.ts @@ -1,7 +1,7 @@ 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') |