diff --git a/locales/index.d.ts b/locales/index.d.ts index 33b63e44c5..f9fcbdb238 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -13245,6 +13245,18 @@ export interface Locale extends ILocale { * Note controls */ "noteFooterLabel": string; + /** + * Packed user data in its raw form. Most of these fields are public and visible to all users. + */ + "rawUserDescription": string; + /** + * Extended user data in its raw form. These fields are private and can only be accessed by moderators. + */ + "rawInfoDescription": string; + /** + * ActivityPub user data in its raw form. These fields are public and accessible to other instances. + */ + "rawApDescription": string; } declare const locales: { [lang: string]: Locale; diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 6ada5463a3..2a93b678dc 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -17,6 +17,7 @@ import { DebounceLoader } from '@/misc/loader.js'; import { IdService } from '@/core/IdService.js'; import { ReactionsBufferingService } from '@/core/ReactionsBufferingService.js'; import { isPackedPureRenote } from '@/misc/is-renote.js'; +import type { Config } from '@/config.js'; import type { OnModuleInit } from '@nestjs/common'; import type { CacheService } from '../CacheService.js'; import type { CustomEmojiService } from '../CustomEmojiService.js'; @@ -92,6 +93,9 @@ export class NoteEntityService implements OnModuleInit { @Inject(DI.channelsRepository) private channelsRepository: ChannelsRepository, + @Inject(DI.config) + private readonly config: Config + //private userEntityService: UserEntityService, //private driveFileEntityService: DriveFileEntityService, //private customEmojiService: CustomEmojiService, @@ -680,4 +684,9 @@ export class NoteEntityService implements OnModuleInit { return map; }, {} as Record); } + + @bindThis + public genLocalNoteUri(noteId: string): string { + return `${this.config.url}/notes/${noteId}`; + } } diff --git a/packages/backend/src/server/api/endpoints/ap/get.ts b/packages/backend/src/server/api/endpoints/ap/get.ts index 06dd37a140..e3e68b50af 100644 --- a/packages/backend/src/server/api/endpoints/ap/get.ts +++ b/packages/backend/src/server/api/endpoints/ap/get.ts @@ -3,11 +3,17 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Injectable } from '@nestjs/common'; +import { Inject, Injectable } from '@nestjs/common'; import ms from 'ms'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { ApResolverService } from '@/core/activitypub/ApResolverService.js'; import { isCollectionOrOrderedCollection, isOrderedCollection, isOrderedCollectionPage } from '@/core/activitypub/type.js'; +import { ApiError } from '@/server/api/error.js'; +import { CacheService } from '@/core/CacheService.js'; +import { UserEntityService } from '@/core/entities/UserEntityService.js'; +import { DI } from '@/di-symbols.js'; +import type { NotesRepository } from '@/models/_.js'; +import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; export const meta = { tags: ['federation'], @@ -22,6 +28,16 @@ export const meta = { }, errors: { + noInputSpecified: { + message: 'uri, userId, or noteId must be specified.', + code: 'NO_INPUT_SPECIFIED', + id: 'b43ff2a7-e7a2-4237-ad7f-7b079563c09e', + }, + multipleInputsSpecified: { + message: 'Only one of uri, userId, or noteId can be specified', + code: 'MULTIPLE_INPUTS_SPECIFIED', + id: 'f1aa27ed-8f20-44f3-a92a-fe073c8ca52b', + }, }, res: { @@ -33,22 +49,46 @@ export const meta = { export const paramDef = { type: 'object', properties: { - uri: { type: 'string' }, + uri: { type: 'string', nullable: true }, + userId: { type: 'string', format: 'misskey:id', nullable: true }, + noteId: { type: 'string', format: 'misskey:id', nullable: true }, expandCollectionItems: { type: 'boolean' }, expandCollectionLimit: { type: 'integer', nullable: true }, allowAnonymous: { type: 'boolean' }, }, - required: ['uri'], } as const; @Injectable() export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( + @Inject(DI.notesRepository) + private readonly notesRepository: NotesRepository, + + private readonly cacheService: CacheService, + private readonly userEntityService: UserEntityService, + private readonly noteEntityService: NoteEntityService, private apResolverService: ApResolverService, ) { - super(meta, paramDef, async (ps, me) => { + super(meta, paramDef, async (ps) => { + if (ps.uri && ps.userId && ps.noteId) { + throw new ApiError(meta.errors.multipleInputsSpecified); + } + + let uri: string; + if (ps.uri) { + uri = ps.uri; + } else if (ps.userId) { + const user = await this.cacheService.findUserById(ps.userId); + uri = user.uri ?? this.userEntityService.genLocalUserUri(ps.userId); + } else if (ps.noteId) { + const note = await this.notesRepository.findOneByOrFail({ id: ps.noteId }); + uri = note.uri ?? this.noteEntityService.genLocalNoteUri(ps.noteId); + } else { + throw new ApiError(meta.errors.noInputSpecified); + } + const resolver = this.apResolverService.createResolver(); - const object = await resolver.resolve(ps.uri, ps.allowAnonymous ?? false); + const object = await resolver.resolve(uri, ps.allowAnonymous ?? false); if (ps.expandCollectionItems && isCollectionOrOrderedCollection(object)) { const items = await resolver.resolveCollectionItems(object, ps.expandCollectionLimit, ps.allowAnonymous ?? false); diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index eaf3620f6f..5196cd4ebe 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -231,6 +231,12 @@ SPDX-License-Identifier: AGPL-3.0-only + @@ -238,6 +244,12 @@ SPDX-License-Identifier: AGPL-3.0-only + @@ -245,7 +257,12 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -437,12 +454,15 @@ function createFetcher(withHint = true) { (withHint && props.infoHint) ? props.infoHint : misskeyApi('admin/show-user', { userId: props.userId, }), - (withHint && props.ipsHint) ? props.ipsHint : misskeyApi('admin/get-user-ips', { - userId: props.userId, - }), - (withHint && props.apHint) ? props.apHint : misskeyApi('ap/get', { - userId: props.userId, - }).catch(() => null)], + iAmAdmin + ? (withHint && props.ipsHint) ? props.ipsHint : misskeyApi('admin/get-user-ips', { + userId: props.userId, + }) + : null, + iAmAdmin + ? (withHint && props.apHint) ? props.apHint : misskeyApi('ap/get', { + userId: props.userId, + }).catch(() => null) : null], ).then(async ([_user, _info, _ips, _ap]) => { user.value = _user; info.value = _info; @@ -902,4 +922,13 @@ definePage(() => ({ margin: calc(var(--MI-margin) / 2); } } + +.rawFolderHeader { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: flex-start; + padding: var(--MI-marginHalf); + gap: var(--MI-marginHalf); +} diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index b1d5f63a8b..82d18e2404 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -12922,7 +12922,11 @@ export type operations = { requestBody: { content: { 'application/json': { - uri: string; + uri?: string | null; + /** Format: misskey:id */ + userId?: string | null; + /** Format: misskey:id */ + noteId?: string | null; expandCollectionItems?: boolean; expandCollectionLimit?: number | null; allowAnonymous?: boolean; diff --git a/sharkey-locales/en-US.yml b/sharkey-locales/en-US.yml index 8ce2b8f01c..5ea562d262 100644 --- a/sharkey-locales/en-US.yml +++ b/sharkey-locales/en-US.yml @@ -624,3 +624,7 @@ keepCwEnabled: "Enabled (copy CWs verbatim)" keepCwPrependRe: "Enabled (copy CW and prepend \"RE:\")" noteFooterLabel: "Note controls" + +rawUserDescription: "Packed user data in its raw form. Most of these fields are public and visible to all users." +rawInfoDescription: "Extended user data in its raw form. These fields are private and can only be accessed by moderators." +rawApDescription: "ActivityPub user data in its raw form. These fields are public and accessible to other instances."