refactor: resolve #7139
This commit is contained in:
parent
ebadd7fd3f
commit
91172654e4
76 changed files with 107 additions and 221 deletions
|
|
@ -3,7 +3,6 @@ import { Note } from '../../../models/entities/note';
|
|||
import { User } from '../../../models/entities/user';
|
||||
import { Notes, UserProfiles, NoteReactions } from '../../../models';
|
||||
import { generateMutedUserQuery } from './generate-muted-user-query';
|
||||
import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
// TODO: リアクション、Renote、返信などをしたノートは除外する
|
||||
|
||||
|
|
@ -11,7 +10,7 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
|
|||
if (timeline.length < 5) return;
|
||||
|
||||
if (user) {
|
||||
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
if (!profile.injectFeaturedNote) return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import rndstr from 'rndstr';
|
|||
import { Note } from '../../../models/entities/note';
|
||||
import { User } from '../../../models/entities/user';
|
||||
import { PromoReads, PromoNotes, Notes, Users } from '../../../models';
|
||||
import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
export async function injectPromo(timeline: Note[], user?: User | null) {
|
||||
if (timeline.length < 5) return;
|
||||
|
|
@ -23,10 +22,10 @@ export async function injectPromo(timeline: Note[], user?: User | null) {
|
|||
// Pick random promo
|
||||
const promo = promos[Math.floor(Math.random() * promos.length)];
|
||||
|
||||
const note = await Notes.findOne(promo.noteId).then(ensure);
|
||||
const note = await Notes.findOneOrFail(promo.noteId);
|
||||
|
||||
// Join
|
||||
note.user = await Users.findOne(note.userId).then(ensure);
|
||||
note.user = await Users.findOneOrFail(note.userId);
|
||||
|
||||
(note as any)._prId_ = rndstr('a-z0-9', 8);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue