diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index e52bfbd2c52d..0d2f4dc629c5 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -201,6 +201,28 @@ export class UserFollowingService implements OnModuleInit { }); if (isFollowed) autoAccept = true; + + // フォローリクエストを承認された側(送信者)の履歴 + if (this.userEntityService.isLocalUser(follower)) { + await this.followRequestHistoryRepository.insert({ + id: this.idService.gen(), + type: 'wasApproved', + fromUserId: follower.id, + toUserId: followee.id, + timestamp: new Date(), + }); + } + + // フォローリクエストを承認した側(受信者)の履歴 + if (this.userEntityService.isLocalUser(followee)) { + await this.followRequestHistoryRepository.insert({ + id: this.idService.gen(), + type: 'approved', + fromUserId: follower.id, + toUserId: followee.id, + timestamp: new Date(), + }); + } } // Automatically accept if the follower is an account who has moved and the locked followee had accepted the old account. diff --git a/packages/backend/src/server/api/endpoints/following/history.ts b/packages/backend/src/server/api/endpoints/following/history.ts index 14cdfd410690..c9698d7237cf 100644 --- a/packages/backend/src/server/api/endpoints/following/history.ts +++ b/packages/backend/src/server/api/endpoints/following/history.ts @@ -37,12 +37,10 @@ export const meta = { fromUser: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailedNotMe', }, toUser: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailedNotMe', }, timestamp: { type: 'string', @@ -199,8 +197,12 @@ export default class extends Endpoint { return await Promise.all(histories.map(async history => ({ id: history.id, type: history.type, - fromUser: await this.userEntityService.pack(history.fromUser ?? history.fromUserId, me, { schema: 'UserDetailed' }), - toUser: await this.userEntityService.pack(history.toUser ?? history.toUserId, me, { schema: 'UserDetailed' }), + fromUser: history.fromUser + ? await this.userEntityService.pack(history.fromUser ?? history.fromUserId, me) + : { name: 'unknown user' }, + toUser: history.toUser + ? await this.userEntityService.pack(history.toUser ?? history.toUserId, me) + : { name: 'unknown user' }, timestamp: history.timestamp.toISOString(), }))); }); diff --git a/packages/backend/src/server/api/endpoints/following/requests/history.ts b/packages/backend/src/server/api/endpoints/following/requests/history.ts index efb3816890a8..f2a33e86c3c4 100644 --- a/packages/backend/src/server/api/endpoints/following/requests/history.ts +++ b/packages/backend/src/server/api/endpoints/following/requests/history.ts @@ -37,12 +37,10 @@ export const meta = { fromUser: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailedNotMe', }, toUser: { type: 'object', optional: false, nullable: false, - ref: 'UserDetailedNotMe', }, timestamp: { type: 'string', @@ -200,8 +198,12 @@ export default class extends Endpoint { return await Promise.all(histories.map(async history => ({ id: history.id, type: history.type, - fromUser: await this.userEntityService.pack(history.fromUser ?? history.fromUserId, me, { schema: 'UserDetailed' }), - toUser: await this.userEntityService.pack(history.toUser ?? history.toUserId, me, { schema: 'UserDetailed' }), + fromUser: history.fromUser + ? await this.userEntityService.pack(history.fromUser ?? history.fromUserId, me) + : { name: 'unknown user' }, + toUser: history.toUser + ? await this.userEntityService.pack(history.toUser ?? history.toUserId, me) + : { name: 'unknown user' }, timestamp: history.timestamp.toISOString(), }))); }); diff --git a/packages/frontend/src/pages/follow-history.vue b/packages/frontend/src/pages/follow-history.vue index 5025b937c913..f5b1d841f702 100644 --- a/packages/frontend/src/pages/follow-history.vue +++ b/packages/frontend/src/pages/follow-history.vue @@ -19,17 +19,41 @@ SPDX-License-Identifier: AGPL-3.0-only