From fb9b6b120839b132def959662ff9248ecdd07d87 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 11 Oct 2024 12:20:08 +0100 Subject: [PATCH] thank you linters --- .../backend/src/core/NoteCreateService.ts | 2 +- packages/backend/src/core/NoteEditService.ts | 2 +- .../backend/src/core/WebhookTestService.ts | 19 +++++++++++++++++++ .../entities/NotificationEntityService.ts | 4 ++-- .../backend/src/models/json-schema/user.ts | 4 ++++ .../api/endpoints/notes/search-by-tag.ts | 6 ++++-- .../api/stream/channels/bubble-timeline.ts | 9 ++++----- .../src/server/web/ClientServerService.ts | 2 +- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 17325d62b5..29f7dd917d 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -576,7 +576,7 @@ export class NoteCreateService implements OnApplicationShutdown { // ハッシュタグ更新 if (data.visibility === 'public' || data.visibility === 'home') { - if (user.isBot && meta.enableBotTrending) { + if (user.isBot && this.meta.enableBotTrending) { this.hashtagService.updateHashtags(user, tags); } else if (!user.isBot) { this.hashtagService.updateHashtags(user, tags); diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index 1f861fd868..48c68777e3 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -13,7 +13,7 @@ import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mf import { extractHashtags } from '@/misc/extract-hashtags.js'; import type { IMentionedRemoteUsers } from '@/models/Note.js'; import { MiNote } from '@/models/Note.js'; -import type { NoteEditRepository, ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, MiFollowing, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository, PollsRepository } from '@/models/_.js'; +import type { NoteEditRepository, ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, MiFollowing, MiMeta, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository, PollsRepository } from '@/models/_.js'; import type { MiDriveFile } from '@/models/DriveFile.js'; import type { MiApp } from '@/models/App.js'; import { concat } from '@/misc/prelude/array.js'; diff --git a/packages/backend/src/core/WebhookTestService.ts b/packages/backend/src/core/WebhookTestService.ts index c2764f30e8..a41f41c44d 100644 --- a/packages/backend/src/core/WebhookTestService.ts +++ b/packages/backend/src/core/WebhookTestService.ts @@ -53,16 +53,22 @@ function generateDummyUser(override?: Partial): MiUser { avatar: null, bannerId: null, banner: null, + backgroundId: null, + background: null, avatarUrl: null, bannerUrl: null, + backgroundUrl: null, avatarBlurhash: null, bannerBlurhash: null, + backgroundBlurhash: null, avatarDecorations: [], tags: [], isSuspended: false, isLocked: false, + isSilenced: false, isBot: false, isCat: true, + speakAsCat: true, isRoot: false, isExplorable: true, isHibernated: false, @@ -76,6 +82,9 @@ function generateDummyUser(override?: Partial): MiUser { uri: null, followersUri: null, token: null, + approved: true, + signupReason: null, + noindex: false, ...override, }; } @@ -118,6 +127,7 @@ function generateDummyNote(override?: Partial): MiNote { replyUserHost: null, renoteUserId: null, renoteUserHost: null, + updatedAt: null, ...override, }; } @@ -182,9 +192,15 @@ function toPackedUserLite(user: MiUser, override?: Packed<'UserLite'>): Packed<' })), isBot: user.isBot, isCat: user.isCat, + speakAsCat: user.speakAsCat, emojis: user.emojis, onlineStatus: 'active', badgeRoles: [], + noindex: user.noindex, + isModerator: false, + isAdmin: false, + isSystem: false, + isSilenced: user.isSilenced, ...override, }; } @@ -201,6 +217,8 @@ function toPackedUserDetailedNotMe(user: MiUser, override?: Packed<'UserDetailed lastFetchedAt: user.lastFetchedAt?.toISOString() ?? null, bannerUrl: user.bannerUrl, bannerBlurhash: user.bannerBlurhash, + backgroundUrl: user.backgroundUrl, + backgroundBlurhash: user.backgroundBlurhash, isLocked: user.isLocked, isSilenced: false, isSuspended: user.isSuspended, @@ -236,6 +254,7 @@ function toPackedUserDetailedNotMe(user: MiUser, override?: Packed<'UserDetailed isRenoteMuted: false, notify: 'none', withReplies: true, + ListenBrainz: null, ...override, }; } diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index 8bfa2cc623..bbaf0cb7c8 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -59,7 +59,7 @@ export class NotificationEntityService implements OnModuleInit { async #packInternal ( src: T, meId: MiUser['id'], - + options: { checkValidNotifier?: boolean; }, @@ -236,7 +236,7 @@ export class NotificationEntityService implements OnModuleInit { public async pack( src: MiNotification | MiGroupedNotification, meId: MiUser['id'], - + options: { checkValidNotifier?: boolean; }, diff --git a/packages/backend/src/models/json-schema/user.ts b/packages/backend/src/models/json-schema/user.ts index fa93b019bd..9ed9ef828e 100644 --- a/packages/backend/src/models/json-schema/user.ts +++ b/packages/backend/src/models/json-schema/user.ts @@ -142,6 +142,10 @@ export const packedUserLiteSchema = { type: 'boolean', nullable: false, optional: true, }, + isSilenced: { + type: 'boolean', + nullable: false, optional: false, + }, instance: { type: 'object', nullable: false, optional: true, diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts index e01b09fb57..f079ab608d 100644 --- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts +++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts @@ -155,8 +155,10 @@ export default class extends Endpoint { // eslint- notes = notes.filter(note => { if (note.user?.isSilenced && me && followings && note.userId !== me.id && !followings[note.userId]) return false; if (note.user?.isSuspended) return false; - if (this.utilityService.isFederationAllowedHost(note.userHost)) return false; - if (this.utilityService.isSilencedHost(this.serverSettings.silencedHosts, note.userHost)) return false; + if (note.userHost) { + if (this.utilityService.isFederationAllowedHost(note.userHost)) return false; + if (this.utilityService.isSilencedHost(this.serverSettings.silencedHosts, note.userHost)) return false; + } return true; }); diff --git a/packages/backend/src/server/api/stream/channels/bubble-timeline.ts b/packages/backend/src/server/api/stream/channels/bubble-timeline.ts index 48c8535b83..8693f0c6ac 100644 --- a/packages/backend/src/server/api/stream/channels/bubble-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/bubble-timeline.ts @@ -5,7 +5,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import type { MiMeta } from '@/models/_.js'; import type { Packed } from '@/misc/json-schema.js'; import { MetaService } from '@/core/MetaService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; @@ -23,11 +22,10 @@ class BubbleTimelineChannel extends Channel { private withRenotes: boolean; private withFiles: boolean; private withBots: boolean; + private instance: MiMeta; constructor( - @Inject(DI.meta) - private serverSettings: MiMeta, - + private metaService: MetaService, private roleService: RoleService, private noteEntityService: NoteEntityService, @@ -46,6 +44,7 @@ class BubbleTimelineChannel extends Channel { this.withRenotes = !!(params.withRenotes ?? true); this.withFiles = !!(params.withFiles ?? false); this.withBots = !!(params.withBots ?? true); + this.instance = await this.metaService.fetch(); // Subscribe events this.subscriber.on('notesStream', this.onNote); @@ -56,7 +55,7 @@ class BubbleTimelineChannel extends Channel { if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return; if (!this.withBots && note.user.isBot) return; - if (!(note.user.host != null && this.serverSettings.bubbleInstances.includes(note.user.host) && note.visibility === 'public' )) return; + if (!(note.user.host != null && this.instance.bubbleInstances.includes(note.user.host) && note.visibility === 'public' )) return; if (note.channelId != null) return; diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index 24ab8b23df..4b760db89d 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -160,7 +160,7 @@ export class ClientServerService { }, { // 空文字列の場合右辺を使いたいため // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - 'src': instance.app512IconUrl || '/static-assets/icons/512.png', + 'src': this.meta.app512IconUrl || '/static-assets/icons/512.png', 'sizes': '300x300', 'type': 'image/png', 'purpose': 'any',