Merge branch 'develop' into sw-file

This commit is contained in:
tamaina 2025-07-31 18:45:24 +09:00 committed by GitHub
commit ba6effb57d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
60 changed files with 2430 additions and 1727 deletions

View File

@ -109,6 +109,7 @@ jobs:
name: E2E tests (backend) name: E2E tests (backend)
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false
matrix: matrix:
node-version-file: node-version-file:
- .node-version - .node-version

View File

@ -1,13 +1,16 @@
## Unreleased ## Unreleased
### General ### General
- - ノートを削除した際、関連するノートが同時に削除されないようになりました
- APIで、「replyIdが存在しているのにreplyがnull」や「renoteIdが存在しているのにrenoteがnull」であるという、今までにはなかったパターンが表れることになります
### Client ### Client
- - Fix: 一部の設定検索結果が存在しないパスになる問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1171)
### Server ### Server
- - Enhance: ノートの削除処理の効率化
- Enhance: 全体的なパフォーマンスの向上
## 2025.7.0 ## 2025.7.0

4
locales/index.d.ts vendored
View File

@ -2567,11 +2567,11 @@ export interface Locale extends ILocale {
*/ */
"serviceworkerInfo": string; "serviceworkerInfo": string;
/** /**
* 稿 *
*/ */
"deletedNote": string; "deletedNote": string;
/** /**
* 稿 *
*/ */
"invisibleNote": string; "invisibleNote": string;
/** /**

View File

@ -637,8 +637,8 @@ addRelay: "リレーの追加"
inboxUrl: "inboxのURL" inboxUrl: "inboxのURL"
addedRelays: "追加済みのリレー" addedRelays: "追加済みのリレー"
serviceworkerInfo: "プッシュ通知を行うには有効にする必要があります。" serviceworkerInfo: "プッシュ通知を行うには有効にする必要があります。"
deletedNote: "削除された投稿" deletedNote: "削除されたノート"
invisibleNote: "非公開の投稿" invisibleNote: "非公開のノート"
enableInfiniteScroll: "自動でもっと見る" enableInfiniteScroll: "自動でもっと見る"
visibility: "公開範囲" visibility: "公開範囲"
poll: "アンケート" poll: "アンケート"

View File

@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class RemoveNoteConstraints1753868431598 {
name = 'RemoveNoteConstraints1753868431598'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "note" DROP CONSTRAINT "FK_52ccc804d7c69037d558bac4c96"`);
await queryRunner.query(`ALTER TABLE "note" DROP CONSTRAINT "FK_17cb3553c700a4985dff5a30ff5"`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "note" ADD CONSTRAINT "FK_17cb3553c700a4985dff5a30ff5" FOREIGN KEY ("replyId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "note" ADD CONSTRAINT "FK_52ccc804d7c69037d558bac4c96" FOREIGN KEY ("renoteId") REFERENCES "note"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}
}

View File

@ -20,6 +20,8 @@ import { CacheService } from '@/core/CacheService.js';
import { isReply } from '@/misc/is-reply.js'; import { isReply } from '@/misc/is-reply.js';
import { isInstanceMuted } from '@/misc/is-instance-muted.js'; import { isInstanceMuted } from '@/misc/is-instance-muted.js';
type NoteFilter = (note: MiNote) => boolean;
type TimelineOptions = { type TimelineOptions = {
untilId: string | null, untilId: string | null,
sinceId: string | null, sinceId: string | null,
@ -28,7 +30,7 @@ type TimelineOptions = {
me?: { id: MiUser['id'] } | undefined | null, me?: { id: MiUser['id'] } | undefined | null,
useDbFallback: boolean, useDbFallback: boolean,
redisTimelines: FanoutTimelineName[], redisTimelines: FanoutTimelineName[],
noteFilter?: (note: MiNote) => boolean, noteFilter?: NoteFilter,
alwaysIncludeMyNotes?: boolean; alwaysIncludeMyNotes?: boolean;
ignoreAuthorFromBlock?: boolean; ignoreAuthorFromBlock?: boolean;
ignoreAuthorFromMute?: boolean; ignoreAuthorFromMute?: boolean;
@ -79,7 +81,7 @@ export class FanoutTimelineEndpointService {
const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId; const shouldFallbackToDb = noteIds.length === 0 || ps.sinceId != null && ps.sinceId < oldestNoteId;
if (!shouldFallbackToDb) { if (!shouldFallbackToDb) {
let filter = ps.noteFilter ?? (_note => true); let filter = ps.noteFilter ?? (_note => true) as NoteFilter;
if (ps.alwaysIncludeMyNotes && ps.me) { if (ps.alwaysIncludeMyNotes && ps.me) {
const me = ps.me; const me = ps.me;
@ -145,15 +147,11 @@ export class FanoutTimelineEndpointService {
{ {
const parentFilter = filter; const parentFilter = filter;
filter = (note) => { filter = (note) => {
const noteJoined = note as MiNote & {
renoteUser: MiUser | null;
replyUser: MiUser | null;
};
if (!ps.ignoreAuthorFromUserSuspension) { if (!ps.ignoreAuthorFromUserSuspension) {
if (note.user!.isSuspended) return false; if (note.user!.isSuspended) return false;
} }
if (note.userId !== note.renoteUserId && noteJoined.renoteUser?.isSuspended) return false; if (note.userId !== note.renoteUserId && note.renote?.user?.isSuspended) return false;
if (note.userId !== note.replyUserId && noteJoined.replyUser?.isSuspended) return false; if (note.userId !== note.replyUserId && note.reply?.user?.isSuspended) return false;
return parentFilter(note); return parentFilter(note);
}; };
@ -200,7 +198,7 @@ export class FanoutTimelineEndpointService {
return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit); return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
} }
private async getAndFilterFromDb(noteIds: string[], noteFilter: (note: MiNote) => boolean, idCompare: (a: string, b: string) => number): Promise<MiNote[]> { private async getAndFilterFromDb(noteIds: string[], noteFilter: NoteFilter, idCompare: (a: string, b: string) => number): Promise<MiNote[]> {
const query = this.notesRepository.createQueryBuilder('note') const query = this.notesRepository.createQueryBuilder('note')
.where('note.id IN (:...noteIds)', { noteIds: noteIds }) .where('note.id IN (:...noteIds)', { noteIds: noteIds })
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')

View File

@ -421,7 +421,7 @@ export class NoteCreateService implements OnApplicationShutdown {
emojis, emojis,
userId: user.id, userId: user.id,
localOnly: data.localOnly!, localOnly: data.localOnly!,
reactionAcceptance: data.reactionAcceptance, reactionAcceptance: data.reactionAcceptance ?? null,
visibility: data.visibility as any, visibility: data.visibility as any,
visibleUserIds: data.visibility === 'specified' visibleUserIds: data.visibility === 'specified'
? data.visibleUsers ? data.visibleUsers
@ -483,7 +483,11 @@ export class NoteCreateService implements OnApplicationShutdown {
await this.notesRepository.insert(insert); await this.notesRepository.insert(insert);
} }
return insert; return {
...insert,
reply: data.reply ?? null,
renote: data.renote ?? null,
};
} catch (e) { } catch (e) {
// duplicate key error // duplicate key error
if (isDuplicateKeyValueError(e)) { if (isDuplicateKeyValueError(e)) {

View File

@ -62,7 +62,6 @@ export class NoteDeleteService {
*/ */
async delete(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, quiet = false, deleter?: MiUser) { async delete(user: { id: MiUser['id']; uri: MiUser['uri']; host: MiUser['host']; isBot: MiUser['isBot']; }, note: MiNote, quiet = false, deleter?: MiUser) {
const deletedAt = new Date(); const deletedAt = new Date();
const cascadingNotes = await this.findCascadingNotes(note);
if (note.replyId) { if (note.replyId) {
await this.notesRepository.decrement({ id: note.replyId }, 'repliesCount', 1); await this.notesRepository.decrement({ id: note.replyId }, 'repliesCount', 1);
@ -90,15 +89,6 @@ export class NoteDeleteService {
this.deliverToConcerned(user, note, content); this.deliverToConcerned(user, note, content);
} }
// also deliver delete activity to cascaded notes
const federatedLocalCascadingNotes = (cascadingNotes).filter(note => !note.localOnly && note.userHost == null); // filter out local-only notes
for (const cascadingNote of federatedLocalCascadingNotes) {
if (!cascadingNote.user) continue;
if (!this.userEntityService.isLocalUser(cascadingNote.user)) continue;
const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
this.deliverToConcerned(cascadingNote.user, cascadingNote, content);
}
//#endregion //#endregion
this.notesChart.update(note, false); this.notesChart.update(note, false);
@ -118,9 +108,6 @@ export class NoteDeleteService {
} }
} }
for (const cascadingNote of cascadingNotes) {
this.searchService.unindexNote(cascadingNote);
}
this.searchService.unindexNote(note); this.searchService.unindexNote(note);
await this.notesRepository.delete({ await this.notesRepository.delete({
@ -140,29 +127,6 @@ export class NoteDeleteService {
} }
} }
@bindThis
private async findCascadingNotes(note: MiNote): Promise<MiNote[]> {
const recursive = async (noteId: string): Promise<MiNote[]> => {
const query = this.notesRepository.createQueryBuilder('note')
.where('note.replyId = :noteId', { noteId })
.orWhere(new Brackets(q => {
q.where('note.renoteId = :noteId', { noteId })
.andWhere('note.text IS NOT NULL');
}))
.leftJoinAndSelect('note.user', 'user');
const replies = await query.getMany();
return [
replies,
...await Promise.all(replies.map(reply => recursive(reply.id))),
].flat();
};
const cascadingNotes: MiNote[] = await recursive(note.id);
return cascadingNotes;
}
@bindThis @bindThis
private async getMentionedRemoteUsers(note: MiNote) { private async getMentionedRemoteUsers(note: MiNote) {
const where = [] as any[]; const where = [] as any[];

View File

@ -360,7 +360,7 @@ export class QueryService {
public generateSuspendedUserQueryForNote(q: SelectQueryBuilder<any>, excludeAuthor?: boolean): void { public generateSuspendedUserQueryForNote(q: SelectQueryBuilder<any>, excludeAuthor?: boolean): void {
if (excludeAuthor) { if (excludeAuthor) {
const brakets = (user: string) => new Brackets(qb => qb const brakets = (user: string) => new Brackets(qb => qb
.where(`note.${user}Id IS NULL`) .where(`${user}.id IS NULL`) // そもそもreplyやrenoteではない、もしくはleftjoinなどでuserが存在しなかった場合を考慮
.orWhere(`user.id = ${user}.id`) .orWhere(`user.id = ${user}.id`)
.orWhere(`${user}.isSuspended = FALSE`)); .orWhere(`${user}.isSuspended = FALSE`));
q q
@ -368,7 +368,7 @@ export class QueryService {
.andWhere(brakets('renoteUser')); .andWhere(brakets('renoteUser'));
} else { } else {
const brakets = (user: string) => new Brackets(qb => qb const brakets = (user: string) => new Brackets(qb => qb
.where(`note.${user}Id IS NULL`) .where(`${user}.id IS NULL`) // そもそもreplyやrenoteではない、もしくはleftjoinなどでuserが存在しなかった場合を考慮
.orWhere(`${user}.isSuspended = FALSE`)); .orWhere(`${user}.isSuspended = FALSE`));
q q
.andWhere('user.isSuspended = FALSE') .andWhere('user.isSuspended = FALSE')

View File

@ -17,6 +17,7 @@ import { bindThis } from '@/decorators.js';
import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js'; import type { Antenna } from '@/server/api/endpoints/i/import-antennas.js';
import { ApRequestCreator } from '@/core/activitypub/ApRequestService.js'; import { ApRequestCreator } from '@/core/activitypub/ApRequestService.js';
import { type SystemWebhookPayload } from '@/core/SystemWebhookService.js'; import { type SystemWebhookPayload } from '@/core/SystemWebhookService.js';
import type { Packed } from '@/misc/json-schema.js';
import { type UserWebhookPayload } from './UserWebhookService.js'; import { type UserWebhookPayload } from './UserWebhookService.js';
import type { import type {
DbJobData, DbJobData,
@ -39,7 +40,6 @@ import type {
} from './QueueModule.js'; } from './QueueModule.js';
import type httpSignature from '@peertube/http-signature'; import type httpSignature from '@peertube/http-signature';
import type * as Bull from 'bullmq'; import type * as Bull from 'bullmq';
import type { Packed } from '@/misc/json-schema.js';
export const QUEUE_TYPES = [ export const QUEUE_TYPES = [
'system', 'system',
@ -69,61 +69,85 @@ export class QueueService {
@Inject('queue:userWebhookDeliver') public userWebhookDeliverQueue: UserWebhookDeliverQueue, @Inject('queue:userWebhookDeliver') public userWebhookDeliverQueue: UserWebhookDeliverQueue,
@Inject('queue:systemWebhookDeliver') public systemWebhookDeliverQueue: SystemWebhookDeliverQueue, @Inject('queue:systemWebhookDeliver') public systemWebhookDeliverQueue: SystemWebhookDeliverQueue,
) { ) {
this.systemQueue.add('tickCharts', { this.systemQueue.upsertJobScheduler('tickCharts', {
pattern: '55 * * * *',
}, { }, {
repeat: { pattern: '55 * * * *' }, name: 'tickCharts',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('resyncCharts', { this.systemQueue.upsertJobScheduler('resyncCharts', {
pattern: '0 0 * * *',
}, { }, {
repeat: { pattern: '0 0 * * *' }, name: 'resyncCharts',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('cleanCharts', { this.systemQueue.upsertJobScheduler('cleanCharts', {
pattern: '0 0 * * *',
}, { }, {
repeat: { pattern: '0 0 * * *' }, name: 'cleanCharts',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('aggregateRetention', { this.systemQueue.upsertJobScheduler('aggregateRetention', {
pattern: '0 0 * * *',
}, { }, {
repeat: { pattern: '0 0 * * *' }, name: 'aggregateRetention',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('clean', { this.systemQueue.upsertJobScheduler('clean', {
pattern: '0 0 * * *',
}, { }, {
repeat: { pattern: '0 0 * * *' }, name: 'clean',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('checkExpiredMutings', { this.systemQueue.upsertJobScheduler('checkExpiredMutings', {
pattern: '*/5 * * * *',
}, { }, {
repeat: { pattern: '*/5 * * * *' }, name: 'checkExpiredMutings',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('bakeBufferedReactions', { this.systemQueue.upsertJobScheduler('bakeBufferedReactions', {
pattern: '0 0 * * *',
}, { }, {
repeat: { pattern: '0 0 * * *' }, name: 'bakeBufferedReactions',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
this.systemQueue.add('checkModeratorsActivity', { this.systemQueue.upsertJobScheduler('checkModeratorsActivity', {
}, {
// 毎時30分に起動 // 毎時30分に起動
repeat: { pattern: '30 * * * *' }, pattern: '30 * * * *',
}, {
name: 'checkModeratorsActivity',
opts: {
removeOnComplete: 10, removeOnComplete: 10,
removeOnFail: 30, removeOnFail: 30,
},
}); });
} }

View File

@ -4,7 +4,7 @@
*/ */
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { In } from 'typeorm'; import { EntityNotFoundError, In } from 'typeorm';
import { ModuleRef } from '@nestjs/core'; import { ModuleRef } from '@nestjs/core';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Packed } from '@/misc/json-schema.js'; import type { Packed } from '@/misc/json-schema.js';
@ -46,6 +46,17 @@ function getAppearNoteIds(notes: MiNote[]): Set<string> {
return appearNoteIds; return appearNoteIds;
} }
async function nullIfEntityNotFound<T>(promise: Promise<T>): Promise<T | null> {
try {
return await promise;
} catch (err) {
if (err instanceof EntityNotFoundError) {
return null;
}
throw err;
}
}
@Injectable() @Injectable()
export class NoteEntityService implements OnModuleInit { export class NoteEntityService implements OnModuleInit {
private userEntityService: UserEntityService; private userEntityService: UserEntityService;
@ -436,19 +447,21 @@ export class NoteEntityService implements OnModuleInit {
...(opts.detail ? { ...(opts.detail ? {
clippedCount: note.clippedCount, clippedCount: note.clippedCount,
reply: note.replyId ? this.pack(note.reply ?? note.replyId, me, { // そもそもJOINしていない場合はundefined、JOINしたけど存在していなかった場合はnullで区別される
reply: (note.replyId && note.reply === null) ? null : note.replyId ? nullIfEntityNotFound(this.pack(note.reply ?? note.replyId, me, {
detail: false, detail: false,
skipHide: opts.skipHide, skipHide: opts.skipHide,
withReactionAndUserPairCache: opts.withReactionAndUserPairCache, withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
_hint_: options?._hint_, _hint_: options?._hint_,
}) : undefined, })) : undefined,
renote: note.renoteId ? this.pack(note.renote ?? note.renoteId, me, { // そもそもJOINしていない場合はundefined、JOINしたけど存在していなかった場合はnullで区別される
renote: (note.renoteId && note.renote === null) ? null : note.renoteId ? nullIfEntityNotFound(this.pack(note.renote ?? note.renoteId, me, {
detail: true, detail: true,
skipHide: opts.skipHide, skipHide: opts.skipHide,
withReactionAndUserPairCache: opts.withReactionAndUserPairCache, withReactionAndUserPairCache: opts.withReactionAndUserPairCache,
_hint_: options?._hint_, _hint_: options?._hint_,
}) : undefined, })) : undefined,
poll: note.hasPoll ? this.populatePoll(note, meId) : undefined, poll: note.hasPoll ? this.populatePoll(note, meId) : undefined,
@ -591,7 +604,7 @@ export class NoteEntityService implements OnModuleInit {
private findNoteOrFail(id: string): Promise<MiNote> { private findNoteOrFail(id: string): Promise<MiNote> {
return this.notesRepository.findOneOrFail({ return this.notesRepository.findOneOrFail({
where: { id }, where: { id },
relations: ['user'], relations: ['user', 'renote', 'reply'],
}); });
} }

View File

@ -36,7 +36,7 @@ export class MiNote {
public replyId: MiNote['id'] | null; public replyId: MiNote['id'] | null;
@ManyToOne(type => MiNote, { @ManyToOne(type => MiNote, {
onDelete: 'CASCADE', createForeignKeyConstraints: false,
}) })
@JoinColumn() @JoinColumn()
public reply: MiNote | null; public reply: MiNote | null;
@ -50,7 +50,7 @@ export class MiNote {
public renoteId: MiNote['id'] | null; public renoteId: MiNote['id'] | null;
@ManyToOne(type => MiNote, { @ManyToOne(type => MiNote, {
onDelete: 'CASCADE', createForeignKeyConstraints: false,
}) })
@JoinColumn() @JoinColumn()
public renote: MiNote | null; public renote: MiNote | null;

View File

@ -40,8 +40,8 @@ export class GetterService {
} }
@bindThis @bindThis
public async getNoteWithUser(noteId: MiNote['id']) { public async getNoteWithRelations(noteId: MiNote['id']) {
const note = await this.notesRepository.findOne({ where: { id: noteId }, relations: ['user'] }); const note = await this.notesRepository.findOne({ where: { id: noteId }, relations: ['user', 'reply', 'renote', 'reply.user', 'renote.user'] });
if (note == null) { if (note == null) {
throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.'); throw new IdentifiableError('9725d0ce-ba28-4dde-95a7-2cbb2c15de24', 'No such note.');

View File

@ -269,7 +269,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
let renote: MiNote | null = null; let renote: MiNote | null = null;
if (ps.renoteId != null) { if (ps.renoteId != null) {
// Fetch renote to note // Fetch renote to note
renote = await this.notesRepository.findOneBy({ id: ps.renoteId }); renote = await this.notesRepository.findOne({
where: { id: ps.renoteId },
relations: ['user', 'renote', 'reply'],
});
if (renote == null) { if (renote == null) {
throw new ApiError(meta.errors.noSuchRenoteTarget); throw new ApiError(meta.errors.noSuchRenoteTarget);
@ -315,7 +318,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
let reply: MiNote | null = null; let reply: MiNote | null = null;
if (ps.replyId != null) { if (ps.replyId != null) {
// Fetch reply // Fetch reply
reply = await this.notesRepository.findOneBy({ id: ps.replyId }); reply = await this.notesRepository.findOne({
where: { id: ps.replyId },
relations: ['user'],
});
if (reply == null) { if (reply == null) {
throw new ApiError(meta.errors.noSuchReplyTarget); throw new ApiError(meta.errors.noSuchReplyTarget);

View File

@ -55,7 +55,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private getterService: GetterService, private getterService: GetterService,
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const note = await this.getterService.getNoteWithUser(ps.noteId).catch(err => { const note = await this.getterService.getNoteWithRelations(ps.noteId).catch(err => {
if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote); if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
throw err; throw err;
}); });

View File

@ -237,7 +237,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} }
if (ps.withRenotes === false) { if (ps.withRenotes === false) {
query.andWhere('note.renoteId IS NULL'); query.andWhere(new Brackets(qb => {
qb.orWhere('note.renoteId IS NULL');
qb.orWhere(new Brackets(qb => {
qb.orWhere('note.text IS NOT NULL');
qb.orWhere('note.fileIds != \'{}\'');
}));
}));
} }
//#endregion //#endregion

View File

@ -586,7 +586,7 @@ export class ClientServerService {
id: request.params.note, id: request.params.note,
visibility: In(['public', 'home']), visibility: In(['public', 'home']),
}, },
relations: ['user'], relations: ['user', 'reply', 'renote'],
}); });
if ( if (
@ -827,8 +827,11 @@ export class ClientServerService {
fastify.get<{ Params: { note: string; } }>('/embed/notes/:note', async (request, reply) => { fastify.get<{ Params: { note: string; } }>('/embed/notes/:note', async (request, reply) => {
reply.removeHeader('X-Frame-Options'); reply.removeHeader('X-Frame-Options');
const note = await this.notesRepository.findOneBy({ const note = await this.notesRepository.findOne({
where: {
id: request.params.note, id: request.params.note,
},
relations: ['user', 'reply', 'renote'],
}); });
if (note == null) return; if (note == null) return;

View File

@ -63,7 +63,6 @@ describe('Note', () => {
deepStrictEqualWithExcludedFields(note, resolvedNote, [ deepStrictEqualWithExcludedFields(note, resolvedNote, [
'id', 'id',
'emojis', 'emojis',
'reactionAcceptance',
'replyId', 'replyId',
'reply', 'reply',
'userId', 'userId',
@ -105,7 +104,6 @@ describe('Note', () => {
deepStrictEqualWithExcludedFields(note, resolvedNote, [ deepStrictEqualWithExcludedFields(note, resolvedNote, [
'id', 'id',
'emojis', 'emojis',
'reactionAcceptance',
'renoteId', 'renoteId',
'renote', 'renote',
'userId', 'userId',

View File

@ -673,7 +673,6 @@ describe('アンテナ', () => {
assert.deepStrictEqual(response, expected); assert.deepStrictEqual(response, expected);
}); });
test.skip('が取得でき、日付指定のPaginationに一貫性があること', async () => { }); test.skip('が取得でき、日付指定のPaginationに一貫性があること', async () => { });
test.each([ test.each([
{ label: 'ID指定', offsetBy: 'id' }, { label: 'ID指定', offsetBy: 'id' },

File diff suppressed because it is too large Load Diff

View File

@ -18,5 +18,5 @@ onmessage = (event) => {
render(event.data.hash, canvas); render(event.data.hash, canvas);
const bitmap = canvas.transferToImageBitmap(); const bitmap = canvas.transferToImageBitmap();
postMessage({ id: event.data.id, bitmap }); postMessage({ id: event.data.id, bitmap }, [bitmap]);
}; };

View File

@ -495,7 +495,7 @@ function done(query?: string): boolean | void {
function settings() { function settings() {
emit('esc'); emit('esc');
router.push('settings/emoji-palette'); router.push('/settings/emoji-palette');
} }
onMounted(() => { onMounted(() => {

View File

@ -52,15 +52,20 @@ import TestWebGL2 from '@/workers/test-webgl2?worker';
import { WorkerMultiDispatch } from '@@/js/worker-multi-dispatch.js'; import { WorkerMultiDispatch } from '@@/js/worker-multi-dispatch.js';
import { extractAvgColorFromBlurhash } from '@@/js/extract-avg-color-from-blurhash.js'; import { extractAvgColorFromBlurhash } from '@@/js/extract-avg-color-from-blurhash.js';
// Web Worker
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const isTest = (import.meta.env.MODE === 'test' || window.Cypress != null);
const canvasPromise = new Promise<WorkerMultiDispatch | HTMLCanvasElement>(resolve => { const canvasPromise = new Promise<WorkerMultiDispatch | HTMLCanvasElement>(resolve => {
// Web Worker if (isTest) {
if (import.meta.env.MODE === 'test') {
const canvas = window.document.createElement('canvas'); const canvas = window.document.createElement('canvas');
canvas.width = 64; canvas.width = 64;
canvas.height = 64; canvas.height = 64;
resolve(canvas); resolve(canvas);
return; return;
} }
const testWorker = new TestWebGL2(); const testWorker = new TestWebGL2();
testWorker.addEventListener('message', event => { testWorker.addEventListener('message', event => {
if (event.data.result) { if (event.data.result) {
@ -189,7 +194,7 @@ function drawAvg() {
} }
async function draw() { async function draw() {
if (import.meta.env.MODE === 'test' && props.hash == null) return; if (isTest && props.hash == null) return;
drawAvg(); drawAvg();

View File

@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
:class="[$style.root, { [$style.showActionsOnlyHover]: prefer.s.showNoteActionsOnlyHover, [$style.skipRender]: prefer.s.skipNoteRender }]" :class="[$style.root, { [$style.showActionsOnlyHover]: prefer.s.showNoteActionsOnlyHover, [$style.skipRender]: prefer.s.skipNoteRender }]"
tabindex="0" tabindex="0"
> >
<MkNoteSub v-if="appearNote.reply && !renoteCollapsed" :note="appearNote.reply" :class="$style.replyTo"/> <MkNoteSub v-if="appearNote.replyId && !renoteCollapsed" :note="appearNote.reply" :class="$style.replyTo"/>
<div v-if="pinned" :class="$style.tip"><i class="ti ti-pin"></i> {{ i18n.ts.pinnedNote }}</div> <div v-if="pinned" :class="$style.tip"><i class="ti ti-pin"></i> {{ i18n.ts.pinnedNote }}</div>
<div v-if="isRenote" :class="$style.renote"> <div v-if="isRenote" :class="$style.renote">
<div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div> <div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
@ -99,7 +99,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-if="isEnabledUrlPreview"> <div v-if="isEnabledUrlPreview">
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/> <MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/>
</div> </div>
<div v-if="appearNote.renote" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div> <div v-if="appearNote.renoteId" :class="$style.quote"><MkNoteSimple :note="appearNote.renote" :class="$style.quoteNote"/></div>
<button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false"> <button v-if="isLong && collapsed" :class="$style.collapsed" class="_button" @click="collapsed = false">
<span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span> <span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
</button> </button>
@ -282,7 +282,7 @@ let note = deepClone(props.note);
//} //}
const isRenote = Misskey.note.isPureRenote(note); const isRenote = Misskey.note.isPureRenote(note);
const appearNote = getAppearNote(note); const appearNote = getAppearNote(note) ?? note;
const { $note: $appearNote, subscribe: subscribeManuallyToNoteCapture } = useNoteCapture({ const { $note: $appearNote, subscribe: subscribeManuallyToNoteCapture } = useNoteCapture({
note: appearNote, note: appearNote,
parentNote: note, parentNote: note,

View File

@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
<MkNoteSub v-for="note in conversation" :key="note.id" :class="$style.replyToMore" :note="note"/> <MkNoteSub v-for="note in conversation" :key="note.id" :class="$style.replyToMore" :note="note"/>
</div> </div>
<MkNoteSub v-if="appearNote.reply" :note="appearNote.reply" :class="$style.replyTo"/> <MkNoteSub v-if="appearNote.replyId" :note="appearNote.reply" :class="$style.replyTo"/>
<div v-if="isRenote" :class="$style.renote"> <div v-if="isRenote" :class="$style.renote">
<MkAvatar :class="$style.renoteAvatar" :user="note.user" link preview/> <MkAvatar :class="$style.renoteAvatar" :user="note.user" link preview/>
<i class="ti ti-repeat" style="margin-right: 4px;"></i> <i class="ti ti-repeat" style="margin-right: 4px;"></i>

View File

@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div :class="$style.root"> <div v-if="note" :class="$style.root">
<MkAvatar :class="$style.avatar" :user="note.user" link preview/> <MkAvatar :class="$style.avatar" :user="note.user" link preview/>
<div :class="$style.main"> <div :class="$style.main">
<MkNoteHeader :class="$style.header" :note="note" :mini="true"/> <MkNoteHeader :class="$style.header" :note="note" :mini="true"/>
@ -19,6 +19,9 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</div> </div>
</div> </div>
<div v-else :class="$style.deleted">
{{ i18n.ts.deletedNote }}
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -27,9 +30,10 @@ import * as Misskey from 'misskey-js';
import MkNoteHeader from '@/components/MkNoteHeader.vue'; import MkNoteHeader from '@/components/MkNoteHeader.vue';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue'; import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkCwButton from '@/components/MkCwButton.vue'; import MkCwButton from '@/components/MkCwButton.vue';
import { i18n } from '@/i18n.js';
const props = defineProps<{ const props = defineProps<{
note: Misskey.entities.Note; note: Misskey.entities.Note | null;
}>(); }>();
const showContent = ref(false); const showContent = ref(false);
@ -101,4 +105,14 @@ const showContent = ref(false);
height: 48px; height: 48px;
} }
} }
.deleted {
text-align: center;
padding: 8px !important;
margin: 8px 8px 0 8px;
--color: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.15));
background-size: auto auto;
background-image: repeating-linear-gradient(135deg, transparent, transparent 10px, var(--color) 4px, var(--color) 14px);
border-radius: 8px;
}
</style> </style>

View File

@ -4,7 +4,10 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<div v-if="!muted" :class="[$style.root, { [$style.children]: depth > 1 }]"> <div v-if="note == null" :class="$style.deleted">
{{ i18n.ts.deletedNote }}
</div>
<div v-else-if="!muted" :class="[$style.root, { [$style.children]: depth > 1 }]">
<div :class="$style.main"> <div :class="$style.main">
<div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div> <div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
<MkAvatar :class="$style.avatar" :user="note.user" link preview/> <MkAvatar :class="$style.avatar" :user="note.user" link preview/>
@ -53,7 +56,7 @@ import { userPage } from '@/filters/user.js';
import { checkWordMute } from '@/utility/check-word-mute.js'; import { checkWordMute } from '@/utility/check-word-mute.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
note: Misskey.entities.Note; note: Misskey.entities.Note | null;
detail?: boolean; detail?: boolean;
// how many notes are in between this one and the note being viewed in detail // how many notes are in between this one and the note being viewed in detail
@ -62,12 +65,12 @@ const props = withDefaults(defineProps<{
depth: 1, depth: 1,
}); });
const muted = ref($i ? checkWordMute(props.note, $i, $i.mutedWords) : false); const muted = ref(props.note && $i ? checkWordMute(props.note, $i, $i.mutedWords) : false);
const showContent = ref(false); const showContent = ref(false);
const replies = ref<Misskey.entities.Note[]>([]); const replies = ref<Misskey.entities.Note[]>([]);
if (props.detail) { if (props.detail && props.note) {
misskeyApi('notes/children', { misskeyApi('notes/children', {
noteId: props.note.id, noteId: props.note.id,
limit: 5, limit: 5,
@ -160,4 +163,14 @@ if (props.detail) {
margin: 8px 8px 0 8px; margin: 8px 8px 0 8px;
border-radius: 8px; border-radius: 8px;
} }
.deleted {
text-align: center;
padding: 8px !important;
margin: 8px 8px 0 8px;
--color: light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.15));
background-size: auto auto;
background-image: repeating-linear-gradient(135deg, transparent, transparent 10px, var(--color) 4px, var(--color) 14px);
border-radius: 8px;
}
</style> </style>

View File

@ -151,7 +151,7 @@ const contextmenu = computed(() => ([{
function back() { function back() {
history.value.pop(); history.value.pop();
windowRouter.replace(history.value.at(-1)!.path); windowRouter.replaceByPath(history.value.at(-1)!.path);
} }
function reload() { function reload() {
@ -163,7 +163,7 @@ function close() {
} }
function expand() { function expand() {
mainRouter.push(windowRouter.getCurrentFullPath(), 'forcePage'); mainRouter.pushByPath(windowRouter.getCurrentFullPath(), 'forcePage');
windowEl.value?.close(); windowEl.value?.close();
} }

View File

@ -186,7 +186,7 @@ function searchOnKeyDown(ev: KeyboardEvent) {
if (ev.key === 'Enter' && searchSelectedIndex.value != null) { if (ev.key === 'Enter' && searchSelectedIndex.value != null) {
ev.preventDefault(); ev.preventDefault();
router.push(searchResult.value[searchSelectedIndex.value].path + '#' + searchResult.value[searchSelectedIndex.value].id); router.pushByPath(searchResult.value[searchSelectedIndex.value].path + '#' + searchResult.value[searchSelectedIndex.value].id);
} else if (ev.key === 'ArrowDown') { } else if (ev.key === 'ArrowDown') {
ev.preventDefault(); ev.preventDefault();
const current = searchSelectedIndex.value ?? -1; const current = searchSelectedIndex.value ?? -1;

View File

@ -64,7 +64,7 @@ function onContextmenu(ev) {
icon: 'ti ti-player-eject', icon: 'ti ti-player-eject',
text: i18n.ts.showInPage, text: i18n.ts.showInPage,
action: () => { action: () => {
router.push(props.to, 'forcePage'); router.pushByPath(props.to, 'forcePage');
}, },
}, { type: 'divider' }, { }, { type: 'divider' }, {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
@ -99,6 +99,6 @@ function nav(ev: MouseEvent) {
return openWindow(); return openWindow();
} }
router.push(props.to, ev.ctrlKey ? 'forcePage' : null); router.pushByPath(props.to, ev.ctrlKey ? 'forcePage' : null);
} }
</script> </script>

View File

@ -76,7 +76,7 @@ function mount() {
function back() { function back() {
const prev = tabs.value[tabs.value.length - 2]; const prev = tabs.value[tabs.value.length - 2];
tabs.value = [...tabs.value.slice(0, tabs.value.length - 1)]; tabs.value = [...tabs.value.slice(0, tabs.value.length - 1)];
router.replace(prev.fullPath); router?.replaceByPath(prev.fullPath);
} }
router.useListener('change', ({ resolved }) => { router.useListener('change', ({ resolved }) => {

View File

@ -58,7 +58,7 @@ export type RouterEvents = {
beforeFullPath: string; beforeFullPath: string;
fullPath: string; fullPath: string;
route: RouteDef | null; route: RouteDef | null;
props: Map<string, string> | null; props: Map<string, string | boolean> | null;
}) => void; }) => void;
same: () => void; same: () => void;
}; };
@ -77,6 +77,110 @@ export type PathResolvedResult = {
}; };
}; };
//#region Path Types
type Prettify<T> = {
[K in keyof T]: T[K]
} & {};
type RemoveNever<T> = {
[K in keyof T as T[K] extends never ? never : K]: T[K];
} & {};
type IsPathParameter<Part extends string> = Part extends `${string}:${infer Parameter}` ? Parameter : never;
type GetPathParamKeys<Path extends string> =
Path extends `${infer A}/${infer B}`
? IsPathParameter<A> | GetPathParamKeys<B>
: IsPathParameter<Path>;
type GetPathParams<Path extends string> = Prettify<{
[Param in GetPathParamKeys<Path> as Param extends `${string}?` ? never : Param]: string;
} & {
[Param in GetPathParamKeys<Path> as Param extends `${infer OptionalParam}?` ? OptionalParam : never]?: string;
}>;
type UnwrapReadOnly<T> = T extends ReadonlyArray<infer U>
? U
: T extends Readonly<infer U>
? U
: T;
type GetPaths<Def extends RouteDef> = Def extends { path: infer Path }
? Path extends string
? Def extends { children: infer Children }
? Children extends RouteDef[]
? Path | `${Path}${FlattenAllPaths<Children>}`
: Path
: Path
: never
: never;
type FlattenAllPaths<Defs extends RouteDef[]> = GetPaths<Defs[number]>;
type GetSinglePathQuery<Def extends RouteDef, Path extends FlattenAllPaths<RouteDef[]>> = RemoveNever<
Def extends { path: infer BasePath, children: infer Children }
? BasePath extends string
? Path extends `${BasePath}${infer ChildPath}`
? Children extends RouteDef[]
? ChildPath extends FlattenAllPaths<Children>
? GetPathQuery<Children, ChildPath>
: Record<string, never>
: never
: never
: never
: Def['path'] extends Path
? Def extends { query: infer Query }
? Query extends Record<string, string>
? UnwrapReadOnly<{ [Key in keyof Query]?: string; }>
: Record<string, never>
: Record<string, never>
: Record<string, never>
>;
type GetPathQuery<Defs extends RouteDef[], Path extends FlattenAllPaths<Defs>> = GetSinglePathQuery<Defs[number], Path>;
type RequiredIfNotEmpty<K extends string, T extends Record<string, unknown>> = T extends Record<string, never>
? { [Key in K]?: T }
: { [Key in K]: T };
type NotRequiredIfEmpty<T extends Record<string, unknown>> = T extends Record<string, never> ? T | undefined : T;
type GetRouterOperationProps<Defs extends RouteDef[], Path extends FlattenAllPaths<Defs>> = NotRequiredIfEmpty<RequiredIfNotEmpty<'params', GetPathParams<Path>> & {
query?: GetPathQuery<Defs, Path>;
hash?: string;
}>;
//#endregion
function buildFullPath(args: {
path: string;
params?: Record<string, string>;
query?: Record<string, string>;
hash?: string;
}) {
let fullPath = args.path;
if (args.params) {
for (const key in args.params) {
const value = args.params[key];
const replaceRegex = new RegExp(`:${key}(\\?)?`, 'g');
fullPath = fullPath.replace(replaceRegex, value ? encodeURIComponent(value) : '');
}
}
if (args.query) {
const queryString = new URLSearchParams(args.query).toString();
if (queryString) {
fullPath += '?' + queryString;
}
}
if (args.hash) {
fullPath += '#' + encodeURIComponent(args.hash);
}
return fullPath;
}
function parsePath(path: string): ParsedPath { function parsePath(path: string): ParsedPath {
const res = [] as ParsedPath; const res = [] as ParsedPath;
@ -282,7 +386,7 @@ export class Nirax<DEF extends RouteDef[]> extends EventEmitter<RouterEvents> {
} }
} }
if (res.route.loginRequired && !this.isLoggedIn) { if (res.route.loginRequired && !this.isLoggedIn && 'component' in res.route) {
res.route.component = this.notFoundPageComponent; res.route.component = this.notFoundPageComponent;
res.props.set('showLoginPopup', true); res.props.set('showLoginPopup', true);
} }
@ -310,14 +414,35 @@ export class Nirax<DEF extends RouteDef[]> extends EventEmitter<RouterEvents> {
return this.currentFullPath; return this.currentFullPath;
} }
public push(fullPath: string, flag?: RouterFlag) { public push<P extends FlattenAllPaths<DEF>>(path: P, props?: GetRouterOperationProps<DEF, P>, flag?: RouterFlag | null) {
const fullPath = buildFullPath({
path,
params: props?.params,
query: props?.query,
hash: props?.hash,
});
this.pushByPath(fullPath, flag);
}
public replace<P extends FlattenAllPaths<DEF>>(path: P, props?: GetRouterOperationProps<DEF, P>) {
const fullPath = buildFullPath({
path,
params: props?.params,
query: props?.query,
hash: props?.hash,
});
this.replaceByPath(fullPath);
}
/** どうしても必要な場合に使用(パスが確定している場合は `Nirax.push` を使用すること) */
public pushByPath(fullPath: string, flag?: RouterFlag | null) {
const beforeFullPath = this.currentFullPath; const beforeFullPath = this.currentFullPath;
if (fullPath === beforeFullPath) { if (fullPath === beforeFullPath) {
this.emit('same'); this.emit('same');
return; return;
} }
if (this.navHook) { if (this.navHook) {
const cancel = this.navHook(fullPath, flag); const cancel = this.navHook(fullPath, flag ?? undefined);
if (cancel) return; if (cancel) return;
} }
const res = this.navigate(fullPath); const res = this.navigate(fullPath);
@ -333,14 +458,15 @@ export class Nirax<DEF extends RouteDef[]> extends EventEmitter<RouterEvents> {
} }
} }
public replace(fullPath: string) { /** どうしても必要な場合に使用(パスが確定している場合は `Nirax.replace` を使用すること) */
public replaceByPath(fullPath: string) {
const res = this.navigate(fullPath); const res = this.navigate(fullPath);
this.emit('replace', { this.emit('replace', {
fullPath: res._parsedRoute.fullPath, fullPath: res._parsedRoute.fullPath,
}); });
} }
public useListener<E extends keyof RouterEvents, L = RouterEvents[E]>(event: E, listener: L) { public useListener<E extends keyof RouterEvents>(event: E, listener: EventEmitter.EventListener<RouterEvents, E>) {
this.addListener(event, listener); this.addListener(event, listener);
onBeforeUnmount(() => { onBeforeUnmount(() => {

View File

@ -72,12 +72,20 @@ async function save() {
roleId: role.value.id, roleId: role.value.id,
...data.value, ...data.value,
}); });
router.push('/admin/roles/' + role.value.id); router.push('/admin/roles/:id', {
params: {
id: role.value.id,
}
});
} else { } else {
const created = await os.apiWithDialog('admin/roles/create', { const created = await os.apiWithDialog('admin/roles/create', {
...data.value, ...data.value,
}); });
router.push('/admin/roles/' + created.id); router.push('/admin/roles/:id', {
params: {
id: created.id,
}
});
} }
} }

View File

@ -88,7 +88,11 @@ const role = reactive(await misskeyApi('admin/roles/show', {
})); }));
function edit() { function edit() {
router.push('/admin/roles/' + role.id + '/edit'); router.push('/admin/roles/:id/edit', {
params: {
id: role.id,
}
});
} }
async function del() { async function del() {

View File

@ -47,7 +47,11 @@ async function timetravel() {
} }
function settings() { function settings() {
router.push(`/my/antennas/${props.antennaId}`); router.push('/my/antennas/:antennaId', {
params: {
antennaId: props.antennaId,
}
});
} }
function focus() { function focus() {

View File

@ -165,7 +165,11 @@ function save() {
os.apiWithDialog('channels/update', params); os.apiWithDialog('channels/update', params);
} else { } else {
os.apiWithDialog('channels/create', params).then(created => { os.apiWithDialog('channels/create', params).then(created => {
router.push(`/channels/${created.id}`); router.push('/channels/:channelId', {
params: {
channelId: created.id,
},
});
}); });
} }
} }

View File

@ -147,7 +147,11 @@ watch(() => props.channelId, async () => {
}, { immediate: true }); }, { immediate: true });
function edit() { function edit() {
router.push(`/channels/${channel.value?.id}/edit`); router.push('/channels/:channelId/edit', {
params: {
channelId: props.channelId,
}
});
} }
function openPostForm() { function openPostForm() {

View File

@ -86,7 +86,11 @@ function start(ev: MouseEvent) {
async function startUser() { async function startUser() {
// TODO: localOnly // TODO: localOnly
os.selectUser({ localOnly: true }).then(user => { os.selectUser({ localOnly: true }).then(user => {
router.push(`/chat/user/${user.id}`); router.push('/chat/user/:userId', {
params: {
userId: user.id,
}
});
}); });
} }
@ -101,7 +105,11 @@ async function createRoom() {
name: result, name: result,
}); });
router.push(`/chat/room/${room.id}`); router.push('/chat/room/:roomId', {
params: {
roomId: room.id,
}
});
} }
async function search() { async function search() {

View File

@ -61,7 +61,11 @@ async function join(invitation: Misskey.entities.ChatRoomInvitation) {
roomId: invitation.room.id, roomId: invitation.room.id,
}); });
router.push(`/chat/room/${invitation.room.id}`); router.push('/chat/room/:roomId', {
params: {
roomId: invitation.room.id,
},
});
} }
async function ignore(invitation: Misskey.entities.ChatRoomInvitation) { async function ignore(invitation: Misskey.entities.ChatRoomInvitation) {

View File

@ -429,7 +429,11 @@ async function save() {
script: script.value, script: script.value,
visibility: visibility.value, visibility: visibility.value,
}); });
router.push('/play/' + created.id + '/edit'); router.push('/play/:id/edit', {
params: {
id: created.id,
},
});
} }
} }

View File

@ -85,7 +85,11 @@ async function save() {
fileIds: files.value.map(file => file.id), fileIds: files.value.map(file => file.id),
isSensitive: isSensitive.value, isSensitive: isSensitive.value,
}); });
router.push(`/gallery/${props.postId}`); router.push('/gallery/:postId', {
params: {
postId: props.postId,
}
});
} else { } else {
const created = await os.apiWithDialog('gallery/posts/create', { const created = await os.apiWithDialog('gallery/posts/create', {
title: title.value, title: title.value,
@ -93,7 +97,11 @@ async function save() {
fileIds: files.value.map(file => file.id), fileIds: files.value.map(file => file.id),
isSensitive: isSensitive.value, isSensitive: isSensitive.value,
}); });
router.push(`/gallery/${created.id}`); router.push('/gallery/:postId', {
params: {
postId: created.id,
}
});
} }
} }

View File

@ -150,7 +150,11 @@ async function unlike() {
} }
function edit() { function edit() {
router.push(`/gallery/${post.value.id}/edit`); router.push('/gallery/:postId/edit', {
params: {
postId: props.postId,
},
});
} }
async function reportAbuse() { async function reportAbuse() {

View File

@ -45,11 +45,20 @@ function fetch() {
promise = misskeyApi('ap/show', { promise = misskeyApi('ap/show', {
uri, uri,
}); });
promise.then(res => { promise.then(res => {
if (res.type === 'User') { if (res.type === 'User') {
mainRouter.replace(res.object.host ? `/@${res.object.username}@${res.object.host}` : `/@${res.object.username}`); mainRouter.replace('/@:acct/:page?', {
params: {
acct: res.host != null ? `${res.object.username}@${res.object.host}` : res.object.username,
}
});
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
mainRouter.replace(`/notes/${res.object.id}`); mainRouter.replace('/notes/:noteId/:initialTab?', {
params: {
noteId: res.object.id,
}
});
} else { } else {
os.alert({ os.alert({
type: 'error', type: 'error',
@ -63,7 +72,11 @@ function fetch() {
} }
promise = misskeyApi('users/show', Misskey.acct.parse(uri)); promise = misskeyApi('users/show', Misskey.acct.parse(uri));
promise.then(user => { promise.then(user => {
mainRouter.replace(user.host ? `/@${user.username}@${user.host}` : `/@${user.username}`); mainRouter.replace('/@:acct/:page?', {
params: {
acct: user.host != null ? `${user.username}@${user.host}` : user.username,
}
});
}); });
} }

View File

@ -154,7 +154,11 @@ async function save() {
pageId.value = created.id; pageId.value = created.id;
currentName.value = name.value.trim(); currentName.value = name.value.trim();
mainRouter.replace(`/pages/edit/${pageId.value}`); mainRouter.replace('/pages/edit/:initPageId', {
params: {
initPageId: pageId.value,
},
});
} }
} }
@ -189,7 +193,11 @@ async function duplicate() {
pageId.value = created.id; pageId.value = created.id;
currentName.value = name.value.trim(); currentName.value = name.value.trim();
mainRouter.push(`/pages/edit/${pageId.value}`); mainRouter.push('/pages/edit/:initPageId', {
params: {
initPageId: pageId.value,
},
});
} }
async function add() { async function add() {

View File

@ -267,7 +267,11 @@ function showMenu(ev: MouseEvent) {
menuItems.push({ menuItems.push({
icon: 'ti ti-pencil', icon: 'ti ti-pencil',
text: i18n.ts.edit, text: i18n.ts.edit,
action: () => router.push(`/pages/edit/${page.value.id}`), action: () => router.push('/pages/edit/:initPageId', {
params: {
initPageId: page.value!.id,
},
}),
}); });
if ($i.pinnedPageId === page.value.id) { if ($i.pinnedPageId === page.value.id) {

View File

@ -168,7 +168,11 @@ function startGame(game: Misskey.entities.ReversiGameDetailed) {
playbackRate: 1, playbackRate: 1,
}); });
router.push(`/reversi/g/${game.id}`); router.push('/reversi/g/:gameId', {
params: {
gameId: game.id,
},
});
} }
async function matchHeatbeat() { async function matchHeatbeat() {

View File

@ -264,10 +264,18 @@ async function search() {
const res = await apLookup(searchParams.value.query); const res = await apLookup(searchParams.value.query);
if (res.type === 'User') { if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`); router.push('/@:acct/:page?', {
params: {
acct: `${res.object.username}@${res.object.host}`,
},
});
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`); router.push('/notes/:noteId/:initialTab?', {
params: {
noteId: res.object.id,
},
});
} }
return; return;
@ -282,7 +290,7 @@ async function search() {
text: i18n.ts.lookupConfirm, text: i18n.ts.lookupConfirm,
}); });
if (!confirm.canceled) { if (!confirm.canceled) {
router.push(`/${searchParams.value.query}`); router.pushByPath(`/${searchParams.value.query}`);
return; return;
} }
} }
@ -293,7 +301,11 @@ async function search() {
text: i18n.ts.openTagPageConfirm, text: i18n.ts.openTagPageConfirm,
}); });
if (!confirm.canceled) { if (!confirm.canceled) {
router.push(`/tags/${encodeURIComponent(searchParams.value.query.substring(1))}`); router.push('/tags/:tag', {
params: {
tag: searchParams.value.query.substring(1),
},
});
return; return;
} }
} }

View File

@ -77,10 +77,18 @@ async function search() {
const res = await promise; const res = await promise;
if (res.type === 'User') { if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`); router.push('/@:acct/:page?', {
params: {
acct: `${res.object.username}@${res.object.host}`,
},
});
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`); router.push('/notes/:noteId/:initialTab?', {
params: {
noteId: res.object.id,
},
});
} }
return; return;
@ -95,7 +103,7 @@ async function search() {
text: i18n.ts.lookupConfirm, text: i18n.ts.lookupConfirm,
}); });
if (!confirm.canceled) { if (!confirm.canceled) {
router.push(`/${query}`); router.pushByPath(`/${query}`);
return; return;
} }
} }
@ -106,7 +114,11 @@ async function search() {
text: i18n.ts.openTagPageConfirm, text: i18n.ts.openTagPageConfirm,
}); });
if (!confirm.canceled) { if (!confirm.canceled) {
router.push(`/user-tags/${encodeURIComponent(query.substring(1))}`); router.push('/user-tags/:tag', {
params: {
tag: query.substring(1),
},
});
return; return;
} }
} }

View File

@ -135,7 +135,7 @@ async function del(): Promise<void> {
webhookId: props.webhookId, webhookId: props.webhookId,
}); });
router.push('/settings/webhook'); router.push('/settings/connect');
} }
async function test(type: Misskey.entities.UserWebhook['on'][number]): Promise<void> { async function test(type: Misskey.entities.UserWebhook['on'][number]): Promise<void> {

View File

@ -42,7 +42,11 @@ watch(() => props.listId, async () => {
}, { immediate: true }); }, { immediate: true });
function settings() { function settings() {
router.push(`/my/lists/${props.listId}`); router.push('/my/lists/:listId', {
params: {
listId: props.listId,
}
});
} }
const headerActions = computed(() => list.value ? [{ const headerActions = computed(() => list.value ? [{

View File

@ -603,4 +603,4 @@ export const ROUTE_DEF = [{
}, { }, {
path: '/:(*)', path: '/:(*)',
component: page(() => import('@/pages/not-found.vue')), component: page(() => import('@/pages/not-found.vue')),
}] satisfies RouteDef[]; }] as const satisfies RouteDef[];

View File

@ -20,7 +20,7 @@ export function createRouter(fullPath: string): Router {
export const mainRouter = createRouter(window.location.pathname + window.location.search + window.location.hash); export const mainRouter = createRouter(window.location.pathname + window.location.search + window.location.hash);
window.addEventListener('popstate', (event) => { window.addEventListener('popstate', (event) => {
mainRouter.replace(window.location.pathname + window.location.search + window.location.hash); mainRouter.replaceByPath(window.location.pathname + window.location.search + window.location.hash);
}); });
mainRouter.addListener('push', ctx => { mainRouter.addListener('push', ctx => {

View File

@ -43,7 +43,7 @@ export function swInject() {
if (mainRouter.currentRoute.value.path === ev.data.url) { if (mainRouter.currentRoute.value.path === ev.data.url) {
return window.scroll({ top: 0, behavior: 'smooth' }); return window.scroll({ top: 0, behavior: 'smooth' });
} }
return mainRouter.push(ev.data.url); return mainRouter.pushByPath(ev.data.url);
default: default:
return; return;
} }

View File

@ -158,7 +158,11 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router
icon: 'ti ti-user-exclamation', icon: 'ti ti-user-exclamation',
text: i18n.ts.moderation, text: i18n.ts.moderation,
action: () => { action: () => {
router.push(`/admin/user/${user.id}`); router.push('/admin/user/:userId', {
params: {
userId: user.id,
},
});
}, },
}, { type: 'divider' }); }, { type: 'divider' });
} }
@ -216,7 +220,12 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router
icon: 'ti ti-search', icon: 'ti ti-search',
text: i18n.ts.searchThisUsersNotes, text: i18n.ts.searchThisUsersNotes,
action: () => { action: () => {
router.push(`/search?username=${encodeURIComponent(user.username)}${user.host != null ? '&host=' + encodeURIComponent(user.host) : ''}`); router.push('/search', {
query: {
username: user.username,
host: user.host ?? undefined,
},
});
}, },
}); });
} }

View File

@ -19,12 +19,16 @@ export async function lookup(router?: Router) {
if (canceled || query.length <= 1) return; if (canceled || query.length <= 1) return;
if (query.startsWith('@') && !query.includes(' ')) { if (query.startsWith('@') && !query.includes(' ')) {
_router.push(`/${query}`); _router.pushByPath(`/${query}`);
return; return;
} }
if (query.startsWith('#')) { if (query.startsWith('#')) {
_router.push(`/tags/${encodeURIComponent(query.substring(1))}`); _router.push('/tags/:tag', {
params: {
tag: query.substring(1),
}
});
return; return;
} }
@ -32,9 +36,17 @@ export async function lookup(router?: Router) {
const res = await apLookup(query); const res = await apLookup(query);
if (res.type === 'User') { if (res.type === 'User') {
_router.push(`/@${res.object.username}@${res.object.host}`); _router.push('/@:acct/:page?', {
params: {
acct: `${res.object.username}@${res.object.host}`,
},
});
} else if (res.type === 'Note') { } else if (res.type === 'Note') {
_router.push(`/notes/${res.object.id}`); _router.push('/notes/:noteId/:initialTab?', {
params: {
noteId: res.object.id,
},
});
} }
return; return;

View File

@ -24,6 +24,7 @@ for (const item of generated) {
const inline = rootMods.get(id); const inline = rootMods.get(id);
if (inline) { if (inline) {
inline.parentId = item.id; inline.parentId = item.id;
inline.path = item.path;
} else { } else {
console.log('[Settings Search Index] Failed to inline', id); console.log('[Settings Search Index] Failed to inline', id);
} }

View File

@ -18,5 +18,5 @@ onmessage = (event) => {
render(event.data.hash, canvas); render(event.data.hash, canvas);
const bitmap = canvas.transferToImageBitmap(); const bitmap = canvas.transferToImageBitmap();
postMessage({ id: event.data.id, bitmap }); postMessage({ id: event.data.id, bitmap }, [bitmap]);
}; };

View File

@ -3271,7 +3271,7 @@ type PromoReadRequest = operations['promo___read']['requestBody']['content']['ap
type PureRenote = Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'> & AllNullRecord<Pick<Note, 'text'>> & AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>> & { type PureRenote = Omit<Note, 'renote' | 'renoteId' | 'reply' | 'replyId' | 'text' | 'cw' | 'files' | 'fileIds' | 'poll'> & AllNullRecord<Pick<Note, 'text'>> & AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>> & {
files: []; files: [];
fileIds: []; fileIds: [];
} & NonNullableRecord<Pick<Note, 'renote' | 'renoteId'>>; } & NonNullableRecord<Pick<Note, 'renoteId'>> & Pick<Note, 'renote'>;
// @public (undocumented) // @public (undocumented)
type QueueCount = components['schemas']['QueueCount']; type QueueCount = components['schemas']['QueueCount'];
@ -3801,7 +3801,7 @@ type V2AdminEmojiListResponse = operations['v2___admin___emoji___list']['respons
// Warnings were encountered during analysis: // Warnings were encountered during analysis:
// //
// src/entities.ts:54:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // src/entities.ts:55:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts // src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:218:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:218:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:228:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:228:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts

View File

@ -33,7 +33,8 @@ export type PureRenote =
& AllNullRecord<Pick<Note, 'text'>> & AllNullRecord<Pick<Note, 'text'>>
& AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>> & AllNullOrOptionalRecord<Pick<Note, 'reply' | 'replyId' | 'cw' | 'poll'>>
& { files: []; fileIds: []; } & { files: []; fileIds: []; }
& NonNullableRecord<Pick<Note, 'renote' | 'renoteId'>>; & NonNullableRecord<Pick<Note, 'renoteId'>>
& Pick<Note, 'renote'>; // リート対象が削除された場合、renoteIdはあるがrenoteはnullになる
export type PageEvent = { export type PageEvent = {
pageId: Page['id']; pageId: Page['id'];

View File

@ -2,8 +2,8 @@ import type { Note, PureRenote } from './entities.js';
export function isPureRenote(note: Note): note is PureRenote { export function isPureRenote(note: Note): note is PureRenote {
return ( return (
note.renote != null && note.renoteId != null &&
note.reply == null && note.replyId == null &&
note.text == null && note.text == null &&
note.cw == null && note.cw == null &&
(note.fileIds == null || note.fileIds.length === 0) && (note.fileIds == null || note.fileIds.length === 0) &&