Compare commits
	
		
			7 Commits
		
	
	
		
			featured-s
			...
			multiple-r
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					0ddd4bc545 | ||
| 
						 | 
					cb6a1c773e | ||
| 
						 | 
					9df887ba93 | ||
| 
						 | 
					a2769d0733 | ||
| 
						 | 
					036f90133c | ||
| 
						 | 
					f9bfff604d | ||
| 
						 | 
					fd0e840138 | 
							
								
								
									
										14
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								CHANGELOG.md
									
									
									
									
									
								
							@@ -1,15 +1,3 @@
 | 
			
		||||
## Unreleased
 | 
			
		||||
 | 
			
		||||
### General
 | 
			
		||||
- Enhance: ハイライトからセンシティブなメディアを含むノートを除外するオプション
 | 
			
		||||
 | 
			
		||||
### Client
 | 
			
		||||
-
 | 
			
		||||
 | 
			
		||||
### Server
 | 
			
		||||
-
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## 2024.8.0
 | 
			
		||||
 | 
			
		||||
### General
 | 
			
		||||
@@ -45,8 +33,6 @@
 | 
			
		||||
- Fix: 無制限にストリーミングのチャンネルに接続できる問題を修正
 | 
			
		||||
- Fix: ベースロールのポリシーを変更した際にモデログに記録されないのを修正  
 | 
			
		||||
  (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/700)
 | 
			
		||||
- Fix: Prevent memory leak from memory caches (#14310)
 | 
			
		||||
- Fix: More reliable memory cache eviction (#14311)
 | 
			
		||||
 | 
			
		||||
## 2024.7.0
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2316,7 +2316,6 @@ _pages:
 | 
			
		||||
  eyeCatchingImageSet: "Set thumbnail"
 | 
			
		||||
  eyeCatchingImageRemove: "Delete thumbnail"
 | 
			
		||||
  chooseBlock: "Add a block"
 | 
			
		||||
  enterSectionTitle: "Enter a section title"
 | 
			
		||||
  selectType: "Select a type"
 | 
			
		||||
  contentBlocks: "Content"
 | 
			
		||||
  inputBlocks: "Input"
 | 
			
		||||
@@ -2500,10 +2499,7 @@ _moderationLogTypes:
 | 
			
		||||
  createAbuseReportNotificationRecipient: "Create a recipient for abuse reports"
 | 
			
		||||
  updateAbuseReportNotificationRecipient: "Update recipients for abuse reports"
 | 
			
		||||
  deleteAbuseReportNotificationRecipient: "Delete a recipient for abuse reports"
 | 
			
		||||
  deleteAccount: "Delete the account"
 | 
			
		||||
  deletePage: "Delete the page"
 | 
			
		||||
  deleteFlash: "Delete Play"
 | 
			
		||||
  deleteGalleryPost: "Delete the gallery post"
 | 
			
		||||
_fileViewer:
 | 
			
		||||
  title: "File details"
 | 
			
		||||
  type: "File type"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								locales/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								locales/index.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -6686,6 +6686,10 @@ export interface Locale extends ILocale {
 | 
			
		||||
             * ノートのピン留めの最大数
 | 
			
		||||
             */
 | 
			
		||||
            "pinMax": string;
 | 
			
		||||
            /**
 | 
			
		||||
             * 一つのノートに対する最大リアクション数
 | 
			
		||||
             */
 | 
			
		||||
            "reactionsPerNoteLimit": string;
 | 
			
		||||
            /**
 | 
			
		||||
             * アンテナの作成可能数
 | 
			
		||||
             */
 | 
			
		||||
 
 | 
			
		||||
@@ -1728,6 +1728,7 @@ _role:
 | 
			
		||||
    alwaysMarkNsfw: "ファイルにNSFWを常に付与"
 | 
			
		||||
    canUpdateBioMedia: "アイコンとバナーの更新を許可"
 | 
			
		||||
    pinMax: "ノートのピン留めの最大数"
 | 
			
		||||
    reactionsPerNoteLimit: "一つのノートに対する最大リアクション数"
 | 
			
		||||
    antennaMax: "アンテナの作成可能数"
 | 
			
		||||
    wordMuteMax: "ワードミュートの最大文字数"
 | 
			
		||||
    webhookMax: "Webhookの作成可能数"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "misskey",
 | 
			
		||||
	"version": "2024.8.0",
 | 
			
		||||
	"version": "2024.8.0-rc.3",
 | 
			
		||||
	"codename": "nasubi",
 | 
			
		||||
	"repository": {
 | 
			
		||||
		"type": "git",
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,20 @@
 | 
			
		||||
/*
 | 
			
		||||
 * SPDX-FileCopyrightText: syuilo and misskey-project
 | 
			
		||||
 * SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
export class MultipleReactions1721117896543 {
 | 
			
		||||
	name = 'MultipleReactions1721117896543';
 | 
			
		||||
 | 
			
		||||
	async up(queryRunner) {
 | 
			
		||||
		await queryRunner.query('DROP INDEX "public"."IDX_ad0c221b25672daf2df320a817"');
 | 
			
		||||
		await queryRunner.query('CREATE UNIQUE INDEX "IDX_a7751b74317122d11575bff31c" ON "note_reaction" ("userId", "noteId", "reaction") ');
 | 
			
		||||
		await queryRunner.query('CREATE INDEX "IDX_ad0c221b25672daf2df320a817" ON "note_reaction" ("userId", "noteId") ');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	async down(queryRunner) {
 | 
			
		||||
		await queryRunner.query('DROP INDEX "public"."IDX_ad0c221b25672daf2df320a817"');
 | 
			
		||||
		await queryRunner.query('DROP INDEX "public"."IDX_a7751b74317122d11575bff31c"');
 | 
			
		||||
		await queryRunner.query('CREATE UNIQUE INDEX "IDX_ad0c221b25672daf2df320a817" ON "note_reaction" ("userId", "noteId") ');
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -29,7 +29,7 @@ export class AvatarDecorationService implements OnApplicationShutdown {
 | 
			
		||||
		private moderationLogService: ModerationLogService,
 | 
			
		||||
		private globalEventService: GlobalEventService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.cache = new MemorySingleCache<MiAvatarDecoration[]>(1000 * 60 * 30); // 30s
 | 
			
		||||
		this.cache = new MemorySingleCache<MiAvatarDecoration[]>(1000 * 60 * 30);
 | 
			
		||||
 | 
			
		||||
		this.redisForSub.on('message', this.onMessage);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -56,10 +56,10 @@ export class CacheService implements OnApplicationShutdown {
 | 
			
		||||
	) {
 | 
			
		||||
		//this.onMessage = this.onMessage.bind(this);
 | 
			
		||||
 | 
			
		||||
		this.userByIdCache = new MemoryKVCache<MiUser>(1000 * 60 * 5); // 5m
 | 
			
		||||
		this.localUserByNativeTokenCache = new MemoryKVCache<MiLocalUser | null>(1000 * 60 * 5); // 5m
 | 
			
		||||
		this.localUserByIdCache = new MemoryKVCache<MiLocalUser>(1000 * 60 * 5); // 5m
 | 
			
		||||
		this.uriPersonCache = new MemoryKVCache<MiUser | null>(1000 * 60 * 5); // 5m
 | 
			
		||||
		this.userByIdCache = new MemoryKVCache<MiUser>(Infinity);
 | 
			
		||||
		this.localUserByNativeTokenCache = new MemoryKVCache<MiLocalUser | null>(Infinity);
 | 
			
		||||
		this.localUserByIdCache = new MemoryKVCache<MiLocalUser>(Infinity);
 | 
			
		||||
		this.uriPersonCache = new MemoryKVCache<MiUser | null>(Infinity);
 | 
			
		||||
 | 
			
		||||
		this.userProfileCache = new RedisKVCache<MiUserProfile>(this.redisClient, 'userProfile', {
 | 
			
		||||
			lifetime: 1000 * 60 * 30, // 30m
 | 
			
		||||
@@ -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.entries) {
 | 
			
		||||
						for (const [k, v] of this.uriPersonCache.cache.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.entries) {
 | 
			
		||||
						for (const [k, v] of this.uriPersonCache.cache.entries()) {
 | 
			
		||||
							if (v.value?.id === user.id) {
 | 
			
		||||
								this.uriPersonCache.set(k, user);
 | 
			
		||||
							}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ const parseEmojiStrRegexp = /^([-\w]+)(?:@([\w.-]+))?$/;
 | 
			
		||||
 | 
			
		||||
@Injectable()
 | 
			
		||||
export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
	private emojisCache: MemoryKVCache<MiEmoji | null>;
 | 
			
		||||
	private cache: MemoryKVCache<MiEmoji | null>;
 | 
			
		||||
	public localEmojisCache: RedisSingleCache<Map<string, MiEmoji>>;
 | 
			
		||||
 | 
			
		||||
	constructor(
 | 
			
		||||
@@ -40,7 +40,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
		private moderationLogService: ModerationLogService,
 | 
			
		||||
		private globalEventService: GlobalEventService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.emojisCache = new MemoryKVCache<MiEmoji | null>(1000 * 60 * 60 * 12); // 12h
 | 
			
		||||
		this.cache = new MemoryKVCache<MiEmoji | null>(1000 * 60 * 60 * 12);
 | 
			
		||||
 | 
			
		||||
		this.localEmojisCache = new RedisSingleCache<Map<string, MiEmoji>>(this.redisClient, 'localEmojis', {
 | 
			
		||||
			lifetime: 1000 * 60 * 30, // 30m
 | 
			
		||||
@@ -334,7 +334,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
			host,
 | 
			
		||||
		})) ?? null;
 | 
			
		||||
 | 
			
		||||
		const emoji = await this.emojisCache.fetch(`${name} ${host}`, queryOrNull);
 | 
			
		||||
		const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull);
 | 
			
		||||
 | 
			
		||||
		if (emoji == null) return null;
 | 
			
		||||
		return emoji.publicUrl || emoji.originalUrl; // || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
 | 
			
		||||
@@ -361,7 +361,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
	 */
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async prefetchEmojis(emojis: { name: string; host: string | null; }[]): Promise<void> {
 | 
			
		||||
		const notCachedEmojis = emojis.filter(emoji => this.emojisCache.get(`${emoji.name} ${emoji.host}`) == null);
 | 
			
		||||
		const notCachedEmojis = emojis.filter(emoji => this.cache.get(`${emoji.name} ${emoji.host}`) == null);
 | 
			
		||||
		const emojisQuery: any[] = [];
 | 
			
		||||
		const hosts = new Set(notCachedEmojis.map(e => e.host));
 | 
			
		||||
		for (const host of hosts) {
 | 
			
		||||
@@ -376,7 +376,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
			select: ['name', 'host', 'originalUrl', 'publicUrl'],
 | 
			
		||||
		}) : [];
 | 
			
		||||
		for (const emoji of _emojis) {
 | 
			
		||||
			this.emojisCache.set(`${emoji.name} ${emoji.host}`, emoji);
 | 
			
		||||
			this.cache.set(`${emoji.name} ${emoji.host}`, emoji);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -401,7 +401,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public dispose(): void {
 | 
			
		||||
		this.emojisCache.dispose();
 | 
			
		||||
		this.cache.dispose();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
 
 | 
			
		||||
@@ -174,24 +174,12 @@ export class ReactionService {
 | 
			
		||||
			reaction,
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		// Create reaction
 | 
			
		||||
		try {
 | 
			
		||||
			await this.noteReactionsRepository.insert(record);
 | 
			
		||||
		} catch (e) {
 | 
			
		||||
			if (isDuplicateKeyValueError(e)) {
 | 
			
		||||
				const exists = await this.noteReactionsRepository.findOneByOrFail({
 | 
			
		||||
					noteId: note.id,
 | 
			
		||||
					userId: user.id,
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
				if (exists.reaction !== reaction) {
 | 
			
		||||
					// 別のリアクションがすでにされていたら置き換える
 | 
			
		||||
					await this.delete(user, note);
 | 
			
		||||
					await this.noteReactionsRepository.insert(record);
 | 
			
		||||
				} else {
 | 
			
		||||
					// 同じリアクションがすでにされていたらエラー
 | 
			
		||||
					throw new IdentifiableError('51c42bb4-931a-456b-bff7-e5a8a70dd298');
 | 
			
		||||
				}
 | 
			
		||||
				// 同じリアクションがすでにされていたらエラー
 | 
			
		||||
				throw new IdentifiableError('51c42bb4-931a-456b-bff7-e5a8a70dd298');
 | 
			
		||||
			} else {
 | 
			
		||||
				throw e;
 | 
			
		||||
			}
 | 
			
		||||
@@ -286,11 +274,12 @@ export class ReactionService {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async delete(user: { id: MiUser['id']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote) {
 | 
			
		||||
	public async delete(user: { id: MiUser['id']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, _reaction?: string | null) {
 | 
			
		||||
		// if already unreacted
 | 
			
		||||
		const exist = await this.noteReactionsRepository.findOneBy({
 | 
			
		||||
			noteId: note.id,
 | 
			
		||||
			userId: user.id,
 | 
			
		||||
			reaction: _reaction ?? FALLBACK,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if (exist == null) {
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@ export class RelayService {
 | 
			
		||||
		private createSystemUserService: CreateSystemUserService,
 | 
			
		||||
		private apRendererService: ApRendererService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.relaysCache = new MemorySingleCache<MiRelay[]>(1000 * 60 * 10); // 10m
 | 
			
		||||
		this.relaysCache = new MemorySingleCache<MiRelay[]>(1000 * 60 * 10);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,7 @@ export type RolePolicies = {
 | 
			
		||||
	alwaysMarkNsfw: boolean;
 | 
			
		||||
	canUpdateBioMedia: boolean;
 | 
			
		||||
	pinLimit: number;
 | 
			
		||||
	reactionsPerNoteLimit: number;
 | 
			
		||||
	antennaLimit: number;
 | 
			
		||||
	wordMuteLimit: number;
 | 
			
		||||
	webhookLimit: number;
 | 
			
		||||
@@ -78,6 +79,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
 | 
			
		||||
	alwaysMarkNsfw: false,
 | 
			
		||||
	canUpdateBioMedia: true,
 | 
			
		||||
	pinLimit: 5,
 | 
			
		||||
	reactionsPerNoteLimit: 1,
 | 
			
		||||
	antennaLimit: 5,
 | 
			
		||||
	wordMuteLimit: 200,
 | 
			
		||||
	webhookLimit: 3,
 | 
			
		||||
@@ -127,8 +129,10 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
 | 
			
		||||
		private moderationLogService: ModerationLogService,
 | 
			
		||||
		private fanoutTimelineService: FanoutTimelineService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.rolesCache = new MemorySingleCache<MiRole[]>(1000 * 60 * 60); // 1h
 | 
			
		||||
		this.roleAssignmentByUserIdCache = new MemoryKVCache<MiRoleAssignment[]>(1000 * 60 * 5); // 5m
 | 
			
		||||
		//this.onMessage = this.onMessage.bind(this);
 | 
			
		||||
 | 
			
		||||
		this.rolesCache = new MemorySingleCache<MiRole[]>(1000 * 60 * 60 * 1);
 | 
			
		||||
		this.roleAssignmentByUserIdCache = new MemoryKVCache<MiRoleAssignment[]>(1000 * 60 * 60 * 1);
 | 
			
		||||
 | 
			
		||||
		this.redisForSub.on('message', this.onMessage);
 | 
			
		||||
	}
 | 
			
		||||
@@ -378,6 +382,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
 | 
			
		||||
			alwaysMarkNsfw: calc('alwaysMarkNsfw', vs => vs.some(v => v === true)),
 | 
			
		||||
			canUpdateBioMedia: calc('canUpdateBioMedia', vs => vs.some(v => v === true)),
 | 
			
		||||
			pinLimit: calc('pinLimit', vs => Math.max(...vs)),
 | 
			
		||||
			reactionsPerNoteLimit: calc('reactionsPerNoteLimit', vs => Math.max(...vs)),
 | 
			
		||||
			antennaLimit: calc('antennaLimit', vs => Math.max(...vs)),
 | 
			
		||||
			wordMuteLimit: calc('wordMuteLimit', vs => Math.max(...vs)),
 | 
			
		||||
			webhookLimit: calc('webhookLimit', vs => Math.max(...vs)),
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ export class UserKeypairService implements OnApplicationShutdown {
 | 
			
		||||
	) {
 | 
			
		||||
		this.cache = new RedisKVCache<MiUserKeypair>(this.redisClient, 'userKeypair', {
 | 
			
		||||
			lifetime: 1000 * 60 * 60 * 24, // 24h
 | 
			
		||||
			memoryCacheLifetime: 1000 * 60 * 60, // 1h
 | 
			
		||||
			memoryCacheLifetime: Infinity,
 | 
			
		||||
			fetcher: (key) => this.userKeypairsRepository.findOneByOrFail({ userId: key }),
 | 
			
		||||
			toRedisConverter: (value) => JSON.stringify(value),
 | 
			
		||||
			fromRedisConverter: (value) => JSON.parse(value),
 | 
			
		||||
 
 | 
			
		||||
@@ -54,8 +54,8 @@ export class ApDbResolverService implements OnApplicationShutdown {
 | 
			
		||||
		private cacheService: CacheService,
 | 
			
		||||
		private apPersonService: ApPersonService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.publicKeyCache = new MemoryKVCache<MiUserPublickey | null>(1000 * 60 * 60 * 12); // 12h
 | 
			
		||||
		this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey | null>(1000 * 60 * 60 * 12); // 12h
 | 
			
		||||
		this.publicKeyCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
 | 
			
		||||
		this.publicKeyByUserIdCache = new MemoryKVCache<MiUserPublickey | null>(Infinity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
 
 | 
			
		||||
@@ -170,10 +170,10 @@ export class NoteEntityService implements OnModuleInit {
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async populateMyReaction(note: { id: MiNote['id']; reactions: MiNote['reactions']; reactionAndUserPairCache?: MiNote['reactionAndUserPairCache']; }, meId: MiUser['id'], _hint_?: {
 | 
			
		||||
		myReactions: Map<MiNote['id'], string | null>;
 | 
			
		||||
		myReactionsMap: Map<MiNote['id'], string | null>;
 | 
			
		||||
	}) {
 | 
			
		||||
		if (_hint_?.myReactions) {
 | 
			
		||||
			const reaction = _hint_.myReactions.get(note.id);
 | 
			
		||||
		if (_hint_?.myReactionsMap) {
 | 
			
		||||
			const reaction = _hint_.myReactionsMap.get(note.id);
 | 
			
		||||
			if (reaction) {
 | 
			
		||||
				return this.reactionService.convertLegacyReaction(reaction);
 | 
			
		||||
			} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,23 +7,23 @@ import * as Redis from 'ioredis';
 | 
			
		||||
import { bindThis } from '@/decorators.js';
 | 
			
		||||
 | 
			
		||||
export class RedisKVCache<T> {
 | 
			
		||||
	private readonly lifetime: number;
 | 
			
		||||
	private readonly memoryCache: MemoryKVCache<T>;
 | 
			
		||||
	private readonly fetcher: (key: string) => Promise<T>;
 | 
			
		||||
	private readonly toRedisConverter: (value: T) => string;
 | 
			
		||||
	private readonly fromRedisConverter: (value: string) => T | undefined;
 | 
			
		||||
	private redisClient: Redis.Redis;
 | 
			
		||||
	private name: string;
 | 
			
		||||
	private lifetime: number;
 | 
			
		||||
	private memoryCache: MemoryKVCache<T>;
 | 
			
		||||
	private fetcher: (key: string) => Promise<T>;
 | 
			
		||||
	private toRedisConverter: (value: T) => string;
 | 
			
		||||
	private fromRedisConverter: (value: string) => T | undefined;
 | 
			
		||||
 | 
			
		||||
	constructor(
 | 
			
		||||
		private redisClient: Redis.Redis,
 | 
			
		||||
		private name: string,
 | 
			
		||||
		opts: {
 | 
			
		||||
			lifetime: RedisKVCache<T>['lifetime'];
 | 
			
		||||
			memoryCacheLifetime: number;
 | 
			
		||||
			fetcher: RedisKVCache<T>['fetcher'];
 | 
			
		||||
			toRedisConverter: RedisKVCache<T>['toRedisConverter'];
 | 
			
		||||
			fromRedisConverter: RedisKVCache<T>['fromRedisConverter'];
 | 
			
		||||
		},
 | 
			
		||||
	) {
 | 
			
		||||
	constructor(redisClient: RedisKVCache<T>['redisClient'], name: RedisKVCache<T>['name'], opts: {
 | 
			
		||||
		lifetime: RedisKVCache<T>['lifetime'];
 | 
			
		||||
		memoryCacheLifetime: number;
 | 
			
		||||
		fetcher: RedisKVCache<T>['fetcher'];
 | 
			
		||||
		toRedisConverter: RedisKVCache<T>['toRedisConverter'];
 | 
			
		||||
		fromRedisConverter: RedisKVCache<T>['fromRedisConverter'];
 | 
			
		||||
	}) {
 | 
			
		||||
		this.redisClient = redisClient;
 | 
			
		||||
		this.name = name;
 | 
			
		||||
		this.lifetime = opts.lifetime;
 | 
			
		||||
		this.memoryCache = new MemoryKVCache(opts.memoryCacheLifetime);
 | 
			
		||||
		this.fetcher = opts.fetcher;
 | 
			
		||||
@@ -55,13 +55,7 @@ export class RedisKVCache<T> {
 | 
			
		||||
 | 
			
		||||
		const cached = await this.redisClient.get(`kvcache:${this.name}:${key}`);
 | 
			
		||||
		if (cached == null) return undefined;
 | 
			
		||||
 | 
			
		||||
		const value = this.fromRedisConverter(cached);
 | 
			
		||||
		if (value !== undefined) {
 | 
			
		||||
			this.memoryCache.set(key, value);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return value;
 | 
			
		||||
		return this.fromRedisConverter(cached);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
@@ -72,10 +66,6 @@ export class RedisKVCache<T> {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * キャッシュがあればそれを返し、無ければfetcherを呼び出して結果をキャッシュ&返します
 | 
			
		||||
	 * This awaits the call to Redis to ensure that the write succeeded, which is important for a few reasons:
 | 
			
		||||
	 *   * Other code uses this to synchronize changes between worker processes. A failed write can internally de-sync the cluster.
 | 
			
		||||
	 *   * Without an `await`, consecutive calls could race. An unlucky race could result in the older write overwriting the newer value.
 | 
			
		||||
	 *   * Not awaiting here makes the entire cache non-consistent. The prevents many possible uses.
 | 
			
		||||
	 */
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async fetch(key: string): Promise<T> {
 | 
			
		||||
@@ -87,14 +77,14 @@ export class RedisKVCache<T> {
 | 
			
		||||
 | 
			
		||||
		// Cache MISS
 | 
			
		||||
		const value = await this.fetcher(key);
 | 
			
		||||
		await this.set(key, value);
 | 
			
		||||
		this.set(key, value);
 | 
			
		||||
		return value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async refresh(key: string) {
 | 
			
		||||
		const value = await this.fetcher(key);
 | 
			
		||||
		await this.set(key, value);
 | 
			
		||||
		this.set(key, value);
 | 
			
		||||
 | 
			
		||||
		// TODO: イベント発行して他プロセスのメモリキャッシュも更新できるようにする
 | 
			
		||||
	}
 | 
			
		||||
@@ -111,23 +101,23 @@ export class RedisKVCache<T> {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class RedisSingleCache<T> {
 | 
			
		||||
	private readonly lifetime: number;
 | 
			
		||||
	private readonly memoryCache: MemorySingleCache<T>;
 | 
			
		||||
	private readonly fetcher: () => Promise<T>;
 | 
			
		||||
	private readonly toRedisConverter: (value: T) => string;
 | 
			
		||||
	private readonly fromRedisConverter: (value: string) => T | undefined;
 | 
			
		||||
	private redisClient: Redis.Redis;
 | 
			
		||||
	private name: string;
 | 
			
		||||
	private lifetime: number;
 | 
			
		||||
	private memoryCache: MemorySingleCache<T>;
 | 
			
		||||
	private fetcher: () => Promise<T>;
 | 
			
		||||
	private toRedisConverter: (value: T) => string;
 | 
			
		||||
	private fromRedisConverter: (value: string) => T | undefined;
 | 
			
		||||
 | 
			
		||||
	constructor(
 | 
			
		||||
		private redisClient: Redis.Redis,
 | 
			
		||||
		private name: string,
 | 
			
		||||
		opts: {
 | 
			
		||||
			lifetime: number;
 | 
			
		||||
			memoryCacheLifetime: number;
 | 
			
		||||
			fetcher: RedisSingleCache<T>['fetcher'];
 | 
			
		||||
			toRedisConverter: RedisSingleCache<T>['toRedisConverter'];
 | 
			
		||||
			fromRedisConverter: RedisSingleCache<T>['fromRedisConverter'];
 | 
			
		||||
		},
 | 
			
		||||
	) {
 | 
			
		||||
	constructor(redisClient: RedisSingleCache<T>['redisClient'], name: RedisSingleCache<T>['name'], opts: {
 | 
			
		||||
		lifetime: RedisSingleCache<T>['lifetime'];
 | 
			
		||||
		memoryCacheLifetime: number;
 | 
			
		||||
		fetcher: RedisSingleCache<T>['fetcher'];
 | 
			
		||||
		toRedisConverter: RedisSingleCache<T>['toRedisConverter'];
 | 
			
		||||
		fromRedisConverter: RedisSingleCache<T>['fromRedisConverter'];
 | 
			
		||||
	}) {
 | 
			
		||||
		this.redisClient = redisClient;
 | 
			
		||||
		this.name = name;
 | 
			
		||||
		this.lifetime = opts.lifetime;
 | 
			
		||||
		this.memoryCache = new MemorySingleCache(opts.memoryCacheLifetime);
 | 
			
		||||
		this.fetcher = opts.fetcher;
 | 
			
		||||
@@ -159,13 +149,7 @@ export class RedisSingleCache<T> {
 | 
			
		||||
 | 
			
		||||
		const cached = await this.redisClient.get(`singlecache:${this.name}`);
 | 
			
		||||
		if (cached == null) return undefined;
 | 
			
		||||
 | 
			
		||||
		const value = this.fromRedisConverter(cached);
 | 
			
		||||
		if (value !== undefined) {
 | 
			
		||||
			this.memoryCache.set(value);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return value;
 | 
			
		||||
		return this.fromRedisConverter(cached);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
@@ -176,10 +160,6 @@ export class RedisSingleCache<T> {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * キャッシュがあればそれを返し、無ければfetcherを呼び出して結果をキャッシュ&返します
 | 
			
		||||
	 * This awaits the call to Redis to ensure that the write succeeded, which is important for a few reasons:
 | 
			
		||||
	 *   * Other code uses this to synchronize changes between worker processes. A failed write can internally de-sync the cluster.
 | 
			
		||||
	 *   * Without an `await`, consecutive calls could race. An unlucky race could result in the older write overwriting the newer value.
 | 
			
		||||
	 *   * Not awaiting here makes the entire cache non-consistent. The prevents many possible uses.
 | 
			
		||||
	 */
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async fetch(): Promise<T> {
 | 
			
		||||
@@ -191,14 +171,14 @@ export class RedisSingleCache<T> {
 | 
			
		||||
 | 
			
		||||
		// Cache MISS
 | 
			
		||||
		const value = await this.fetcher();
 | 
			
		||||
		await this.set(value);
 | 
			
		||||
		this.set(value);
 | 
			
		||||
		return value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public async refresh() {
 | 
			
		||||
		const value = await this.fetcher();
 | 
			
		||||
		await this.set(value);
 | 
			
		||||
		this.set(value);
 | 
			
		||||
 | 
			
		||||
		// TODO: イベント発行して他プロセスのメモリキャッシュも更新できるようにする
 | 
			
		||||
	}
 | 
			
		||||
@@ -207,12 +187,22 @@ export class RedisSingleCache<T> {
 | 
			
		||||
// TODO: メモリ節約のためあまり参照されないキーを定期的に削除できるようにする?
 | 
			
		||||
 | 
			
		||||
export class MemoryKVCache<T> {
 | 
			
		||||
	private readonly cache = new Map<string, { date: number; value: T; }>();
 | 
			
		||||
	private readonly gcIntervalHandle = setInterval(() => this.gc(), 1000 * 60 * 3); // 3m
 | 
			
		||||
	/**
 | 
			
		||||
	 * データを持つマップ
 | 
			
		||||
	 * @deprecated これを直接操作するべきではない
 | 
			
		||||
	 */
 | 
			
		||||
	public cache: Map<string, { date: number; value: T; }>;
 | 
			
		||||
	private lifetime: number;
 | 
			
		||||
	private gcIntervalHandle: NodeJS.Timeout;
 | 
			
		||||
 | 
			
		||||
	constructor(
 | 
			
		||||
		private readonly lifetime: number,
 | 
			
		||||
	) {}
 | 
			
		||||
	constructor(lifetime: MemoryKVCache<never>['lifetime']) {
 | 
			
		||||
		this.cache = new Map();
 | 
			
		||||
		this.lifetime = lifetime;
 | 
			
		||||
 | 
			
		||||
		this.gcIntervalHandle = setInterval(() => {
 | 
			
		||||
			this.gc();
 | 
			
		||||
		}, 1000 * 60 * 3);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	/**
 | 
			
		||||
@@ -297,14 +287,10 @@ export class MemoryKVCache<T> {
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public gc(): void {
 | 
			
		||||
		const now = Date.now();
 | 
			
		||||
 | 
			
		||||
		for (const [key, { date }] of this.cache.entries()) {
 | 
			
		||||
			// 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);
 | 
			
		||||
			if ((now - date) > this.lifetime) {
 | 
			
		||||
				this.cache.delete(key);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -312,19 +298,16 @@ export class MemoryKVCache<T> {
 | 
			
		||||
	public dispose(): void {
 | 
			
		||||
		clearInterval(this.gcIntervalHandle);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public get entries() {
 | 
			
		||||
		return this.cache.entries();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class MemorySingleCache<T> {
 | 
			
		||||
	private cachedAt: number | null = null;
 | 
			
		||||
	private value: T | undefined;
 | 
			
		||||
	private lifetime: number;
 | 
			
		||||
 | 
			
		||||
	constructor(
 | 
			
		||||
		private lifetime: number,
 | 
			
		||||
	) {}
 | 
			
		||||
	constructor(lifetime: MemorySingleCache<never>['lifetime']) {
 | 
			
		||||
		this.lifetime = lifetime;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
	public set(value: T): void {
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,8 @@ import { MiUser } from './User.js';
 | 
			
		||||
import { MiNote } from './Note.js';
 | 
			
		||||
 | 
			
		||||
@Entity('note_reaction')
 | 
			
		||||
@Index(['userId', 'noteId'], { unique: true })
 | 
			
		||||
@Index(['userId', 'noteId'])
 | 
			
		||||
@Index(['userId', 'noteId', 'reaction'], { unique: true })
 | 
			
		||||
export class MiNoteReaction {
 | 
			
		||||
	@PrimaryColumn(id())
 | 
			
		||||
	public id: string;
 | 
			
		||||
 
 | 
			
		||||
@@ -236,6 +236,10 @@ export const packedRolePoliciesSchema = {
 | 
			
		||||
			type: 'integer',
 | 
			
		||||
			optional: false, nullable: false,
 | 
			
		||||
		},
 | 
			
		||||
		reactionsPerNoteLimit: {
 | 
			
		||||
			type: 'integer',
 | 
			
		||||
			optional: false, nullable: false,
 | 
			
		||||
		},
 | 
			
		||||
		antennaLimit: {
 | 
			
		||||
			type: 'integer',
 | 
			
		||||
			optional: false, nullable: false,
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@ export class DeliverProcessorService {
 | 
			
		||||
		private queueLoggerService: QueueLoggerService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.logger = this.queueLoggerService.logger.createSubLogger('deliver');
 | 
			
		||||
		this.suspendedHostsCache = new MemorySingleCache<MiInstance[]>(1000 * 60 * 60); // 1h
 | 
			
		||||
		this.suspendedHostsCache = new MemorySingleCache<MiInstance[]>(1000 * 60 * 60);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
 
 | 
			
		||||
@@ -134,7 +134,7 @@ export class NodeinfoServerService {
 | 
			
		||||
			return document;
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		const cache = new MemorySingleCache<Awaited<ReturnType<typeof nodeinfo2>>>(1000 * 60 * 10); // 10m
 | 
			
		||||
		const cache = new MemorySingleCache<Awaited<ReturnType<typeof nodeinfo2>>>(1000 * 60 * 10);
 | 
			
		||||
 | 
			
		||||
		fastify.get(nodeinfo2_1path, async (request, reply) => {
 | 
			
		||||
			const base = await cache.fetch(() => nodeinfo2(21));
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ export class AuthenticateService implements OnApplicationShutdown {
 | 
			
		||||
 | 
			
		||||
		private cacheService: CacheService,
 | 
			
		||||
	) {
 | 
			
		||||
		this.appCache = new MemoryKVCache<MiApp>(1000 * 60 * 60 * 24 * 7); // 1w
 | 
			
		||||
		this.appCache = new MemoryKVCache<MiApp>(Infinity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@bindThis
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,6 @@ export const paramDef = {
 | 
			
		||||
		limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
 | 
			
		||||
		untilId: { type: 'string', format: 'misskey:id' },
 | 
			
		||||
		channelId: { type: 'string', nullable: true, format: 'misskey:id' },
 | 
			
		||||
		withSensitive: { type: 'boolean', default: true },
 | 
			
		||||
	},
 | 
			
		||||
	required: [],
 | 
			
		||||
} as const;
 | 
			
		||||
@@ -104,13 +103,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 | 
			
		||||
 | 
			
		||||
			notes.sort((a, b) => a.id > b.id ? -1 : 1);
 | 
			
		||||
 | 
			
		||||
			let packed = await this.noteEntityService.packMany(notes, me);
 | 
			
		||||
 | 
			
		||||
			if (!ps.withSensitive) {
 | 
			
		||||
				packed = packed.filter(note => note.files?.length === 0 || note.files?.every(file => !file.isSensitive));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return packed;
 | 
			
		||||
			return await this.noteEntityService.packMany(notes, me);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,7 @@ export const ROLE_POLICIES = [
 | 
			
		||||
	'alwaysMarkNsfw',
 | 
			
		||||
	'canUpdateBioMedia',
 | 
			
		||||
	'pinLimit',
 | 
			
		||||
	'reactionsPerNoteLimit',
 | 
			
		||||
	'antennaLimit',
 | 
			
		||||
	'wordMuteLimit',
 | 
			
		||||
	'webhookLimit',
 | 
			
		||||
 
 | 
			
		||||
@@ -417,6 +417,25 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
				</div>
 | 
			
		||||
			</MkFolder>
 | 
			
		||||
 | 
			
		||||
			<MkFolder v-if="matchQuery([i18n.ts._role._options.reactionsPerNoteLimit, 'reactionsPerNoteLimit'])">
 | 
			
		||||
				<template #label>{{ i18n.ts._role._options.reactionsPerNoteLimit }}</template>
 | 
			
		||||
				<template #suffix>
 | 
			
		||||
					<span v-if="role.policies.reactionsPerNoteLimit.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
 | 
			
		||||
					<span v-else>{{ role.policies.reactionsPerNoteLimit.value }}</span>
 | 
			
		||||
					<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.reactionsPerNoteLimit)"></i></span>
 | 
			
		||||
				</template>
 | 
			
		||||
				<div class="_gaps">
 | 
			
		||||
					<MkSwitch v-model="role.policies.reactionsPerNoteLimit.useDefault" :readonly="readonly">
 | 
			
		||||
						<template #label>{{ i18n.ts._role.useBaseValue }}</template>
 | 
			
		||||
					</MkSwitch>
 | 
			
		||||
					<MkInput v-model="role.policies.reactionsPerNoteLimit.value" :disabled="role.policies.reactionsPerNoteLimit.useDefault" type="number" :readonly="readonly">
 | 
			
		||||
					</MkInput>
 | 
			
		||||
					<MkRange v-model="role.policies.reactionsPerNoteLimit.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
 | 
			
		||||
						<template #label>{{ i18n.ts._role.priority }}</template>
 | 
			
		||||
					</MkRange>
 | 
			
		||||
				</div>
 | 
			
		||||
			</MkFolder>
 | 
			
		||||
 | 
			
		||||
			<MkFolder v-if="matchQuery([i18n.ts._role._options.antennaMax, 'antennaLimit'])">
 | 
			
		||||
				<template #label>{{ i18n.ts._role._options.antennaMax }}</template>
 | 
			
		||||
				<template #suffix>
 | 
			
		||||
 
 | 
			
		||||
@@ -149,6 +149,13 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
							</MkInput>
 | 
			
		||||
						</MkFolder>
 | 
			
		||||
 | 
			
		||||
						<MkFolder v-if="matchQuery([i18n.ts._role._options.reactionsPerNoteLimit, 'reactionsPerNoteLimit'])">
 | 
			
		||||
							<template #label>{{ i18n.ts._role._options.reactionsPerNoteLimit }}</template>
 | 
			
		||||
							<template #suffix>{{ policies.reactionsPerNoteLimit }}</template>
 | 
			
		||||
							<MkInput v-model="policies.reactionsPerNoteLimit" type="number">
 | 
			
		||||
							</MkInput>
 | 
			
		||||
						</MkFolder>
 | 
			
		||||
 | 
			
		||||
						<MkFolder v-if="matchQuery([i18n.ts._role._options.antennaMax, 'antennaLimit'])">
 | 
			
		||||
							<template #label>{{ i18n.ts._role._options.antennaMax }}</template>
 | 
			
		||||
							<template #suffix>{{ policies.antennaLimit }}</template>
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,9 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
<MkSpacer :contentMax="800">
 | 
			
		||||
	<MkTab v-model="tab" style="margin-bottom: var(--margin);">
 | 
			
		||||
		<option value="notes">{{ i18n.ts.notes }}</option>
 | 
			
		||||
		<option value="notesWithSensitive">{{ i18n.ts.notes }} (+{{ i18n.ts.sensitive }})</option>
 | 
			
		||||
		<option value="polls">{{ i18n.ts.poll }}</option>
 | 
			
		||||
	</MkTab>
 | 
			
		||||
	<MkNotes v-if="tab === 'notes'" :pagination="paginationForNotes"/>
 | 
			
		||||
	<MkNotes v-else-if="tab === 'notesWithSensitive'" :pagination="paginationForNotesWithSensitive"/>
 | 
			
		||||
	<MkNotes v-else-if="tab === 'polls'" :pagination="paginationForPolls"/>
 | 
			
		||||
</MkSpacer>
 | 
			
		||||
</template>
 | 
			
		||||
@@ -25,17 +23,6 @@ import { i18n } from '@/i18n.js';
 | 
			
		||||
const paginationForNotes = {
 | 
			
		||||
	endpoint: 'notes/featured' as const,
 | 
			
		||||
	limit: 10,
 | 
			
		||||
	params: {
 | 
			
		||||
		withSensitive: false,
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const paginationForNotesWithSensitive = {
 | 
			
		||||
	endpoint: 'notes/featured' as const,
 | 
			
		||||
	limit: 10,
 | 
			
		||||
	params: {
 | 
			
		||||
		withSensitive: true,
 | 
			
		||||
	},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const paginationForPolls = {
 | 
			
		||||
 
 | 
			
		||||
@@ -16,57 +16,21 @@ function containsFocusTrappedElements(el: HTMLElement): boolean {
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getZIndex(el: HTMLElement): number {
 | 
			
		||||
	const zIndex = parseInt(window.getComputedStyle(el).zIndex || '0', 10);
 | 
			
		||||
	if (isNaN(zIndex)) {
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	return zIndex;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getHighestZIndexElement(): { el: HTMLElement; zIndex: number; } | null {
 | 
			
		||||
	let highestZIndexElement: HTMLElement | null = null;
 | 
			
		||||
	let highestZIndex = -Infinity;
 | 
			
		||||
 | 
			
		||||
	focusTrapElements.forEach((el) => {
 | 
			
		||||
		const zIndex = getZIndex(el);
 | 
			
		||||
		if (zIndex > highestZIndex) {
 | 
			
		||||
			highestZIndex = zIndex;
 | 
			
		||||
			highestZIndexElement = el;
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return highestZIndexElement == null ? null : {
 | 
			
		||||
		el: highestZIndexElement,
 | 
			
		||||
		zIndex: highestZIndex,
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function releaseFocusTrap(el: HTMLElement): void {
 | 
			
		||||
	focusTrapElements.delete(el);
 | 
			
		||||
	if (el.inert === true) {
 | 
			
		||||
		el.inert = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const highestZIndexElement = getHighestZIndexElement();
 | 
			
		||||
 | 
			
		||||
	if (el.parentElement != null && el !== document.body) {
 | 
			
		||||
		el.parentElement.childNodes.forEach((siblingNode) => {
 | 
			
		||||
			const siblingEl = getHTMLElementOrNull(siblingNode);
 | 
			
		||||
			if (!siblingEl) return;
 | 
			
		||||
			if (
 | 
			
		||||
				siblingEl !== el &&
 | 
			
		||||
				(
 | 
			
		||||
					highestZIndexElement == null ||
 | 
			
		||||
					siblingEl === highestZIndexElement.el ||
 | 
			
		||||
					siblingEl.contains(highestZIndexElement.el)
 | 
			
		||||
				)
 | 
			
		||||
			) {
 | 
			
		||||
			if (siblingEl !== el && (focusTrapElements.has(siblingEl) || containsFocusTrappedElements(siblingEl) || focusTrapElements.size === 0)) {
 | 
			
		||||
				siblingEl.inert = false;
 | 
			
		||||
			} else if (
 | 
			
		||||
				highestZIndexElement != null &&
 | 
			
		||||
				siblingEl !== highestZIndexElement.el &&
 | 
			
		||||
				!siblingEl.contains(highestZIndexElement.el) &&
 | 
			
		||||
				focusTrapElements.size > 0 &&
 | 
			
		||||
				!containsFocusTrappedElements(siblingEl) &&
 | 
			
		||||
				!focusTrapElements.has(siblingEl) &&
 | 
			
		||||
				!ignoreElements.includes(siblingEl.tagName.toLowerCase())
 | 
			
		||||
			) {
 | 
			
		||||
				siblingEl.inert = true;
 | 
			
		||||
@@ -81,29 +45,9 @@ function releaseFocusTrap(el: HTMLElement): void {
 | 
			
		||||
export function focusTrap(el: HTMLElement, hasInteractionWithOtherFocusTrappedEls: boolean, parent: true): void;
 | 
			
		||||
export function focusTrap(el: HTMLElement, hasInteractionWithOtherFocusTrappedEls?: boolean, parent?: false): { release: () => void; };
 | 
			
		||||
export function focusTrap(el: HTMLElement, hasInteractionWithOtherFocusTrappedEls = false, parent = false): { release: () => void; } | void {
 | 
			
		||||
	const highestZIndexElement = getHighestZIndexElement();
 | 
			
		||||
 | 
			
		||||
	const highestZIndex = highestZIndexElement == null ? -Infinity : highestZIndexElement.zIndex;
 | 
			
		||||
	const zIndex = getZIndex(el);
 | 
			
		||||
 | 
			
		||||
	// If the element has a lower z-index than the highest z-index element, focus trap the highest z-index element instead
 | 
			
		||||
	// Focus trapping for this element will be done in the release function
 | 
			
		||||
	if (!parent && zIndex < highestZIndex) {
 | 
			
		||||
		focusTrapElements.add(el);
 | 
			
		||||
		if (highestZIndexElement) {
 | 
			
		||||
			focusTrap(highestZIndexElement.el, hasInteractionWithOtherFocusTrappedEls);
 | 
			
		||||
		}
 | 
			
		||||
		return {
 | 
			
		||||
			release: () => {
 | 
			
		||||
				releaseFocusTrap(el);
 | 
			
		||||
			},
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (el.inert === true) {
 | 
			
		||||
		el.inert = false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (el.parentElement != null && el !== document.body) {
 | 
			
		||||
		el.parentElement.childNodes.forEach((siblingNode) => {
 | 
			
		||||
			const siblingEl = getHTMLElementOrNull(siblingNode);
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,7 @@
 | 
			
		||||
		X11: 'rgba(0, 0, 0, 0.3)',
 | 
			
		||||
		X12: 'rgba(255, 255, 255, 0.1)',
 | 
			
		||||
		X13: 'rgba(255, 255, 255, 0.15)',
 | 
			
		||||
		X14: ':alpha<0.5<@navBg',
 | 
			
		||||
		X15: ':alpha<0<@panel',
 | 
			
		||||
		X16: ':alpha<0.7<@panel',
 | 
			
		||||
		X17: ':alpha<0.8<@bg',
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,7 @@
 | 
			
		||||
		X11: 'rgba(0, 0, 0, 0.1)',
 | 
			
		||||
		X12: 'rgba(0, 0, 0, 0.1)',
 | 
			
		||||
		X13: 'rgba(0, 0, 0, 0.15)',
 | 
			
		||||
		X14: ':alpha<0.5<@navBg',
 | 
			
		||||
		X15: ':alpha<0<@panel',
 | 
			
		||||
		X16: ':alpha<0.7<@panel',
 | 
			
		||||
		X17: ':alpha<0.8<@bg',
 | 
			
		||||
 
 | 
			
		||||
@@ -82,8 +82,6 @@ function more() {
 | 
			
		||||
 | 
			
		||||
<style lang="scss" module>
 | 
			
		||||
.root {
 | 
			
		||||
	--nav-bg-transparent: color-mix(in srgb, var(--navBg), transparent 50%);
 | 
			
		||||
 | 
			
		||||
	display: flex;
 | 
			
		||||
	flex-direction: column;
 | 
			
		||||
}
 | 
			
		||||
@@ -93,7 +91,7 @@ function more() {
 | 
			
		||||
	top: 0;
 | 
			
		||||
	z-index: 1;
 | 
			
		||||
	padding: 20px 0;
 | 
			
		||||
	background: var(--nav-bg-transparent);
 | 
			
		||||
	background: var(--X14);
 | 
			
		||||
	-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
}
 | 
			
		||||
@@ -127,7 +125,7 @@ function more() {
 | 
			
		||||
	position: sticky;
 | 
			
		||||
	bottom: 0;
 | 
			
		||||
	padding: 20px 0;
 | 
			
		||||
	background: var(--nav-bg-transparent);
 | 
			
		||||
	background: var(--X14);
 | 
			
		||||
	-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,6 @@ function more(ev: MouseEvent) {
 | 
			
		||||
.root {
 | 
			
		||||
	--nav-width: 250px;
 | 
			
		||||
	--nav-icon-only-width: 80px;
 | 
			
		||||
	--nav-bg-transparent: color-mix(in srgb, var(--navBg), transparent 50%);
 | 
			
		||||
 | 
			
		||||
	flex: 0 0 var(--nav-width);
 | 
			
		||||
	width: var(--nav-width);
 | 
			
		||||
@@ -145,7 +144,7 @@ function more(ev: MouseEvent) {
 | 
			
		||||
		top: 0;
 | 
			
		||||
		z-index: 1;
 | 
			
		||||
		padding: 20px 0;
 | 
			
		||||
		background: var(--nav-bg-transparent);
 | 
			
		||||
		background: var(--X14);
 | 
			
		||||
		-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
		backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	}
 | 
			
		||||
@@ -188,7 +187,7 @@ function more(ev: MouseEvent) {
 | 
			
		||||
		position: sticky;
 | 
			
		||||
		bottom: 0;
 | 
			
		||||
		padding-top: 20px;
 | 
			
		||||
		background: var(--nav-bg-transparent);
 | 
			
		||||
		background: var(--X14);
 | 
			
		||||
		-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
		backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	}
 | 
			
		||||
@@ -379,7 +378,7 @@ function more(ev: MouseEvent) {
 | 
			
		||||
		top: 0;
 | 
			
		||||
		z-index: 1;
 | 
			
		||||
		padding: 20px 0;
 | 
			
		||||
		background: var(--nav-bg-transparent);
 | 
			
		||||
		background: var(--X14);
 | 
			
		||||
		-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
		backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	}
 | 
			
		||||
@@ -409,7 +408,7 @@ function more(ev: MouseEvent) {
 | 
			
		||||
		position: sticky;
 | 
			
		||||
		bottom: 0;
 | 
			
		||||
		padding-top: 20px;
 | 
			
		||||
		background: var(--nav-bg-transparent);
 | 
			
		||||
		background: var(--X14);
 | 
			
		||||
		-webkit-backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
		backdrop-filter: var(--blur, blur(8px));
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
	"type": "module",
 | 
			
		||||
	"name": "misskey-js",
 | 
			
		||||
	"version": "2024.8.0",
 | 
			
		||||
	"version": "2024.8.0-rc.3",
 | 
			
		||||
	"description": "Misskey SDK for JavaScript",
 | 
			
		||||
	"license": "MIT",
 | 
			
		||||
	"main": "./built/index.js",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user