fix code quality issues
This commit is contained in:
parent
e4ee9580e3
commit
4a615ff251
|
@ -90,15 +90,11 @@ export class NoteReadService implements OnApplicationShutdown {
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (notes.length === 0) return;
|
if (notes.length === 0) return;
|
||||||
|
|
||||||
const noteIds = new Set<MiNote['id']>();
|
const noteIds = new Set<MiNote['id']>(
|
||||||
|
notes.filter(note =>
|
||||||
for (const note of notes) {
|
(note.mentions?.includes(userId) ?? false) || (note.visibleUserIds?.includes(userId) ?? false)
|
||||||
if (note.mentions && note.mentions.includes(userId)) {
|
).map(note => note.id),
|
||||||
noteIds.add(note.id);
|
);
|
||||||
} else if (note.visibleUserIds && note.visibleUserIds.includes(userId)) {
|
|
||||||
noteIds.add(note.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noteIds.size === 0) return;
|
if (noteIds.size === 0) return;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import type { UsersRepository, NotesRepository, FollowingsRepository, AbuseUserR
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
import type { MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
import { isNotNull } from '@/misc/is-not-null.js';
|
||||||
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { getApHrefNullable, getApId, getApIds, getApType, isAccept, isActor, isAdd, isAnnounce, isBlock, isCollection, isCollectionOrOrderedCollection, isCreate, isDelete, isFlag, isFollow, isLike, isMove, isPost, isReject, isRemove, isTombstone, isUndo, isUpdate, validActor, validPost } from './type.js';
|
import { getApHrefNullable, getApId, getApIds, getApType, isAccept, isActor, isAdd, isAnnounce, isBlock, isCollection, isCollectionOrOrderedCollection, isCreate, isDelete, isFlag, isFollow, isLike, isMove, isPost, isReject, isRemove, isTombstone, isUndo, isUpdate, validActor, validPost } from './type.js';
|
||||||
import { ApNoteService } from './models/ApNoteService.js';
|
import { ApNoteService } from './models/ApNoteService.js';
|
||||||
import { ApLoggerService } from './ApLoggerService.js';
|
import { ApLoggerService } from './ApLoggerService.js';
|
||||||
|
@ -36,8 +37,6 @@ import { ApResolverService } from './ApResolverService.js';
|
||||||
import { ApAudienceService } from './ApAudienceService.js';
|
import { ApAudienceService } from './ApAudienceService.js';
|
||||||
import { ApPersonService } from './models/ApPersonService.js';
|
import { ApPersonService } from './models/ApPersonService.js';
|
||||||
import { ApQuestionService } from './models/ApQuestionService.js';
|
import { ApQuestionService } from './models/ApQuestionService.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
||||||
import type { Resolver } from './ApResolverService.js';
|
import type { Resolver } from './ApResolverService.js';
|
||||||
import type { IAccept, IAdd, IAnnounce, IBlock, ICreate, IDelete, IFlag, IFollow, ILike, IObject, IReject, IRemove, IUndo, IUpdate, IMove } from './type.js';
|
import type { IAccept, IAdd, IAnnounce, IBlock, ICreate, IDelete, IFlag, IFollow, ILike, IObject, IReject, IRemove, IUndo, IUpdate, IMove } from './type.js';
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,7 @@ export class NoteReactionEntityService implements OnModuleInit {
|
||||||
withNote: boolean;
|
withNote: boolean;
|
||||||
},
|
},
|
||||||
) : Promise<Packed<'NoteReaction'>[]> {
|
) : Promise<Packed<'NoteReaction'>[]> {
|
||||||
const opts = Object.assign({
|
const opts = { withNote: false, ...options };
|
||||||
withNote: false,
|
|
||||||
}, options);
|
|
||||||
|
|
||||||
return (await Promise.allSettled(reactions.map(x => this.pack(x, me, opts))))
|
return (await Promise.allSettled(reactions.map(x => this.pack(x, me, opts))))
|
||||||
.filter(result => result.status === 'fulfilled')
|
.filter(result => result.status === 'fulfilled')
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { DriveFilesRepository, GalleryPostsRepository } from '@/models/_.js';
|
import type { DriveFilesRepository, GalleryPostsRepository } from '@/models/_.js';
|
||||||
import { MiGalleryPost } from '@/models/GalleryPost.js';
|
import { MiGalleryPost } from '@/models/GalleryPost.js';
|
||||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import ms from 'ms';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { DriveFilesRepository, GalleryPostsRepository } from '@/models/_.js';
|
import type { DriveFilesRepository, GalleryPostsRepository } from '@/models/_.js';
|
||||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
|
||||||
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { isNotNull } from '@/misc/is-not-null.js';
|
import { isNotNull } from '@/misc/is-not-null.js';
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { IsNull } from 'typeorm';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { UsersRepository } from '@/models/_.js';
|
import type { UsersRepository } from '@/models/_.js';
|
||||||
import * as Acct from '@/misc/acct.js';
|
import * as Acct from '@/misc/acct.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
|
|
@ -97,10 +97,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
qb
|
qb
|
||||||
.from(this.noteReactionsRepository.metadata.targetName, 'reaction')
|
.from(this.noteReactionsRepository.metadata.targetName, 'reaction')
|
||||||
.where('"reaction"."userId" = :userId', { userId: ps.userId }),
|
.where('"reaction"."userId" = :userId', { userId: ps.userId }),
|
||||||
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate
|
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate,
|
||||||
),
|
),
|
||||||
'reaction',
|
'reaction',
|
||||||
'"reaction"."noteId" = note.id'
|
'"reaction"."noteId" = note.id',
|
||||||
);
|
);
|
||||||
|
|
||||||
this.queryService.generateVisibilityQuery(query, me);
|
this.queryService.generateVisibilityQuery(query, me);
|
||||||
|
|
Loading…
Reference in New Issue