From 9de201fdb376a3bf4d0bc4f6eabb2c6db4888f53 Mon Sep 17 00:00:00 2001 From: FruitRiin Date: Thu, 14 Nov 2024 09:57:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A6=8B=E3=81=A4=E3=81=91=E3=82=8B?= =?UTF-8?q?=EF=BC=9E=E3=83=8F=E3=82=A4=E3=83=A9=E3=82=A4=E3=83=88=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=81=B5=E3=81=81=E3=81=BC=E3=81=99=E3=81=9F=E3=83=BC?= =?UTF-8?q?=E3=82=92=E6=84=9F=E3=81=98=E3=82=8B=E6=A9=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkNote.vue | 15 +++++++++++++-- packages/frontend/src/components/MkNotes.vue | 10 ++++++---- packages/frontend/src/pages/explore.featured.vue | 4 ++-- packages/frontend/vite.config.local-dev.ts | 13 +++++++++---- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index cf0d0787b18b..dcff4a279cea 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -64,7 +64,7 @@ SPDX-License-Identifier: AGPL-3.0-only

-
+
({{ i18n.ts.private }}) (), { mock: false, + featured: false, }); provide('mock', props.mock); @@ -623,6 +625,15 @@ function emitUpdReaction(emoji: string, delta: number) { overflow: clip; contain: content; + .akafav { + font-size: 2rem; + color: red; + } + .aofav { + font-size: 1.5rem; + color: blue; + } + &:focus-visible { outline: none; diff --git a/packages/frontend/src/components/MkNotes.vue b/packages/frontend/src/components/MkNotes.vue index 1c17c6b6912c..0c70fa8d662e 100644 --- a/packages/frontend/src/components/MkNotes.vue +++ b/packages/frontend/src/components/MkNotes.vue @@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only :ad="true" :class="$style.notes" > - +
@@ -39,11 +39,14 @@ import MkPagination, { Paging } from '@/components/MkPagination.vue'; import { i18n } from '@/i18n.js'; import { infoImageUrl } from '@/instance.js'; -const props = defineProps<{ +const props = withDefaults(defineProps<{ pagination: Paging; noGap?: boolean; disableAutoLoad?: boolean; -}>(); + featured: boolean; +}>(), { + featured: false, +}); const pagingComponent = shallowRef>(); @@ -63,7 +66,6 @@ defineExpose({ &:not(.noGap) { > .notes { background: var(--MI_THEME-bg); - .note { background: var(--MI_THEME-panel); border-radius: var(--MI-radius); diff --git a/packages/frontend/src/pages/explore.featured.vue b/packages/frontend/src/pages/explore.featured.vue index 8b16a88ff3b7..ae8b940af430 100644 --- a/packages/frontend/src/pages/explore.featured.vue +++ b/packages/frontend/src/pages/explore.featured.vue @@ -9,8 +9,8 @@ SPDX-License-Identifier: AGPL-3.0-only - - + + diff --git a/packages/frontend/vite.config.local-dev.ts b/packages/frontend/vite.config.local-dev.ts index 922fb459958f..ef82175f3431 100644 --- a/packages/frontend/vite.config.local-dev.ts +++ b/packages/frontend/vite.config.local-dev.ts @@ -13,9 +13,14 @@ const defaultConfig = getConfig(); const { port } = yaml.load(await readFile('../../.config/default.yml', 'utf-8')); -const httpUrl = `http://localhost:${port}/`; -const websocketUrl = `ws://localhost:${port}/`; -const embedUrl = `http://localhost:5174/`; + +const mistemsDebug = false + +const hostingPort = mistemsDebug ? 5180 : 5173 ; +const httpUrl = mistemsDebug ? `https://misskey.systems/` : `http://localhost:${port}/`; +const websocketUrl = mistemsDebug ? `wss://misskey.systems` : `ws://localhost:${port}/`; +const embedUrl = mistemsDebug ? `https://misskey.systems/`: `http://localhost:5174/` ; + // activitypubリクエストはProxyを通し、それ以外はViteの開発サーバーを返す function varyHandler(req: IncomingMessage) { @@ -33,7 +38,7 @@ const devConfig: UserConfig = { base: './', server: { host: 'localhost', - port: 5173, + port: hostingPort, proxy: { '/api': { changeOrigin: true, From 677c3259f0ea335bdace40bc423406ac81587b01 Mon Sep 17 00:00:00 2001 From: FruitRiin Date: Sat, 16 Nov 2024 14:20:28 +0900 Subject: [PATCH 2/3] favstar2 --- .../migration/1731722596000-favstar.js | 22 ++++++++++ .../backend/src/core/NoteCreateService.ts | 2 +- packages/backend/src/core/ReactionService.ts | 13 ++++-- .../src/core/entities/MetaEntityService.ts | 16 +++++++- packages/backend/src/models/Meta.ts | 9 ++++ .../src/server/api/endpoints/admin/meta.ts | 22 ++++++++++ .../server/api/endpoints/admin/update-meta.ts | 20 +++++++++ packages/frontend/src/components/MkNote.vue | 11 ++++- packages/frontend/src/instance.ts | 8 +++- .../frontend/src/pages/admin/settings.vue | 41 +++++++++++++++++++ 10 files changed, 155 insertions(+), 9 deletions(-) create mode 100644 packages/backend/migration/1731722596000-favstar.js diff --git a/packages/backend/migration/1731722596000-favstar.js b/packages/backend/migration/1731722596000-favstar.js new file mode 100644 index 000000000000..d7fcbcf24c2a --- /dev/null +++ b/packages/backend/migration/1731722596000-favstar.js @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class Favstar17317225960000 { + constructor() { + this.name = 'Favstar17317225960000'; + } + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" ADD "highlightRateFactor" integer NOT NULL DEFAULT 30`); + await queryRunner.query(`ALTER TABLE "meta" ADD "highlightMidPopularityThreshold" integer NOT NULL DEFAULT 3`); + await queryRunner.query(`ALTER TABLE "meta" ADD "highlightHighPopularityThreashold" integer NOT NULL DEFAULT 5`) + await queryRunner.query(`ALTER TABLE "meta" ADD "highlightExcludeEmojis" text NOT NULL DEFAULT ''`) + } + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "highlightRateFactor"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "highlightMidPopularityThreshold"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "highlightHighPopularityThreashold"`); + await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "highlightExcludeEmojis"`); + } +} diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 3647fa723173..ddfb664c2c58 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -753,7 +753,7 @@ export class NoteCreateService implements OnApplicationShutdown { .execute(); // 30%の確率、3日以内に投稿されたノートの場合ハイライト用ランキング更新 - if (Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) { + if (Math.random() <= (this.meta.highlightRateFactor / 100) && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) { if (renote.channelId != null) { if (renote.replyId == null) { this.featuredService.updateInChannelNotesRanking(renote.channelId, renote.id, 5); diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index 6f9fe53937bc..1f262fbd02e7 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Inject, Injectable } from '@nestjs/common'; +import { Inject, Injectable, Logger } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; import type { EmojisRepository, NoteReactionsRepository, UsersRepository, NotesRepository, MiMeta } from '@/models/_.js'; import { IdentifiableError } from '@/misc/identifiable-error.js'; @@ -123,7 +123,7 @@ export class ReactionService { } let reaction = _reaction ?? FALLBACK; - + if (note.reactionAcceptance === 'likeOnly' || ((note.reactionAcceptance === 'likeOnlyForRemote' || note.reactionAcceptance === 'nonSensitiveOnlyForLocalLikeOnlyForRemote') && (user.host != null))) { reaction = '\u2764'; } else if (_reaction != null) { @@ -171,6 +171,8 @@ export class ReactionService { reaction, }; + Logger.error('I\'m ' + reaction); + try { await this.noteReactionsRepository.insert(record); } catch (e) { @@ -209,9 +211,14 @@ export class ReactionService { .execute(); } + const excludeEmojis = this.meta.highlightExcludeEmojis.split(/:\n/).filter(v => v); + Logger.error('I\'m ' + reaction); + + Logger.error(excludeEmojis, !excludeEmojis.includes(reaction)); // 30%の確率、セルフではない、3日以内に投稿されたノートの場合ハイライト用ランキング更新 if ( - Math.random() < 0.3 && + !excludeEmojis.includes(reaction) && + Math.random() <= (this.meta.highlightRateFactor / 100) && note.userId !== user.id && (Date.now() - this.idService.parse(note.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3 ) { diff --git a/packages/backend/src/core/entities/MetaEntityService.ts b/packages/backend/src/core/entities/MetaEntityService.ts index 409dca34263b..2fbc66acc37a 100644 --- a/packages/backend/src/core/entities/MetaEntityService.ts +++ b/packages/backend/src/core/entities/MetaEntityService.ts @@ -17,6 +17,13 @@ import type { Config } from '@/config.js'; import { DI } from '@/di-symbols.js'; import { DEFAULT_POLICIES } from '@/core/RoleService.js'; +type HighlightExtention = { + highlightRateFactor: number, + highlightMidPopularityThreshold: number, + highlightHighPopularityThreashold: number, + highlightExcludeEmojis: string +} + @Injectable() export class MetaEntityService { constructor( @@ -34,7 +41,7 @@ export class MetaEntityService { ) { } @bindThis - public async pack(meta?: MiMeta): Promise> { + public async pack(meta?: MiMeta): Promise & HighlightExtention> { let instance = meta; if (!instance) { @@ -67,7 +74,7 @@ export class MetaEntityService { } } - const packed: Packed<'MetaLite'> = { + const packed: Packed<'MetaLite'> & HighlightExtention = { maintainerName: instance.maintainerName, maintainerEmail: instance.maintainerEmail, @@ -132,6 +139,11 @@ export class MetaEntityService { enableUrlPreview: instance.urlPreviewEnabled, noteSearchableScope: (this.config.meilisearch == null || this.config.meilisearch.scope !== 'local') ? 'global' : 'local', maxFileSize: this.config.maxFileSize, + + highlightRateFactor: instance.highlightRateFactor, + highlightMidPopularityThreshold: instance.highlightMidPopularityThreshold, + highlightHighPopularityThreashold: instance.highlightHighPopularityThreashold, + highlightExcludeEmojis: instance.highlightExcludeEmojis, }; return packed; diff --git a/packages/backend/src/models/Meta.ts b/packages/backend/src/models/Meta.ts index ad5e31ad6ff2..f36786124bbe 100644 --- a/packages/backend/src/models/Meta.ts +++ b/packages/backend/src/models/Meta.ts @@ -658,4 +658,13 @@ export class MiMeta { default: '{}', }) public federationHosts: string[]; + + @Column('integer', { default: 30 }) + public highlightRateFactor: number; + @Column('integer', { default: 3 }) + public highlightMidPopularityThreshold: number; + @Column('integer', { default: 5 }) + public highlightHighPopularityThreashold: number; + @Column('text', { default: '' }) + public highlightExcludeEmojis: string; } diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 64e3cc33bd2c..7918e977431d 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -522,6 +522,24 @@ export const meta = { optional: false, nullable: false, }, }, + + highlightRateFactor: { + type: 'number', + optinal: false, nullable: false, + }, + + highlightMidPopularityThreshold: { + type: 'number', + optinal: false, nullable: false, + }, + highlightHighPopularityThreashold: { + type: 'number', + optinal: false, nullable: false, + }, + highlightExcludeEmojis: { + type: 'string', + optinal: false, nullable: false, + }, }, }, } as const; @@ -662,6 +680,10 @@ export default class extends Endpoint { // eslint- urlPreviewSummaryProxyUrl: instance.urlPreviewSummaryProxyUrl, federation: instance.federation, federationHosts: instance.federationHosts, + highlightRateFactor: instance.highlightRateFactor, + highlightMidPopularityThreshold: instance.highlightMidPopularityThreshold, + highlightHighPopularityThreashold: instance.highlightHighPopularityThreashold, + highlightExcludeEmojis: instance.highlightExcludeEmojis, }; }); } diff --git a/packages/backend/src/server/api/endpoints/admin/update-meta.ts b/packages/backend/src/server/api/endpoints/admin/update-meta.ts index 38ef0d1de837..5d8d7ddd10f8 100644 --- a/packages/backend/src/server/api/endpoints/admin/update-meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/update-meta.ts @@ -185,6 +185,19 @@ export const paramDef = { type: 'string', }, }, + highlightRateFactor: { + type: 'number', + }, + + highlightMidPopularityThreshold: { + type: 'number', + }, + highlightHighPopularityThreashold: { + type: 'number', + }, + highlightExcludeEmojis: { + type: 'string', + }, }, required: [], } as const; @@ -673,6 +686,13 @@ export default class extends Endpoint { // eslint- set.federationHosts = ps.federationHosts.filter(Boolean).map(x => x.toLowerCase()); } + if (ps.highlightRateFactor) { + set.highlightRateFactor = ps.highlightRateFactor; + set.highlightMidPopularityThreshold = ps.highlightMidPopularityThreshold; + set.highlightHighPopularityThreashold = ps.highlightHighPopularityThreashold; + set.highlightExcludeEmojis = ps.highlightExcludeEmojis; + } + const before = await this.metaService.fetch(true); await this.metaService.update(set); diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index dcff4a279cea..cfd5bfb5a6e7 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -64,7 +64,7 @@ SPDX-License-Identifier: AGPL-3.0-only

-
+
({{ i18n.ts.private }}) | null>('currentClip', nul const note = ref(deepClone(props.note)); + +const highlightPopularityThreshold = computed(() => { + return { + highPopularity: instance.highlightHighPopularityThreashold, + midPopularity: instance.highlightMidPopularityThreshold, + } +}) // plugin if (noteViewInterruptors.length > 0) { onMounted(async () => { diff --git a/packages/frontend/src/instance.ts b/packages/frontend/src/instance.ts index 71cb42b30c45..dd72c6fa1fb5 100644 --- a/packages/frontend/src/instance.ts +++ b/packages/frontend/src/instance.ts @@ -28,7 +28,13 @@ if (providedAt > cachedAt) { // TODO: instanceをリアクティブにするかは再考の余地あり -export const instance: Misskey.entities.MetaDetailed = reactive(cachedMeta ?? {}); + +type HighlightPopularityThreshold = { + highlightMidPopularityThreshold: number; + highlightHighPopularityThreashold: number; +} + +export const instance: Misskey.entities.MetaDetailed & HighlightPopularityThreshold = reactive(cachedMeta ?? {}); export const serverErrorImageUrl = computed(() => instance.serverErrorImageUrl ?? DEFAULT_SERVER_ERROR_IMAGE_URL); diff --git a/packages/frontend/src/pages/admin/settings.vue b/packages/frontend/src/pages/admin/settings.vue index ea7603a45adb..3a893367cf5b 100644 --- a/packages/frontend/src/pages/admin/settings.vue +++ b/packages/frontend/src/pages/admin/settings.vue @@ -249,6 +249,38 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.selectAccount }}
+ + + + +
+ リアクションしたときに見つける>ハイライトの採用される確率は、大規模サーバーにおいてパフォーマンスへの影響を考慮してデフォルト30%です。(つまり、70%のリアクションはカウントに影響しません) + + + + + + + + + + + + + + + + + + + + + + +
+
@@ -290,6 +322,10 @@ const infoForm = useForm({ inquiryUrl: meta.inquiryUrl ?? '', repositoryUrl: meta.repositoryUrl ?? '', impressumUrl: meta.impressumUrl ?? '', + highlightRateFactor: meta.highlightRateFactor ?? 30, + highlightMidPopularityThreshold: meta.highlightMidPopularityThreshold ?? 3, + highlightHighPopularityThreashold: meta.highlightHighPopularityThreashold ?? 5, + highlightExcludeEmojis: meta.highlightExcludeEmojis, }, async (state) => { await os.apiWithDialog('admin/update-meta', { name: state.name, @@ -302,6 +338,11 @@ const infoForm = useForm({ inquiryUrl: state.inquiryUrl, repositoryUrl: state.repositoryUrl, impressumUrl: state.impressumUrl, + highlightRateFactor: state.highlightRateFactor, + highlightMidPopularityThreshold: state.highlightMidPopularityThreshold, + highlightHighPopularityThreashold: state.highlightHighPopularityThreashold ?? 5, + highlightExcludeEmojis: state.highlightExcludeEmojis, + }); fetchInstance(true); }); From cacf4771001d6d34c2c6224eed9194ecb8e16cd3 Mon Sep 17 00:00:00 2001 From: FruitRiin Date: Sat, 16 Nov 2024 15:12:04 +0900 Subject: [PATCH 3/3] fix typo --- packages/frontend/src/pages/admin/settings.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/admin/settings.vue b/packages/frontend/src/pages/admin/settings.vue index 3a893367cf5b..ecc2779797f8 100644 --- a/packages/frontend/src/pages/admin/settings.vue +++ b/packages/frontend/src/pages/admin/settings.vue @@ -274,7 +274,7 @@ SPDX-License-Identifier: AGPL-3.0-only