From 32872181ddf14cfbf006dc93d04eeacac5eaf7a0 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Thu, 25 Jul 2024 10:37:23 -0400 Subject: [PATCH 01/22] feat: implement `attachLdSignatureForRelays` to control signing of Relayed activities --- .config/ci.yml | 8 +- .config/docker_example.yml | 4 +- .config/example.yml | 4 +- chart/files/default.yml | 4 +- packages/backend/src/config.ts | 11 ++- .../src/core/activitypub/ApRendererService.ts | 97 +++++++++++++------ 6 files changed, 89 insertions(+), 39 deletions(-) diff --git a/.config/ci.yml b/.config/ci.yml index c381d21d92..02081e5971 100644 --- a/.config/ci.yml +++ b/.config/ci.yml @@ -106,7 +106,7 @@ redis: # ┌───────────────────────────┐ #───┘ MeiliSearch configuration └───────────────────────────── -# You can set scope to local (default value) or global +# You can set scope to local (default value) or global # (include notes from remote). #meilisearch: @@ -198,13 +198,15 @@ proxyRemoteFiles: true # https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4 #videoThumbnailGenerator: https://example.com -# Sign to ActivityPub GET request (default: true) +# Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true +# Sign outgoing ActivityPub Activities (default: true) +attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false # For security reasons, uploading attachments from the intranet is prohibited, -# but exceptions can be made from the following settings. Default value is "undefined". +# but exceptions can be made from the following settings. Default value is "undefined". # Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)). #allowedPrivateNetworks: [ # '127.0.0.1/32' diff --git a/.config/docker_example.yml b/.config/docker_example.yml index c22bd83c2e..375753e79f 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -270,8 +270,10 @@ proxyRemoteFiles: true # https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4 #videoThumbnailGenerator: https://example.com -# Sign to ActivityPub GET request (default: true) +# Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true +# Sign outgoing ActivityPub Activities (default: true) +attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/.config/example.yml b/.config/example.yml index ae55b983bb..4b6aaae63b 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -285,8 +285,10 @@ proxyRemoteFiles: true # https://example.com/thumbnail.webp?thumbnail=1&url=https%3A%2F%2Fstorage.example.com%2Fpath%2Fto%2Fvideo.mp4 #videoThumbnailGenerator: https://example.com -# Sign to ActivityPub GET request (default: true) +# Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true +# Sign outgoing ActivityPub Activities (default: true) +attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/chart/files/default.yml b/chart/files/default.yml index 2e1381ec57..7c94bcbea3 100644 --- a/chart/files/default.yml +++ b/chart/files/default.yml @@ -208,8 +208,10 @@ id: "aidx" # Media Proxy #mediaProxy: https://example.com/proxy -# Sign to ActivityPub GET request (default: true) +# Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true +# Sign outgoing ActivityPub Activities (default: true) +attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 58c4d028aa..10a63f8ae2 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -4,12 +4,12 @@ */ import * as fs from 'node:fs'; -import { fileURLToPath } from 'node:url'; -import { dirname, resolve } from 'node:path'; +import {fileURLToPath} from 'node:url'; +import {dirname, resolve} from 'node:path'; import * as yaml from 'js-yaml'; -import { globSync } from 'glob'; +import {globSync} from 'glob'; import * as Sentry from '@sentry/node'; -import type { RedisOptions } from 'ioredis'; +import type {RedisOptions} from 'ioredis'; type RedisOptionsSource = Partial & { host: string; @@ -95,6 +95,7 @@ type Source = { customMOTD?: string[]; signToActivityPubGet?: boolean; + attachLdSignatureForRelays?: boolean; checkActivityPubGetSignature?: boolean; perChannelMaxNoteCacheCount?: number; @@ -161,6 +162,7 @@ export type Config = { proxyRemoteFiles: boolean | undefined; customMOTD: string[] | undefined; signToActivityPubGet: boolean; + attachLdSignatureForRelays: boolean; checkActivityPubGetSignature: boolean | undefined; version: string; @@ -291,6 +293,7 @@ export function loadConfig(): Config { proxyRemoteFiles: config.proxyRemoteFiles, customMOTD: config.customMOTD, signToActivityPubGet: config.signToActivityPubGet ?? true, + attachLdSignatureForRelays: config.attachLdSignatureForRelays ?? true, checkActivityPubGetSignature: config.checkActivityPubGetSignature, mediaProxy: externalMediaProxy ?? internalMediaProxy, externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy, diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index 90784fdc1d..28c5dcf150 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -3,36 +3,69 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { createPublicKey, randomUUID } from 'node:crypto'; -import { Inject, Injectable } from '@nestjs/common'; -import { In } from 'typeorm'; +import {createPublicKey, randomUUID} from 'node:crypto'; +import {Inject, Injectable} from '@nestjs/common'; +import {In} from 'typeorm'; import * as mfm from '@transfem-org/sfm-js'; -import { DI } from '@/di-symbols.js'; -import type { Config } from '@/config.js'; -import type { MiPartialLocalUser, MiLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js'; -import type { IMentionedRemoteUsers, MiNote } from '@/models/Note.js'; -import type { MiBlocking } from '@/models/Blocking.js'; -import type { MiRelay } from '@/models/Relay.js'; -import type { MiDriveFile } from '@/models/DriveFile.js'; -import type { MiNoteReaction } from '@/models/NoteReaction.js'; -import type { MiEmoji } from '@/models/Emoji.js'; -import type { MiPoll } from '@/models/Poll.js'; -import type { MiPollVote } from '@/models/PollVote.js'; -import { UserKeypairService } from '@/core/UserKeypairService.js'; -import { MfmService } from '@/core/MfmService.js'; -import { UserEntityService } from '@/core/entities/UserEntityService.js'; -import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; -import type { MiUserKeypair } from '@/models/UserKeypair.js'; -import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFilesRepository, PollsRepository, InstancesRepository } from '@/models/_.js'; -import { bindThis } from '@/decorators.js'; -import { CustomEmojiService } from '@/core/CustomEmojiService.js'; -import { isNotNull } from '@/misc/is-not-null.js'; -import { IdService } from '@/core/IdService.js'; -import { MetaService } from '../MetaService.js'; -import { JsonLdService } from './JsonLdService.js'; -import { ApMfmService } from './ApMfmService.js'; -import { CONTEXT } from './misc/contexts.js'; -import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js'; +import {DI} from '@/di-symbols.js'; +import type {Config} from '@/config.js'; +import type {MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser} from '@/models/User.js'; +import type {IMentionedRemoteUsers, MiNote} from '@/models/Note.js'; +import type {MiBlocking} from '@/models/Blocking.js'; +import type {MiRelay} from '@/models/Relay.js'; +import type {MiDriveFile} from '@/models/DriveFile.js'; +import type {MiNoteReaction} from '@/models/NoteReaction.js'; +import type {MiEmoji} from '@/models/Emoji.js'; +import type {MiPoll} from '@/models/Poll.js'; +import type {MiPollVote} from '@/models/PollVote.js'; +import {UserKeypairService} from '@/core/UserKeypairService.js'; +import {MfmService} from '@/core/MfmService.js'; +import {UserEntityService} from '@/core/entities/UserEntityService.js'; +import {DriveFileEntityService} from '@/core/entities/DriveFileEntityService.js'; +import type {MiUserKeypair} from '@/models/UserKeypair.js'; +import type { + DriveFilesRepository, + InstancesRepository, + NotesRepository, + PollsRepository, + UserProfilesRepository, + UsersRepository +} from '@/models/_.js'; +import {bindThis} from '@/decorators.js'; +import {CustomEmojiService} from '@/core/CustomEmojiService.js'; +import {isNotNull} from '@/misc/is-not-null.js'; +import {IdService} from '@/core/IdService.js'; +import {MetaService} from '../MetaService.js'; +import {JsonLdService} from './JsonLdService.js'; +import {ApMfmService} from './ApMfmService.js'; +import {CONTEXT} from './misc/contexts.js'; +import type { + IAccept, + IActivity, + IAdd, + IAnnounce, + IApDocument, + IApEmoji, + IApHashtag, + IApImage, + IApMention, + IBlock, + ICreate, + IDelete, + IFlag, + IFollow, + IKey, + ILike, + IMove, + IObject, + IPost, + IQuestion, + IReject, + IRemove, + ITombstone, + IUndo, + IUpdate +} from './type.js'; @Injectable() export class ApRendererService { @@ -793,6 +826,12 @@ export class ApRendererService { @bindThis public async attachLdSignature(activity: any, user: { id: MiUser['id']; host: null; }): Promise { + // When using authorized fetch, Linked Data signatures are often undesired (as it can allow blocked instances to bypass the check). + // We allow admins to disable LD signatures for increased privacy, at the expense of increased incoming fetch (GET) requests. + if (!this.config.attachLdSignatureForRelays) { + return activity; + } + const keypair = await this.userKeypairService.getUserKeypair(user.id); const jsonLd = this.jsonLdService.use(); From fecdff7fa092ca9d8ca0cd50b5694eb3f8279a91 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Fri, 26 Jul 2024 09:42:49 -0400 Subject: [PATCH 02/22] revert import changes --- .../src/core/activitypub/ApRendererService.ts | 91 ++++++------------- 1 file changed, 29 insertions(+), 62 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index 28c5dcf150..8db9199e5d 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -3,69 +3,36 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import {createPublicKey, randomUUID} from 'node:crypto'; -import {Inject, Injectable} from '@nestjs/common'; -import {In} from 'typeorm'; +import { createPublicKey, randomUUID } from 'node:crypto'; +import { Inject, Injectable } from '@nestjs/common'; +import { In } from 'typeorm'; import * as mfm from '@transfem-org/sfm-js'; -import {DI} from '@/di-symbols.js'; -import type {Config} from '@/config.js'; -import type {MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser} from '@/models/User.js'; -import type {IMentionedRemoteUsers, MiNote} from '@/models/Note.js'; -import type {MiBlocking} from '@/models/Blocking.js'; -import type {MiRelay} from '@/models/Relay.js'; -import type {MiDriveFile} from '@/models/DriveFile.js'; -import type {MiNoteReaction} from '@/models/NoteReaction.js'; -import type {MiEmoji} from '@/models/Emoji.js'; -import type {MiPoll} from '@/models/Poll.js'; -import type {MiPollVote} from '@/models/PollVote.js'; -import {UserKeypairService} from '@/core/UserKeypairService.js'; -import {MfmService} from '@/core/MfmService.js'; -import {UserEntityService} from '@/core/entities/UserEntityService.js'; -import {DriveFileEntityService} from '@/core/entities/DriveFileEntityService.js'; -import type {MiUserKeypair} from '@/models/UserKeypair.js'; -import type { - DriveFilesRepository, - InstancesRepository, - NotesRepository, - PollsRepository, - UserProfilesRepository, - UsersRepository -} from '@/models/_.js'; -import {bindThis} from '@/decorators.js'; -import {CustomEmojiService} from '@/core/CustomEmojiService.js'; -import {isNotNull} from '@/misc/is-not-null.js'; -import {IdService} from '@/core/IdService.js'; -import {MetaService} from '../MetaService.js'; -import {JsonLdService} from './JsonLdService.js'; -import {ApMfmService} from './ApMfmService.js'; -import {CONTEXT} from './misc/contexts.js'; -import type { - IAccept, - IActivity, - IAdd, - IAnnounce, - IApDocument, - IApEmoji, - IApHashtag, - IApImage, - IApMention, - IBlock, - ICreate, - IDelete, - IFlag, - IFollow, - IKey, - ILike, - IMove, - IObject, - IPost, - IQuestion, - IReject, - IRemove, - ITombstone, - IUndo, - IUpdate -} from './type.js'; +import { DI } from '@/di-symbols.js'; +import type { Config } from '@/config.js'; +import type { MiPartialLocalUser, MiLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js'; +import type { IMentionedRemoteUsers, MiNote } from '@/models/Note.js'; +import type { MiBlocking } from '@/models/Blocking.js'; +import type { MiRelay } from '@/models/Relay.js'; +import type { MiDriveFile } from '@/models/DriveFile.js'; +import type { MiNoteReaction } from '@/models/NoteReaction.js'; +import type { MiEmoji } from '@/models/Emoji.js'; +import type { MiPoll } from '@/models/Poll.js'; +import type { MiPollVote } from '@/models/PollVote.js'; +import { UserKeypairService } from '@/core/UserKeypairService.js'; +import { MfmService } from '@/core/MfmService.js'; +import { UserEntityService } from '@/core/entities/UserEntityService.js'; +import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; +import type { MiUserKeypair } from '@/models/UserKeypair.js'; +import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFilesRepository, PollsRepository, InstancesRepository } from '@/models/_.js'; +import { bindThis } from '@/decorators.js'; +import { CustomEmojiService } from '@/core/CustomEmojiService.js'; +import { isNotNull } from '@/misc/is-not-null.js'; +import { IdService } from '@/core/IdService.js'; +import { MetaService } from '../MetaService.js'; +import { JsonLdService } from './JsonLdService.js'; +import { ApMfmService } from './ApMfmService.js'; +import { CONTEXT } from './misc/contexts.js'; +import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js'; @Injectable() export class ApRendererService { From 916509dd6a6216277b2439a7e622890c563c4a78 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Fri, 26 Jul 2024 10:17:02 -0400 Subject: [PATCH 03/22] revert more import changes --- packages/backend/src/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 10a63f8ae2..c8170a6a50 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -4,12 +4,12 @@ */ import * as fs from 'node:fs'; -import {fileURLToPath} from 'node:url'; -import {dirname, resolve} from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { dirname, resolve } from 'node:path'; import * as yaml from 'js-yaml'; -import {globSync} from 'glob'; +import { globSync } from 'glob'; import * as Sentry from '@sentry/node'; -import type {RedisOptions} from 'ioredis'; +import type { RedisOptions } from 'ioredis'; type RedisOptionsSource = Partial & { host: string; From 378408226b5e8968313058de4862b9916d08d6e0 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Fri, 26 Jul 2024 22:45:07 -0400 Subject: [PATCH 04/22] tweak wording --- .config/ci.yml | 3 +++ .config/docker_example.yml | 3 +++ .config/example.yml | 3 +++ chart/files/default.yml | 3 +++ packages/backend/src/core/activitypub/ApRendererService.ts | 5 +++-- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.config/ci.yml b/.config/ci.yml index 02081e5971..44092d3662 100644 --- a/.config/ci.yml +++ b/.config/ci.yml @@ -201,6 +201,9 @@ proxyRemoteFiles: true # Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true # Sign outgoing ActivityPub Activities (default: true) +# Linked Data signatures are cryptographic signatures attached to each activity to provide proof of authenticity. +# When using authorized fetch, this is often undesired as any signed activity can be forwarded to a blocked instance by relays and other instances. +# This setting allows admins to disable LD signatures for increased privacy, at the expense of fewer relayed activities and additional inbound fetch (GET) requests. attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/.config/docker_example.yml b/.config/docker_example.yml index 375753e79f..f4645d672d 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -273,6 +273,9 @@ proxyRemoteFiles: true # Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true # Sign outgoing ActivityPub Activities (default: true) +# Linked Data signatures are cryptographic signatures attached to each activity to provide proof of authenticity. +# When using authorized fetch, this is often undesired as any signed activity can be forwarded to a blocked instance by relays and other instances. +# This setting allows admins to disable LD signatures for increased privacy, at the expense of fewer relayed activities and additional inbound fetch (GET) requests. attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/.config/example.yml b/.config/example.yml index 4b6aaae63b..21e85b7b89 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -288,6 +288,9 @@ proxyRemoteFiles: true # Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true # Sign outgoing ActivityPub Activities (default: true) +# Linked Data signatures are cryptographic signatures attached to each activity to provide proof of authenticity. +# When using authorized fetch, this is often undesired as any signed activity can be forwarded to a blocked instance by relays and other instances. +# This setting allows admins to disable LD signatures for increased privacy, at the expense of fewer relayed activities and additional inbound fetch (GET) requests. attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/chart/files/default.yml b/chart/files/default.yml index 7c94bcbea3..aab7ed6ce1 100644 --- a/chart/files/default.yml +++ b/chart/files/default.yml @@ -211,6 +211,9 @@ id: "aidx" # Sign outgoing ActivityPub GET request (default: true) signToActivityPubGet: true # Sign outgoing ActivityPub Activities (default: true) +# Linked Data signatures are cryptographic signatures attached to each activity to provide proof of authenticity. +# When using authorized fetch, this is often undesired as any signed activity can be forwarded to a blocked instance by relays and other instances. +# This setting allows admins to disable LD signatures for increased privacy, at the expense of fewer relayed activities and additional inbound fetch (GET) requests. attachLdSignatureForRelays: true # check that inbound ActivityPub GET requests are signed ("authorized fetch") checkActivityPubGetSignature: false diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts index 8db9199e5d..98fc647a83 100644 --- a/packages/backend/src/core/activitypub/ApRendererService.ts +++ b/packages/backend/src/core/activitypub/ApRendererService.ts @@ -793,8 +793,9 @@ export class ApRendererService { @bindThis public async attachLdSignature(activity: any, user: { id: MiUser['id']; host: null; }): Promise { - // When using authorized fetch, Linked Data signatures are often undesired (as it can allow blocked instances to bypass the check). - // We allow admins to disable LD signatures for increased privacy, at the expense of increased incoming fetch (GET) requests. + // Linked Data signatures are cryptographic signatures attached to each activity to provide proof of authenticity. + // When using authorized fetch, this is often undesired as any signed activity can be forwarded to a blocked instance by relays and other instances. + // This setting allows admins to disable LD signatures for increased privacy, at the expense of fewer relayed activities and additional inbound fetch (GET) requests. if (!this.config.attachLdSignatureForRelays) { return activity; } From 114b6980346470fcf8cf1a11e50038c8fb15c48e Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 09:18:44 -0400 Subject: [PATCH 05/22] encapsulate `MemoryKVCache` --- packages/backend/src/core/CacheService.ts | 4 ++-- packages/backend/src/misc/cache.ts | 24 +++++++++-------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts index d008e7ec52..4afcef02be 100644 --- a/packages/backend/src/core/CacheService.ts +++ b/packages/backend/src/core/CacheService.ts @@ -135,14 +135,14 @@ export class CacheService implements OnApplicationShutdown { if (user == null) { this.userByIdCache.delete(body.id); this.localUserByIdCache.delete(body.id); - for (const [k, v] of this.uriPersonCache.cache.entries()) { + for (const [k, v] of this.uriPersonCache.entries) { if (v.value?.id === body.id) { this.uriPersonCache.delete(k); } } } else { this.userByIdCache.set(user.id, user); - for (const [k, v] of this.uriPersonCache.cache.entries()) { + for (const [k, v] of this.uriPersonCache.entries) { if (v.value?.id === user.id) { this.uriPersonCache.set(k, user); } diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index bba64a06ef..fe27d44692 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -187,22 +187,12 @@ export class RedisSingleCache { // TODO: メモリ節約のためあまり参照されないキーを定期的に削除できるようにする? export class MemoryKVCache { - /** - * データを持つマップ - * @deprecated これを直接操作するべきではない - */ - public cache: Map; - private lifetime: number; - private gcIntervalHandle: NodeJS.Timeout; + private readonly cache = new Map(); + private readonly gcIntervalHandle = setInterval(() => this.gc(), 1000 * 60 * 3); - constructor(lifetime: MemoryKVCache['lifetime']) { - this.cache = new Map(); - this.lifetime = lifetime; - - this.gcIntervalHandle = setInterval(() => { - this.gc(); - }, 1000 * 60 * 3); - } + constructor( + private readonly lifetime: number, + ) {} @bindThis /** @@ -298,6 +288,10 @@ export class MemoryKVCache { public dispose(): void { clearInterval(this.gcIntervalHandle); } + + public get entries() { + return this.cache.entries(); + } } export class MemorySingleCache { From bc236a4bd250fc700bdd2d5549bf9647c02cb946 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 13:42:23 -0400 Subject: [PATCH 06/22] remove infinity caches --- packages/backend/src/core/CacheService.ts | 8 ++++---- packages/backend/src/core/UserKeypairService.ts | 2 +- .../backend/src/core/activitypub/ApDbResolverService.ts | 4 ++-- packages/backend/src/server/api/AuthenticateService.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/CacheService.ts b/packages/backend/src/core/CacheService.ts index 4afcef02be..6725ebe75b 100644 --- a/packages/backend/src/core/CacheService.ts +++ b/packages/backend/src/core/CacheService.ts @@ -56,10 +56,10 @@ export class CacheService implements OnApplicationShutdown { ) { //this.onMessage = this.onMessage.bind(this); - this.userByIdCache = new MemoryKVCache(Infinity); - this.localUserByNativeTokenCache = new MemoryKVCache(Infinity); - this.localUserByIdCache = new MemoryKVCache(Infinity); - this.uriPersonCache = new MemoryKVCache(Infinity); + this.userByIdCache = new MemoryKVCache(1000 * 60 * 5); // 5m + this.localUserByNativeTokenCache = new MemoryKVCache(1000 * 60 * 5); // 5m + this.localUserByIdCache = new MemoryKVCache(1000 * 60 * 5); // 5m + this.uriPersonCache = new MemoryKVCache(1000 * 60 * 5); // 5m this.userProfileCache = new RedisKVCache(this.redisClient, 'userProfile', { lifetime: 1000 * 60 * 30, // 30m diff --git a/packages/backend/src/core/UserKeypairService.ts b/packages/backend/src/core/UserKeypairService.ts index 51ac99179a..eb7a95da3e 100644 --- a/packages/backend/src/core/UserKeypairService.ts +++ b/packages/backend/src/core/UserKeypairService.ts @@ -25,7 +25,7 @@ export class UserKeypairService implements OnApplicationShutdown { ) { this.cache = new RedisKVCache(this.redisClient, 'userKeypair', { lifetime: 1000 * 60 * 60 * 24, // 24h - memoryCacheLifetime: Infinity, + memoryCacheLifetime: 1000 * 60 * 60 * 12, // 12h fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }), toRedisConverter: (value) => JSON.stringify(value), fromRedisConverter: (value) => JSON.parse(value), diff --git a/packages/backend/src/core/activitypub/ApDbResolverService.ts b/packages/backend/src/core/activitypub/ApDbResolverService.ts index 44680a2ed5..062af39732 100644 --- a/packages/backend/src/core/activitypub/ApDbResolverService.ts +++ b/packages/backend/src/core/activitypub/ApDbResolverService.ts @@ -54,8 +54,8 @@ export class ApDbResolverService implements OnApplicationShutdown { private cacheService: CacheService, private apPersonService: ApPersonService, ) { - this.publicKeyCache = new MemoryKVCache(Infinity); - this.publicKeyByUserIdCache = new MemoryKVCache(Infinity); + this.publicKeyCache = new MemoryKVCache(1000 * 60 * 60 * 12); // 12h + this.publicKeyByUserIdCache = new MemoryKVCache(1000 * 60 * 60 * 12); // 12h } @bindThis diff --git a/packages/backend/src/server/api/AuthenticateService.ts b/packages/backend/src/server/api/AuthenticateService.ts index ddef8db987..690ff2e022 100644 --- a/packages/backend/src/server/api/AuthenticateService.ts +++ b/packages/backend/src/server/api/AuthenticateService.ts @@ -37,7 +37,7 @@ export class AuthenticateService implements OnApplicationShutdown { private cacheService: CacheService, ) { - this.appCache = new MemoryKVCache(Infinity); + this.appCache = new MemoryKVCache(1000 * 60 * 60 * 24 * 7); // 1w } @bindThis From b1f1e3eb0e9a809839d2ee2ccf71d64c47dc7efa Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 13:54:59 -0400 Subject: [PATCH 07/22] encapsulate other caches --- packages/backend/src/misc/cache.ts | 71 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index fe27d44692..b6eca73b03 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -7,23 +7,23 @@ import * as Redis from 'ioredis'; import { bindThis } from '@/decorators.js'; export class RedisKVCache { - private redisClient: Redis.Redis; - private name: string; - private lifetime: number; - private memoryCache: MemoryKVCache; - private fetcher: (key: string) => Promise; - private toRedisConverter: (value: T) => string; - private fromRedisConverter: (value: string) => T | undefined; + private readonly lifetime: number; + private readonly memoryCache: MemoryKVCache; + private readonly fetcher: (key: string) => Promise; + private readonly toRedisConverter: (value: T) => string; + private readonly fromRedisConverter: (value: string) => T | undefined; - constructor(redisClient: RedisKVCache['redisClient'], name: RedisKVCache['name'], opts: { - lifetime: RedisKVCache['lifetime']; - memoryCacheLifetime: number; - fetcher: RedisKVCache['fetcher']; - toRedisConverter: RedisKVCache['toRedisConverter']; - fromRedisConverter: RedisKVCache['fromRedisConverter']; - }) { - this.redisClient = redisClient; - this.name = name; + constructor( + private redisClient: Redis.Redis, + private name: string, + opts: { + lifetime: RedisKVCache['lifetime']; + memoryCacheLifetime: number; + fetcher: RedisKVCache['fetcher']; + toRedisConverter: RedisKVCache['toRedisConverter']; + fromRedisConverter: RedisKVCache['fromRedisConverter']; + }, + ) { this.lifetime = opts.lifetime; this.memoryCache = new MemoryKVCache(opts.memoryCacheLifetime); this.fetcher = opts.fetcher; @@ -101,23 +101,23 @@ export class RedisKVCache { } export class RedisSingleCache { - private redisClient: Redis.Redis; - private name: string; - private lifetime: number; - private memoryCache: MemorySingleCache; - private fetcher: () => Promise; - private toRedisConverter: (value: T) => string; - private fromRedisConverter: (value: string) => T | undefined; + private readonly lifetime: number; + private readonly memoryCache: MemorySingleCache; + private readonly fetcher: () => Promise; + private readonly toRedisConverter: (value: T) => string; + private readonly fromRedisConverter: (value: string) => T | undefined; - constructor(redisClient: RedisSingleCache['redisClient'], name: RedisSingleCache['name'], opts: { - lifetime: RedisSingleCache['lifetime']; - memoryCacheLifetime: number; - fetcher: RedisSingleCache['fetcher']; - toRedisConverter: RedisSingleCache['toRedisConverter']; - fromRedisConverter: RedisSingleCache['fromRedisConverter']; - }) { - this.redisClient = redisClient; - this.name = name; + constructor( + private redisClient: Redis.Redis, + private name: string, + opts: { + lifetime: number; + memoryCacheLifetime: number; + fetcher: RedisSingleCache['fetcher']; + toRedisConverter: RedisSingleCache['toRedisConverter']; + fromRedisConverter: RedisSingleCache['fromRedisConverter']; + }, + ) { this.lifetime = opts.lifetime; this.memoryCache = new MemorySingleCache(opts.memoryCacheLifetime); this.fetcher = opts.fetcher; @@ -297,11 +297,10 @@ export class MemoryKVCache { export class MemorySingleCache { private cachedAt: number | null = null; private value: T | undefined; - private lifetime: number; - constructor(lifetime: MemorySingleCache['lifetime']) { - this.lifetime = lifetime; - } + constructor( + private lifetime: number, + ) {} @bindThis public set(value: T): void { From 613706f6b87951bc10e36ebf915e81b0efb2bcac Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 14:02:18 -0400 Subject: [PATCH 08/22] add missing awaits to internally synchronize caches --- packages/backend/src/misc/cache.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index b6eca73b03..68397e1563 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -77,14 +77,14 @@ export class RedisKVCache { // Cache MISS const value = await this.fetcher(key); - this.set(key, value); + await this.set(key, value); return value; } @bindThis public async refresh(key: string) { const value = await this.fetcher(key); - this.set(key, value); + await this.set(key, value); // TODO: イベント発行して他プロセスのメモリキャッシュも更新できるようにする } @@ -171,14 +171,14 @@ export class RedisSingleCache { // Cache MISS const value = await this.fetcher(); - this.set(value); + await this.set(value); return value; } @bindThis public async refresh() { const value = await this.fetcher(); - this.set(value); + await this.set(value); // TODO: イベント発行して他プロセスのメモリキャッシュも更新できるようにする } From 3688f1dadf8e5f5601700a167ca4aa9514d71469 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 14:09:08 -0400 Subject: [PATCH 09/22] implement pull-through caching --- packages/backend/src/misc/cache.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index 68397e1563..fc98ce8132 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -55,7 +55,13 @@ export class RedisKVCache { const cached = await this.redisClient.get(`kvcache:${this.name}:${key}`); if (cached == null) return undefined; - return this.fromRedisConverter(cached); + + const value = this.fromRedisConverter(cached); + if (value !== undefined) { + this.memoryCache.set(key, value); + } + + return value; } @bindThis @@ -149,7 +155,13 @@ export class RedisSingleCache { const cached = await this.redisClient.get(`singlecache:${this.name}`); if (cached == null) return undefined; - return this.fromRedisConverter(cached); + + const value = this.fromRedisConverter(cached); + if (value !== undefined) { + this.memoryCache.set(value); + } + + return value; } @bindThis From 672f1ea68476f5d325c2c996eb3020fd69e99aad Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sat, 3 Aug 2024 14:49:06 -0400 Subject: [PATCH 10/22] tune cache lifetimes --- .../backend/src/core/AvatarDecorationService.ts | 2 +- packages/backend/src/core/CustomEmojiService.ts | 14 +++++++------- packages/backend/src/core/RelayService.ts | 2 +- packages/backend/src/core/RoleService.ts | 6 ++---- packages/backend/src/core/UserKeypairService.ts | 2 +- .../queue/processors/DeliverProcessorService.ts | 2 +- .../backend/src/server/NodeinfoServerService.ts | 2 +- .../backend/src/server/web/UrlPreviewService.ts | 4 ++-- 8 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/backend/src/core/AvatarDecorationService.ts b/packages/backend/src/core/AvatarDecorationService.ts index 21e31d79a4..fa3f63677e 100644 --- a/packages/backend/src/core/AvatarDecorationService.ts +++ b/packages/backend/src/core/AvatarDecorationService.ts @@ -29,7 +29,7 @@ export class AvatarDecorationService implements OnApplicationShutdown { private moderationLogService: ModerationLogService, private globalEventService: GlobalEventService, ) { - this.cache = new MemorySingleCache(1000 * 60 * 30); + this.cache = new MemorySingleCache(1000 * 60 * 30); // 30s this.redisForSub.on('message', this.onMessage); } diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index bfbc2b172d..098e94991c 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -26,7 +26,7 @@ const parseEmojiStrRegexp = /^([-\w]+)(?:@([\w.-]+))?$/; @Injectable() export class CustomEmojiService implements OnApplicationShutdown { - private cache: MemoryKVCache; + private emojisCache: MemoryKVCache; public localEmojisCache: RedisSingleCache>; constructor( @@ -49,7 +49,7 @@ export class CustomEmojiService implements OnApplicationShutdown { private globalEventService: GlobalEventService, private driveService: DriveService, ) { - this.cache = new MemoryKVCache(1000 * 60 * 60 * 12); + this.emojisCache = new MemoryKVCache(1000 * 60 * 60 * 12); // 12h this.localEmojisCache = new RedisSingleCache>(this.redisClient, 'localEmojis', { lifetime: 1000 * 60 * 30, // 30m @@ -350,14 +350,14 @@ export class CustomEmojiService implements OnApplicationShutdown { if (name == null) return null; if (host == null) return null; - const newHost = host === this.config.host ? null : host; + const newHost = host === this.config.host ? null : host; const queryOrNull = async () => (await this.emojisRepository.findOneBy({ name, host: newHost ?? IsNull(), })) ?? null; - const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull); + const emoji = await this.emojisCache.fetch(`${name} ${host}`, queryOrNull); if (emoji == null) return null; return emoji.publicUrl || emoji.originalUrl; // || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ) @@ -384,7 +384,7 @@ export class CustomEmojiService implements OnApplicationShutdown { */ @bindThis public async prefetchEmojis(emojis: { name: string; host: string | null; }[]): Promise { - const notCachedEmojis = emojis.filter(emoji => this.cache.get(`${emoji.name} ${emoji.host}`) == null); + const notCachedEmojis = emojis.filter(emoji => this.emojisCache.get(`${emoji.name} ${emoji.host}`) == null); const emojisQuery: any[] = []; const hosts = new Set(notCachedEmojis.map(e => e.host)); for (const host of hosts) { @@ -399,7 +399,7 @@ export class CustomEmojiService implements OnApplicationShutdown { select: ['name', 'host', 'originalUrl', 'publicUrl'], }) : []; for (const emoji of _emojis) { - this.cache.set(`${emoji.name} ${emoji.host}`, emoji); + this.emojisCache.set(`${emoji.name} ${emoji.host}`, emoji); } } @@ -424,7 +424,7 @@ export class CustomEmojiService implements OnApplicationShutdown { @bindThis public dispose(): void { - this.cache.dispose(); + this.emojisCache.dispose(); } @bindThis diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts index e9dc9b57af..9caeaf1714 100644 --- a/packages/backend/src/core/RelayService.ts +++ b/packages/backend/src/core/RelayService.ts @@ -35,7 +35,7 @@ export class RelayService { private createSystemUserService: CreateSystemUserService, private apRendererService: ApRendererService, ) { - this.relaysCache = new MemorySingleCache(1000 * 60 * 10); + this.relaysCache = new MemorySingleCache(1000 * 60 * 10); // 10s } @bindThis diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index f5a753afc7..f46aacaef4 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -129,10 +129,8 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { private moderationLogService: ModerationLogService, private fanoutTimelineService: FanoutTimelineService, ) { - //this.onMessage = this.onMessage.bind(this); - - this.rolesCache = new MemorySingleCache(1000 * 60 * 60 * 1); - this.roleAssignmentByUserIdCache = new MemoryKVCache(1000 * 60 * 60 * 1); + this.rolesCache = new MemorySingleCache(1000 * 60 * 60); // 1h + this.roleAssignmentByUserIdCache = new MemoryKVCache(1000 * 60 * 5); // 1h this.redisForSub.on('message', this.onMessage); } diff --git a/packages/backend/src/core/UserKeypairService.ts b/packages/backend/src/core/UserKeypairService.ts index eb7a95da3e..92d61cd103 100644 --- a/packages/backend/src/core/UserKeypairService.ts +++ b/packages/backend/src/core/UserKeypairService.ts @@ -25,7 +25,7 @@ export class UserKeypairService implements OnApplicationShutdown { ) { this.cache = new RedisKVCache(this.redisClient, 'userKeypair', { lifetime: 1000 * 60 * 60 * 24, // 24h - memoryCacheLifetime: 1000 * 60 * 60 * 12, // 12h + memoryCacheLifetime: 1000 * 60 * 60, // 1h fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }), toRedisConverter: (value) => JSON.stringify(value), fromRedisConverter: (value) => JSON.parse(value), diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index d665945861..95477aa2cd 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -45,7 +45,7 @@ export class DeliverProcessorService { private queueLoggerService: QueueLoggerService, ) { this.logger = this.queueLoggerService.logger.createSubLogger('deliver'); - this.suspendedHostsCache = new MemorySingleCache(1000 * 60 * 60); + this.suspendedHostsCache = new MemorySingleCache(1000 * 60 * 60); // 1m } @bindThis diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index 716bb0944b..bf12822964 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -135,7 +135,7 @@ export class NodeinfoServerService { return document; }; - const cache = new MemorySingleCache>>(1000 * 60 * 10); + const cache = new MemorySingleCache>>(1000 * 60 * 10); // 10s fastify.get(nodeinfo2_1path, async (request, reply) => { const base = await cache.fetch(() => nodeinfo2(21)); diff --git a/packages/backend/src/server/web/UrlPreviewService.ts b/packages/backend/src/server/web/UrlPreviewService.ts index 96038d9c1e..ef804b5bfd 100644 --- a/packages/backend/src/server/web/UrlPreviewService.ts +++ b/packages/backend/src/server/web/UrlPreviewService.ts @@ -38,8 +38,8 @@ export class UrlPreviewService { ) { this.logger = this.loggerService.getLogger('url-preview'); this.previewCache = new RedisKVCache(this.redisClient, 'summaly', { - lifetime: 1000 * 86400, - memoryCacheLifetime: 1000 * 10 * 60, + lifetime: 1000 * 60 * 60 * 24, // 1d + memoryCacheLifetime: 1000 * 60 * 10, // 10m fetcher: (key: string) => { throw new Error('the UrlPreview cache should never fetch'); }, toRedisConverter: (value) => JSON.stringify(value), fromRedisConverter: (value) => JSON.parse(value), From 4ed4547f4a14aa912054edcb8ee669c3eceae9fc Mon Sep 17 00:00:00 2001 From: Marie Date: Sat, 3 Aug 2024 22:45:49 +0000 Subject: [PATCH 11/22] upd: add icon for moving files/folders --- .../sharkey-icons/custom-sharkey-icons.svg | 3 ++- .../sharkey-icons/custom-sharkey-icons.ttf | Bin 1896 -> 2180 bytes .../sharkey-icons/custom-sharkey-icons.woff | Bin 1292 -> 1520 bytes .../assets/fonts/sharkey-icons/style.css | 4 ++++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg index 9d21137072..777fe5ab05 100644 --- a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg +++ b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg @@ -7,5 +7,6 @@ - + + diff --git a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.ttf b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.ttf index a2601e0f1b00c4f2e72249911b911e48c55d6de1..e48ffbdf738227d81b408fa91500cfd0b1b673cc 100644 GIT binary patch delta 887 zcmaFC*CJTYz{tSBz{}9Uz|0Wf<`&{Rdm7hs1_q7{1_lNhcNbST22BPY1_llf1_lN> z|6qM1|2HwU3=E7B3=9lm$+?LIEVr2x7#J9jFfcHBr6(2_{Qu9u%)r3mz`(%3k)BhT zHf^QDR0alS1qKGDB^jxSDQd^r_!$@&?l3Sgm}O+7)+e&CFtIW)Fp4lRFsNkYmQ=7Y zFt{)Ffe$4J;%tvFy;4d$#{O7uMFHw3?T66O44))%?4)h zPiA4XWM*SXnC!q9t(naD;Qs>#J;tm5KQb_YjbLD4fM|r!ObiU#3=9mClaDa!GA2*{ z#8}VBI=PT(IeQqx8O9(6hRrg}Ga2id86+9_8P74UW6)+WV2Ed65N2Z+m0^};G&eRi zR}@t=RTdQy7n5hSW;8dmXEaq;(`VFX1d+;0@{G!+#_Vh$S!E?Qb~X`lF*9>h6Ehn| zTSj9eQ8soyMsYEFMmt7xJ0>+#Jw|mkb}wOO0e(it=zmKUm{@pOw{5Ry;bviCX60fH zkC2sNW3{%e7idoxJu5d0v#bm=v%Y{r0xKuGs00%;^EoCqCU#a< zK{0v3I7V(hQ4Urv7FJdsAr5{%E+%FscSa_r$(va;>h&2;LPL{1}O%6D4Urfjv*7uW?|4^_z7jRGKeu+K-p{z8jLXv z$qc0o#SA43`3$)Xx(vmWqgYq)8#CxKSTN`^7%>M*&DEtv%r-;?E-%u_&7(H?z1nJGIh~D=j}KCABCwzbqA` i>i>TRCa^bn7#JADKqfFSGB7i+PIh3I;Xx$0r0D>8I+ExB delta 582 zcmZn>e8E@Gz{tSBz{}9Uz|0Wf<`&{RQ|jVs1_pK?1_lNhcNbST22BQT1_pK=1_lN> z|6qM1{|hlS3=E7B3=9lm$+?LIELWKm7#J9jFfcHBr6(2_{Qu9u%)r2|!oa}5k)BhT z_Gi+WNCpOG83qQ%85yaGDJtG)-ZL;T++ko~Fw4kDtxsfOVPa)qU=(3sU{J}(EvaB* zV9;h@VBEmKz#x>9pPa}L#&Cv#fmwiofq^GCv7&&%iy@qWfzg72fk7cJF*jAM*uR2- zfn^H=1CvQXesPKWl_&NL3~VnL7#OU;o?~QSSm>M<6whz-m4Tay0R$dSJNgqsvw<1f zlUW!onOPY^COa@jYbG&1`2T=GkMZjNs|*ZaBN!MMAQ~Yw6WECi43m#A>M|xx{=`^6 zxshqcWCtbz<}ijcn-!R6GEP3qs#b5na2l$eg+YW-4a#O^;ARYlve_6!7&{r585mhO z85kKf7#N^zCI%@6dnlWkA%P(i%4T8EVE6-NvoeS=T0_}v3>u8_49N_o48;s34EYSX z47v=(le5@X2%0nKG8i%#G3YWFF&HoyF&Ix)WY^>}*EKZKH8L7$!S#NHelbj^U8uL4@DYp8!>@Z|?vA diff --git a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.woff b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.woff index d9f471fa35a861eb745fb136094ffd9c90b7922f..2ac8730e3e83adc2dc0b1c9de10f631e9a3bb9e6 100644 GIT binary patch delta 1329 zcmeC-`oJwx?(gQtz{tSBz`*)}ffqz`v`iGyu$w)N>$$s&s~ZCYqYncEgB%!ZGVu5Z z>l-mJFy=5YFgP@9cSau$Vg3OU|`8$U|^78U|>*TVPRs;$StX0U|?xsU|QvfkBLcfq{vEk%5_kb#elutx#IchyRSta*wb6mru-M=()|qGkHCu zBIA?E7a8U1wMBgvN-{9KJkD+l3O@$M|Nj}7D(2V*`sQDD5V(8u{1Lx5Yv*pAtClC_ zUMi)ZIZ^g_(6fR-D z>%79NEmJAPyTG`37iazCtSH~^J?+yMoH%>NHBXH<=?A|D>-^$Vo~3cwoa~>t54bkJ z?_45Q5x4wpb=l#~YgOx|g&lX6-tE`@eDTBHqptUvkN;e2bA4)}!qP8aW@#_A=6|1b zZYyKOzekzgr=&R3S^~1gCd?|i`f`6)*_#i> z>z~d}Kc%G7^X;4F!5LN(Wo2)cJ!-ioS)YA1W;t8IX^mF@L+MvO-aadt@%MG$yv=Gy zXI#H2pB5}s&KWuVw0}hG3J&3-9!s$vU6#GA%o}7wlf_cc82{Dr`H*`+;xFsW_V6nV z3=E*;nUave@JMri`R!w$Z`Y(gNK0a91SM1Di+_B0dcqq`*qI}w7@TKtwSv`8p2VzN z&lWU^fiZ-^8=L^4L>R*v#vr(f3CSJ_326+BY6@v744sw@KY18<8W`4ttv`MsLwR3 z-G3}}pWxT|ZSm()uk4<|Ed4QC$FlWF>ye$!e|9`yG*u|HUs#bq;(hDKanSi0}x<~=*UbmvF>Nm~pK=OhQV9-bEs xygH|joH%mg%!xx$b0$ViIXiK7WXznoQJE*EPMbe@Qq+{$@zb~%>i%xZ2&t)s2CH(T9P7K@N;H8Mys} z^^F)97;_jH7@Qdx7{dH7#MC6`CKfO-Fm7OAVDMyMVDw_SIHxe=Qdo zV)k%qGcbSy0%VOC0|NsS10w@71Iy$DMq8nznh*aOo8=x~{U4r~#n63*`~BqgjEam) zCSPQfs~6>2D9ga`bSAqwDEJr{82|rgV5*p7+kf8cu!F#{^w~RBW_ld+{k*()?TkxH zZkmctGIMm*>R^8vSaqSnv^{K9^PA8c|gA0J&^oUUKX&R@$`7~FmM%!V`HXFrS% zaA;8A-o(IGYr*isdauDUL(!Bu=}WbZ--`&L@K+d+~Gdi zr2aBzn%bP@o+YxXFV8Pe{r&IV&Ast?mxJ;L?418&6rM7sJMz_uF zm8G8ZJkM9E&D|wi|B2s4YHiuE#YIa^O(&;hC)7Srb_rGQVbz^&%5&|)?r%$$WoTXX zf77SO-gfp@?rg!!f68X0E_|+}B<#$6an-Hh_8>*ZwC&SeE2U?>d7KB#t0t7{eK;NeQVOi3w>8 zjA{yLDGZ&K4L^ApxGfnLfoxjZf7a`;gGlTCm+~FEwDn@ndUY8nc6K|(?s(13akpfl zYKz&Fw1i1|zc}_a=s(ro`9bBJmrDy@%(L0X&kNqOuB$kHLH6*J`rjv**G0O^P5LBQ zdF09+SGnTMdCLAv_Mgmj6AwzOUGdCoj=TmGkLO49%YzerlOnx$uF9bNBNG z;kP#gZUh%y+I?yN@@amBIZ^cmXY+)=Jv|xPx_;?D!5L;U7qIQin{JmA={;M0W$canY}0JYBj0^834e6vZnzO!ZTQ}^S@ZIw z!%{P};&1DCp3nWrn!X|(l>R{>ljOkG!}Fp+ROi%@6Gu**iJCJpV#?Whvm;~X%#Gq? LP@T?d%fJ8t`(UT$ diff --git a/packages/backend/assets/fonts/sharkey-icons/style.css b/packages/backend/assets/fonts/sharkey-icons/style.css index 7fb0f94504..4cae7787d4 100644 --- a/packages/backend/assets/fonts/sharkey-icons/style.css +++ b/packages/backend/assets/fonts/sharkey-icons/style.css @@ -29,3 +29,7 @@ .sk-icons.sk-misskey:before { content: "\62"; } + +.sk-icons.sk-foldermove:before { + content: "\63"; +} From ba093382682380ddf1bb756e9d83b31b776fa7af Mon Sep 17 00:00:00 2001 From: Hazel K Date: Sun, 4 Aug 2024 09:58:01 -0400 Subject: [PATCH 12/22] optimize cache GC by stopping early --- packages/backend/src/misc/cache.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/misc/cache.ts b/packages/backend/src/misc/cache.ts index fc98ce8132..d968069ca3 100644 --- a/packages/backend/src/misc/cache.ts +++ b/packages/backend/src/misc/cache.ts @@ -200,7 +200,7 @@ export class RedisSingleCache { export class MemoryKVCache { private readonly cache = new Map(); - private readonly gcIntervalHandle = setInterval(() => this.gc(), 1000 * 60 * 3); + private readonly gcIntervalHandle = setInterval(() => this.gc(), 1000 * 60 * 3); // 3m constructor( private readonly lifetime: number, @@ -289,10 +289,14 @@ export class MemoryKVCache { @bindThis public gc(): void { const now = Date.now(); + for (const [key, { date }] of this.cache.entries()) { - if ((now - date) > this.lifetime) { - this.cache.delete(key); - } + // The map is ordered from oldest to youngest. + // We can stop once we find an entry that's still active, because all following entries must *also* be active. + const age = now - date; + if (age < this.lifetime) break; + + this.cache.delete(key); } } From 1e86cba7dc1cf81d03b805529fc0556c96ff286e Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 5 Aug 2024 09:27:06 +0100 Subject: [PATCH 13/22] delete old emoji file when replaced - fixes #608 it's the same code that 5f7fc54ee9359d7dae82ad70e89f930d6a2b2e61 added to `delete` and `deleteBulk`, with the extra check that we're not deleting the same file we're setting --- packages/backend/src/core/CustomEmojiService.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts index bfbc2b172d..eea0f9228d 100644 --- a/packages/backend/src/core/CustomEmojiService.ts +++ b/packages/backend/src/core/CustomEmojiService.ts @@ -142,6 +142,13 @@ export class CustomEmojiService implements OnApplicationShutdown { this.localEmojisCache.refresh(); + if (data.driveFile != null) { + const file = await this.driveFilesRepository.findOneBy({ url: emoji.originalUrl, userHost: emoji.host ? emoji.host : IsNull() }); + if (file && file.id != data.driveFile.id) { + await this.driveService.deleteFile(file, false, moderator ? moderator : undefined); + } + } + const packed = await this.emojiEntityService.packDetailed(emoji.id); if (emoji.name === data.name) { From 0386e52d6f8231a879ccf72e166b04f71b9d11db Mon Sep 17 00:00:00 2001 From: 4censord Date: Sun, 4 Aug 2024 18:09:48 +0200 Subject: [PATCH 14/22] Impove the check_connect script --- packages/backend/scripts/check_connect.js | 32 +++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/backend/scripts/check_connect.js b/packages/backend/scripts/check_connect.js index ba25fd416c..d4bf4baf43 100644 --- a/packages/backend/scripts/check_connect.js +++ b/packages/backend/scripts/check_connect.js @@ -5,11 +5,33 @@ import Redis from 'ioredis'; import { loadConfig } from '../built/config.js'; +import { createPostgresDataSource } from '../built/postgres.js'; const config = loadConfig(); -const redis = new Redis(config.redis); -redis.on('connect', () => redis.disconnect()); -redis.on('error', (e) => { - throw e; -}); +// createPostgresDataSource handels primaries and replicas automatically. +// usually, it only opens connections first use, so we force it using +// .initialize() +createPostgresDataSource(config) + .initialize() + .then(c => { c.destroy() }) + .catch(e => { throw e }); + + +// Connect to all redis servers +function connectToRedis(redisOptions) { + const redis = new Redis(redisOptions); + redis.on('connect', () => redis.disconnect()); + redis.on('error', (e) => { + throw e; + }); +} + +// If not all of these are defined, the default one gets reused. +// so we use a Set to only try connecting once to each **uniq** redis. +(new Set([ + config.redis, + config.redisForPubsub, + config.redisForJobQueue, + config.redisForTimelines, +])).forEach(connectToRedis); From 61c13241babbd9424e9d8ac21c7fe84ecc6c5018 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 6 Aug 2024 10:13:53 +0100 Subject: [PATCH 15/22] use `XMLSerializer` for `toMastoApiHtml` - fixes #556 the `inline` bit is not pretty, but does the job --- packages/backend/src/core/MfmService.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 625df1feaa..76d0eb2339 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -6,7 +6,7 @@ import { URL } from 'node:url'; import { Inject, Injectable } from '@nestjs/common'; import * as parse5 from 'parse5'; -import { Window, XMLSerializer } from 'happy-dom'; +import { Window, DocumentFragment, XMLSerializer } from 'happy-dom'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import { intersperse } from '@/misc/prelude/array.js'; @@ -483,6 +483,8 @@ export class MfmService { const doc = window.document; + const body = doc.createElement('p'); + async function appendChildren(children: mfm.MfmNode[], targetElement: any): Promise { if (children) { for (const child of await Promise.all(children.map(async (x) => await (handlers as any)[x.type](x)))) targetElement.appendChild(child); @@ -661,7 +663,7 @@ export class MfmService { }, }; - await appendChildren(nodes, doc.body); + await appendChildren(nodes, body); if (quoteUri !== null) { const a = doc.createElement('a'); @@ -675,9 +677,15 @@ export class MfmService { quote.innerHTML += 'RE: '; quote.appendChild(a); - doc.body.appendChild(quote); + body.appendChild(quote); } - return inline ? doc.body.innerHTML : `

${doc.body.innerHTML}

`; + let result = new XMLSerializer().serializeToString(body); + + if (inline) { + result = result.replace(/^

/,'').replace(/<\/p>$/,''); + } + + return result; } } From 9d4d2a1fad27abe853b90cb4bab5ba9ea331fe23 Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:35:52 +0000 Subject: [PATCH 16/22] upd: align font with new repo --- .../sharkey-icons/custom-sharkey-icons.svg | 12 -- .../sharkey-icons/custom-sharkey-icons.ttf | Bin 2180 -> 0 bytes .../sharkey-icons/custom-sharkey-icons.woff | Bin 1520 -> 0 bytes .../assets/fonts/sharkey-icons/shark-font.svg | 30 +++++ .../assets/fonts/sharkey-icons/shark-font.ttf | Bin 0 -> 2652 bytes .../fonts/sharkey-icons/shark-font.woff | Bin 0 -> 1736 bytes .../assets/fonts/sharkey-icons/style.css | 117 +++++++++++++++--- 7 files changed, 128 insertions(+), 31 deletions(-) delete mode 100644 packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg delete mode 100644 packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.ttf delete mode 100644 packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.woff create mode 100644 packages/backend/assets/fonts/sharkey-icons/shark-font.svg create mode 100644 packages/backend/assets/fonts/sharkey-icons/shark-font.ttf create mode 100644 packages/backend/assets/fonts/sharkey-icons/shark-font.woff diff --git a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg deleted file mode 100644 index 777fe5ab05..0000000000 --- a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.ttf b/packages/backend/assets/fonts/sharkey-icons/custom-sharkey-icons.ttf deleted file mode 100644 index e48ffbdf738227d81b408fa91500cfd0b1b673cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2180 zcmZQzWME+6WoTevW(aU|3-O&jjq5oB14jk}1A~mai>n)hCIb%x1BV9#1B0A@u)dN1 zo0wV#2F3^m28OWY+{6Nw+sp|J42(w@7#O|M6N?M}|7T!kVBm0IU|`@#qCw$foL z0|T=H0|V2NjMT&wwc~933=9l+7#JALGBQ#VSy-4@85kHv7#J8-GIC2Q*ccdG7#J8g zFfcHP40MvkQxRyh6Ipr85qDi8Np&8pM#V!GBGetU|?n7VDw>3V_;x# zhtgjeBpF&j8dy0&%D@;D2Ve$>2uO2HVQ^qbWJqRw@c#jW9^=*j9~s~-fVc>xAB?pb z7#JiO7{IPz2E`fJ4WKY&2D4-sSQs=I7#P?XKrRMpPX7NNWD7$gi2lC_tO_i^$OgBB zff1wzb3F;XdJ7FJTV43PRThBJ&o;E>g3&}O{Kc$GnjL6yOhfk9PNSxKEu zolTq3)Y!;e%*b5KSk=s)(M(;AQCv)1k5O5PolRU!oJ|R&L=>vTn$c8QiSeqIrfz7c zuBMijuBKX?nx^i*WBkGr5{j-R5|ZNL%Tu}8*;uXCsl};jYinugXlX=gXz6HaX|L86 z)z%i(mX?;5)@R`n2#w^)@f2Xpn##q=Q+h#KT1HD$R8&+8>{bQ_ZzcxDtqdj%&J4i} z4CYGeYD(;)BJ6C+O6qF1j3(x0=4Qr5@=S7!#zyvxX2wS1V&Y=5jBo{N>}()CrY0a| z;$kA~e2hj=1yBR_DG9J}F$xJuO9~5d^9XTs$qCytF|)I)nimwWA_qf7T{-OjQ+P&fr*8eb=!6p zZWbnHRxZ}?2w536R%_dOf%bG!E@ozNiSP&(W+o;UJ|@P10B&AUHf9!1R#p)Xem)LH zMmJ_=7RI&g!mKQO!jin+jN00FV~vbhd0Cj4*f?3=vvRXA%gQh_>kB9(uyV4CN-!}q zpJQTUVrOL)6q6T>W8~%&TrQC_A-MH#0duub2U!1~ip!V1r5+Ky(p9IzuXh0)r8Q z9)kgc0)rKU0?`hEs5WNMWw2n-WiVneU@&4ZVPJ5}&nt1uFG^2UFw!$nuu{P0Tm>ry zV_gefBLgE72BPi5;qfqrRE8pkVunnxw-gu*!CqkqOD!tS%+FIW)H9&i3TTamC|WVg zb~bRG!^FtM$jr#X3J!6O+|1(Q?9@s_uC)A|l+>c!{IXP#s{j8Pn7}EBhk=1X3~V+d b12Y3F10w?qm3Y{%8Nt~)?n7I^^F)97;_jH7@Qdx7{dJD#MCC|CKfO-Fm7OAVDMsKVDw_S&76>) zSPT;T!@$760mA?PGcc#;RHiX7FtIQ&Fc~s1FfEz3(qU>wYGMil1B(R%1A{ID1B02` zaW?*pjMPL129^wvI~W)kR9IM;STk}2qCAjZJJz{J4F zz|6qPz{tP?<}olZfb^y$CCoW+;M9SGFAmQ*cHqDRzNPz(JdCy&7#J9CC^9<0pv)}9 z;Zf|HSdie6;*nPK;Xh-u+~ceNwy4iSNd|_O$JuSc zam)DsKLb<69NR$O{L2mkcW<6Q;`e6l+^uuf@}%5LrSvl=${ugJB*w|u6r;6p6|2j` zrU?S>7R9T6uzLJqJi-`Q$e1T%85UFZp$45_|V4Yul%Cj^so0I($_W{@D_nk|`D&m&Etu8yfd97-_w6NpO(!2e- zpD%vcd(`zl^YNc+ZLUvER9O1u%Pj4s*8K02&TVC^`1dH&`;-)CT1!B-*o0XnS6}Y$ zDx33T^OVGjbCWJb6)Zj+aPGFOo1WG6TW)$XhbQhlpZY~YaX$A|Rl^Y1$giRMWmbeq zd`V!|DxO<3V_kDwrHqQL#FV3dJk&gQJYX|ld+OvDshn9`HS%2A51QpTZf(6>baum$ z*!dpf4<6q9o$53D&1>_lV4oRBzkPeGmo7bf{nOd$r<7EBzJ1d?IKxV!tnAIQM=jSR zv#-W1XDc|Z(dvIF{mRGNXC*WKz7CwXS?%bI>o?`of`!UCBd4GCkBD8tAzajBDb}OQ zvbU9agKTKBSn3($zdAl2at}!SWu4g`eg&466A~C6Y3?t-eeCn?n$!nrNeqpk{GfdC zj}K2zc%unBbA%Lw^9-(5g!(6dj_-g$7~(T)+en;b~gXn@qE!#p|D@N{h#*a?^?<~JL>kH3*3LN z?@&7Lo0*fi^x>hS;YmC}WfzytJQ^Btbz$kgi<|fC_|lyp@h5FDxGYF=VC&&|(ZH*7 u>d1*BC(fKW6g6jJ#FVoWXGg}&nH!aPV(PT{lP5(@nH@iki=pm6=OzFbjaMQ7 diff --git a/packages/backend/assets/fonts/sharkey-icons/shark-font.svg b/packages/backend/assets/fonts/sharkey-icons/shark-font.svg new file mode 100644 index 0000000000..b67bd7f7d8 --- /dev/null +++ b/packages/backend/assets/fonts/sharkey-icons/shark-font.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + diff --git a/packages/backend/assets/fonts/sharkey-icons/shark-font.ttf b/packages/backend/assets/fonts/sharkey-icons/shark-font.ttf new file mode 100644 index 0000000000000000000000000000000000000000..0fdf04df082cc5724a7c94b19b299cfd5a317040 GIT binary patch literal 2652 zcmZQzWME+6W@unwW-xFM4s}wTp=QXyz-Yn1z%b80Sl=i>)HR-gf$;_d14BY`Zejt? zu_-$k7?>Iu7?>uc=TxSB>JRQF$xlw?^5QIEU|+oO{^$jlxIj_U|^JBU|>+l zOUzCERWx@I0|WaS1_ma*g8br=o)7oGGB9x7VPIgW1G$|EWE=yW1o;Lm0wsh%YCyOl z^~&^kew(ih+z_=;c{s(yz<8B`fq?^R6az>PgAhXq12b3&ND~(W7Xt&se=r{+&&6QC zV8_7Z;^q^=z?YL)lE)y$z=9-?%x28VOiyIsV1VdkWMBcSWMtrAU}W%OU}oT9P-C!S z0Esg)a51nluraVRa4>L!+1y}NEDTHx>+N}M20kmOom*Be1>9%GKR`m%>O}glgN<5kin46kk3#A7G(sB zqPvWdL4-ksL4rYwL5@L=K>-XI7zDv#&cYzTz{9}Dzy=O`P6l2EZg5yLfn3Q5NxMA`WmJ!otWb zE)gEV!otYN$im0O7!aV#!pOqTq9)D7$mqt#xR#lZlUYsOn^9Z)ZfqPoCl?bF6B{S% zdsc21W?30#W_7(ZtN$%-BetQOwAm(ahLLT#iweQG^X7qsGS0 z$7rsku4ZCpBqqYfZX_-SlQJkd&CHMuQ{$RYyc$GnzL6gCjfk9PNSxKEuNu5ob z(bU+;T+GN^%vjaTp3zKQj!|4pT#r#*O<9ReT#TJf9HL4Ts>+(tR9T7fs+NYHMwEuG zrk0kjrdphurtZIE0zwiJimoLRlH&Z~Hg?Y3ysQdLOlQ>M)U>s=v~;vIqBOL0w6wHW zYm17Ah-ynqOH1ps@CbxP^5l35FuIm1DGT#B*cwikmX^^H6%`fL0_8LY1_6d+ptK9F zML>B0QYwS$1um#KsH_x(vO#r$G?dNCz|EivWrIpK11Ot|K^t7}fXwG+5N1dPmAWjP z44@LS0?KA$;A7~4vY8n~7-m7)EDR!$QksR6ft5jw;Sf}ujX{Lr29(Xk5XSHZ%I0QJ zV{|IcNG!_MP0P|UhJ1!Rh7yJ#hE#@hhEj$cunaa8*u=sZQW=UEiWxG&rYJBNGUzcFU^U;JA(bHy ztU8gQgdvq7g+YNKiJ_7~0bFOLGZ-CnrZA>57BS{BmN8~B7BgluRx)NVg6abX0KOP8o&W#< literal 0 HcmV?d00001 diff --git a/packages/backend/assets/fonts/sharkey-icons/shark-font.woff b/packages/backend/assets/fonts/sharkey-icons/shark-font.woff new file mode 100644 index 0000000000000000000000000000000000000000..993666bc3aacaf202da6002fbc9baa8e7a881581 GIT binary patch literal 1736 zcmXT-cXMN4WME)mU^~IU4WhYXAbb!T6}tzAIx#RXaxgG36frO`%u}49X6PTRZ^XdB zSi``;V9&t7kPsm18lRk-Sir!*xQBs(;Ryo+(*&MlQ+A~1RHiX7FfCwUV3K5DU@H04 zAKa0VnwY}CzyeaI#=yW}mMG_NDI+5_k%58b2?GOzC<6n73JW8Xa7J!P1p@=i9|i^n z0R{#J4>kq{hMfH5LguKMu zR0alC2L=X40|o{ryK z7KP6)9lh-vAHL>ilKR&fS0-FJ&T-1F`9dAALM@iPk!Yj$88kf7)CP$W^ zi>R><`?zQzFPSTtD8ldm(5*KmMiZSrFA82&k`?=sqHIv6gEoFu?+pg@`HJf zKtFSgWs%dJsweUxkJuGLbG(0=%#wWh+s$}Bo8S^g`-jS17o>J|2W;o{3D8`%XT`Ck zn3klDT8Z$dW+D@3Iaf?%l0T%Bo;zXPyQa^Q;k!~pr*NMzUf8Lab6CvfwQ*3g z{7YihwRW+3etP{;aCNjqa+G=fY~E&`Fpim@FAB#P&-k$6=C35?qdjX<-3^R=-5z-D z&wNyy`{R(Y+XvC5E1ar1LL0k64zxHQcF;{&yyle6=YwarIhq%7Fc-YAT)d(zjCJBI z4dd$zbtb>7&swat|D&C;&fep}n=Wr?yDNL_rC)i1sddpL?G>|ge)hk(QD?;^lUZE< ztoXNXe&DPxQ(n!rN_M+rz4ce_^bHd&V&|=h3sO$&u7Bpe^8I96np{X*Qm5%GV-`M(FtGC=ZANYlJ43Jh^;SkA%q3M6qPCZsViswq5Ua$;-ypJ2z#AheRPfuUkf?nG<9 z!ww>@>pwdm5n^i0$XM3MmikFEI7p?o>x-Y!x%1y59(%fcJHQpe(!C&oSEtFfAa`C0 zXR1#BIqTy4J@yRiKDIJE<+!l+S&>P>!B_pWmqNpWzB@es>)lbR=h$A@@BfhR@Ad-m;y)bi6PKuanz1!G(z4^W8kL&Ek z)=xKcZRAz5cyrO2r<+I4c;9;|c9pBAb{?@bPY<7YFKp`}fm!!I#}u7P30tZh#-_bY z+@esg;K@nlsPkJMy}dDclG>&0A0eEPitDeHnRr*7Ek3nw&i}RNwf{}O?o+rt{`S$7 zkcv6E2TyV}D2O;*EZ3g>e4l}bp$|*zg8lgyw-u{Q?w?ezEosTxHK}V>+qAxUjT1X( twodhp5?<%*E}s|s(^z%6{M0vcvTX;BHmW_^Y3XSpr?dM6w{e7k8vquk!u|jN literal 0 HcmV?d00001 diff --git a/packages/backend/assets/fonts/sharkey-icons/style.css b/packages/backend/assets/fonts/sharkey-icons/style.css index 4cae7787d4..593337e992 100644 --- a/packages/backend/assets/fonts/sharkey-icons/style.css +++ b/packages/backend/assets/fonts/sharkey-icons/style.css @@ -1,35 +1,114 @@ -@charset "UTF-8"; - @font-face { - font-family: "custom-sharkey-icons"; - src: url("./custom-sharkey-icons.woff") format("woff"), - url("./custom-sharkey-icons.ttf") format("truetype"), - url("./custom-sharkey-icons.svg#custom-sharkey-icons") format("svg"); - font-weight: normal; + font-display: auto; + font-family: "shark-font"; font-style: normal; - font-display: block; + font-weight: normal; + + src: url("./shark-font.woff") format("woff"), url("./shark-font.ttf") format("truetype"), url("./shark-font.svg#shark-font") format("svg"); } .sk-icons { - font-family: "custom-sharkey-icons" !important; - font-style: normal; + display: inline-block; + font-family: "shark-font"; font-weight: normal; + font-style: normal; font-variant: normal; - text-transform: none; + text-rendering: auto; line-height: 1; - speak: none; - -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; } -.sk-icons.sk-shark:before { - content: "\61"; +.sk-icons-lg { + font-size: 1.33333em; + line-height: 0.75em; + vertical-align: -0.0667em; } -.sk-icons.sk-misskey:before { - content: "\62"; +.sk-icons-xs { + font-size: 0.75em; } -.sk-icons.sk-foldermove:before { - content: "\63"; +.sk-icons-sm { + font-size: 0.875em; } + +.sk-icons-1x { + font-size: 1em; +} + +.sk-icons-2x { + font-size: 2em; +} + +.sk-icons-3x { + font-size: 3em; +} + +.sk-icons-4x { + font-size: 4em; +} + +.sk-icons-5x { + font-size: 5em; +} + +.sk-icons-6x { + font-size: 6em; +} + +.sk-icons-7x { + font-size: 7em; +} + +.sk-icons-8x { + font-size: 8em; +} + +.sk-icons-9x { + font-size: 9em; +} + +.sk-icons-10x { + font-size: 10em; +} + +.sk-icons-fw { + text-align: center; + width: 1.25em; +} + +.sk-icons-border { + border: solid 0.08em #eee; + border-radius: 0.1em; + padding: 0.2em 0.25em 0.15em; +} + +.sk-icons-pull-left { + float: left; +} + +.sk-icons-pull-right { + float: right; +} + +.sk-icons.sk-icons-pull-left { + margin-right: 0.3em; +} + +.sk-icons.sk-icons-pull-right { + margin-left: 0.3em; +} + + +.sk-icons.sk-foldermove::before { + content: "\ea01"; +} + +.sk-icons.sk-misskey::before { + content: "\ea02"; +} + +.sk-icons.sk-shark::before { + content: "\ea03"; +} \ No newline at end of file From 6d7cebb61c506c155da8ca30a97a263dbe7798ba Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:39:19 +0000 Subject: [PATCH 17/22] chore: add icon font to contributing --- CONTRIBUTING.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2acacd6dfa..1999828755 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,6 +94,12 @@ The owner [@syuilo](https://github.com/syuilo) merges the PR into the develop br If your language is not listed in Crowdin, please open an issue. +## Icon Font (Shark Font) +Sharkey has its own Icon Font called Shark Font which can be found at https://activitypub.software/TransFem-org/shark-font +Build Instructions can all be found over there in the `README`. + +If you have an Icon Suggestion or want to add an Icon please open an issue over at that repo. + ![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg) ## Development From 45611e504c074fbb9cbcffc4dffc042967aeedf2 Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:43:15 +0000 Subject: [PATCH 18/22] chore: fix positioning in contributing --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1999828755..f75fbd05fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,13 +94,13 @@ The owner [@syuilo](https://github.com/syuilo) merges the PR into the develop br If your language is not listed in Crowdin, please open an issue. +![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg) + ## Icon Font (Shark Font) Sharkey has its own Icon Font called Shark Font which can be found at https://activitypub.software/TransFem-org/shark-font Build Instructions can all be found over there in the `README`. -If you have an Icon Suggestion or want to add an Icon please open an issue over at that repo. - -![Crowdin](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg) +If you have an Icon Suggestion or want to add an Icon please open an issue/merge request over at that repo. ## Development During development, it is useful to use the From d79880987506f4cfb8b69c8134fc5beb6083e42c Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:54:18 +0000 Subject: [PATCH 19/22] upd: add back in timestamps on src --- packages/backend/assets/fonts/sharkey-icons/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/assets/fonts/sharkey-icons/style.css b/packages/backend/assets/fonts/sharkey-icons/style.css index 593337e992..7168702e5a 100644 --- a/packages/backend/assets/fonts/sharkey-icons/style.css +++ b/packages/backend/assets/fonts/sharkey-icons/style.css @@ -4,7 +4,7 @@ font-style: normal; font-weight: normal; - src: url("./shark-font.woff") format("woff"), url("./shark-font.ttf") format("truetype"), url("./shark-font.svg#shark-font") format("svg"); + src: url("./shark-font.woff?1722899913909") format("woff"), url("./shark-font.ttf?1722899913909") format("truetype"), url("./shark-font.svg?1722899913909#shark-font") format("svg"); } .sk-icons { From 1033436349371f2bf4d0eda9da5794030a9ab7b2 Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:58:56 +0000 Subject: [PATCH 20/22] chore: add note about updating css and font files --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f75fbd05fd..d7aaa4f555 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,6 +102,10 @@ Build Instructions can all be found over there in the `README`. If you have an Icon Suggestion or want to add an Icon please open an issue/merge request over at that repo. +When Updating the Font make sure to copy **all generated files** from the `dest` folder into `packages/backend/assets/fonts/sharkey-icons` + +For the CSS simply copy the file content and replace the old content in `style.css` and for the WOFF, TTF and SVG simply replace them. + ## Development During development, it is useful to use the From e82cc99528f7c9fe9e8e8c82d02a8240b46d6a77 Mon Sep 17 00:00:00 2001 From: Marie Date: Tue, 6 Aug 2024 15:59:24 +0000 Subject: [PATCH 21/22] chore: remove space --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d7aaa4f555..053fffcaeb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,7 +103,6 @@ Build Instructions can all be found over there in the `README`. If you have an Icon Suggestion or want to add an Icon please open an issue/merge request over at that repo. When Updating the Font make sure to copy **all generated files** from the `dest` folder into `packages/backend/assets/fonts/sharkey-icons` - For the CSS simply copy the file content and replace the old content in `style.css` and for the WOFF, TTF and SVG simply replace them. ## Development From 9930c64f2d4a198551cfcff1a7c84b5ab10b54f4 Mon Sep 17 00:00:00 2001 From: Hazel K Date: Mon, 5 Aug 2024 21:19:29 -0400 Subject: [PATCH 22/22] Fix timeout comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> --- packages/backend/src/core/RelayService.ts | 2 +- packages/backend/src/core/RoleService.ts | 2 +- .../backend/src/queue/processors/DeliverProcessorService.ts | 2 +- packages/backend/src/server/NodeinfoServerService.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts index 9caeaf1714..91857dc683 100644 --- a/packages/backend/src/core/RelayService.ts +++ b/packages/backend/src/core/RelayService.ts @@ -35,7 +35,7 @@ export class RelayService { private createSystemUserService: CreateSystemUserService, private apRendererService: ApRendererService, ) { - this.relaysCache = new MemorySingleCache(1000 * 60 * 10); // 10s + this.relaysCache = new MemorySingleCache(1000 * 60 * 10); // 10m } @bindThis diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index f46aacaef4..2b6089fd3a 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -130,7 +130,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { private fanoutTimelineService: FanoutTimelineService, ) { this.rolesCache = new MemorySingleCache(1000 * 60 * 60); // 1h - this.roleAssignmentByUserIdCache = new MemoryKVCache(1000 * 60 * 5); // 1h + this.roleAssignmentByUserIdCache = new MemoryKVCache(1000 * 60 * 5); // 5m this.redisForSub.on('message', this.onMessage); } diff --git a/packages/backend/src/queue/processors/DeliverProcessorService.ts b/packages/backend/src/queue/processors/DeliverProcessorService.ts index 95477aa2cd..4076e9da90 100644 --- a/packages/backend/src/queue/processors/DeliverProcessorService.ts +++ b/packages/backend/src/queue/processors/DeliverProcessorService.ts @@ -45,7 +45,7 @@ export class DeliverProcessorService { private queueLoggerService: QueueLoggerService, ) { this.logger = this.queueLoggerService.logger.createSubLogger('deliver'); - this.suspendedHostsCache = new MemorySingleCache(1000 * 60 * 60); // 1m + this.suspendedHostsCache = new MemorySingleCache(1000 * 60 * 60); // 1h } @bindThis diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts index bf12822964..bc8d3c0411 100644 --- a/packages/backend/src/server/NodeinfoServerService.ts +++ b/packages/backend/src/server/NodeinfoServerService.ts @@ -135,7 +135,7 @@ export class NodeinfoServerService { return document; }; - const cache = new MemorySingleCache>>(1000 * 60 * 10); // 10s + const cache = new MemorySingleCache>>(1000 * 60 * 10); // 10m fastify.get(nodeinfo2_1path, async (request, reply) => { const base = await cache.fetch(() => nodeinfo2(21));