admin/show-userで公開鍵(リモートユーザー)/秘密鍵公開鍵ペア(ローカルユーザー)を確認できるように

This commit is contained in:
tamaina 2024-07-20 23:33:11 +09:00
parent 0c9af9a6a5
commit 69bf858bb6
1 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,9 @@ import { RoleService } from '@/core/RoleService.js';
import { RoleEntityService } from '@/core/entities/RoleEntityService.js';
import { IdService } from '@/core/IdService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js';
import { ApDbResolverService } from '@/core/activitypub/ApDbResolverService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { UserKeypairService } from '@/core/UserKeypairService.js';
export const meta = {
tags: ['admin'],
@ -172,6 +175,14 @@ export const meta = {
},
},
},
publicKeys: {
type: 'array',
optional: false, nullable: true,
},
keyPairs: {
type: 'object',
optional: false, nullable: true,
},
},
},
} as const;
@ -199,6 +210,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private roleService: RoleService,
private roleEntityService: RoleEntityService,
private idService: IdService,
private apDbResolverService: ApDbResolverService,
private userEntityService: UserEntityService,
private userKeypairService: UserKeypairService,
) {
super(meta, paramDef, async (ps, me) => {
const [user, profile] = await Promise.all([
@ -251,6 +265,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
expiresAt: a.expiresAt ? a.expiresAt.toISOString() : null,
roleId: a.roleId,
})),
publicKeys: this.userEntityService.isRemoteUser(user) ? await this.apDbResolverService.getPublicKeyByUserId(user.id) : null,
keyPairs: this.userEntityService.isLocalUser(user) ? await this.userKeypairService.getUserKeypair(user.id) : null,
};
});
}