From b9254b6b020ac6f311fab86fc395ae1aaaddcd11 Mon Sep 17 00:00:00 2001 From: Wesley Finck Date: Tue, 28 Oct 2025 17:28:41 -0700 Subject: [PATCH] pass callerDid for getMyProfile --- .../useCases/queries/GetProfileUseCase.ts | 14 ++++++++++++++ .../http/controllers/GetMyProfileController.ts | 5 ++++- .../http/factories/ControllerFactory.ts | 4 ++-- .../http/factories/UseCaseFactory.ts | 4 ++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/modules/cards/application/useCases/queries/GetProfileUseCase.ts b/src/modules/cards/application/useCases/queries/GetProfileUseCase.ts index 914404ae..b7007d6e 100644 --- a/src/modules/cards/application/useCases/queries/GetProfileUseCase.ts +++ b/src/modules/cards/application/useCases/queries/GetProfileUseCase.ts @@ -6,6 +6,7 @@ import { IIdentityResolutionService } from 'src/modules/atproto/domain/services/ export interface GetMyProfileQuery { userId: string; + callerDid?: string; } export interface GetMyProfileResult { @@ -54,11 +55,24 @@ export class GetProfileUseCase ), ); } + let callerDid = undefined; + if (query.callerDid) { + const callerDidResult = DIDOrHandle.create(query.callerDid); + if (callerDidResult.isErr()) { + return err( + new ValidationError( + `Invalid caller DID: ${callerDidResult.error.message}`, + ), + ); + } + callerDid = callerDidResult.value.value; + } try { // Fetch user profile using the resolved DID const profileResult = await this.profileService.getProfile( didResult.value.value, + callerDid, ); if (profileResult.isErr()) { diff --git a/src/modules/cards/infrastructure/http/controllers/GetMyProfileController.ts b/src/modules/cards/infrastructure/http/controllers/GetMyProfileController.ts index f6749543..70f528f8 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetMyProfileController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetMyProfileController.ts @@ -16,7 +16,10 @@ export class GetMyProfileController extends Controller { return this.unauthorized(res); } - const result = await this.getProfileUseCase.execute({ userId }); + const result = await this.getProfileUseCase.execute({ + userId, + callerDid: req.did, + }); if (result.isErr()) { return this.fail(res, result.error); diff --git a/src/shared/infrastructure/http/factories/ControllerFactory.ts b/src/shared/infrastructure/http/factories/ControllerFactory.ts index f679f023..6a5f6e6a 100644 --- a/src/shared/infrastructure/http/factories/ControllerFactory.ts +++ b/src/shared/infrastructure/http/factories/ControllerFactory.ts @@ -94,10 +94,10 @@ export class ControllerFactory { cookieService, ), getMyProfileController: new GetMyProfileController( - useCases.getMyProfileUseCase, + useCases.getProfileUseCase, ), getUserProfileController: new GetUserProfileController( - useCases.getMyProfileUseCase, + useCases.getProfileUseCase, ), refreshAccessTokenController: new RefreshAccessTokenController( useCases.refreshAccessTokenUseCase, diff --git a/src/shared/infrastructure/http/factories/UseCaseFactory.ts b/src/shared/infrastructure/http/factories/UseCaseFactory.ts index f318ce52..4eeb7dbb 100644 --- a/src/shared/infrastructure/http/factories/UseCaseFactory.ts +++ b/src/shared/infrastructure/http/factories/UseCaseFactory.ts @@ -44,7 +44,7 @@ export interface UseCases { logoutUseCase: LogoutUseCase; initiateOAuthSignInUseCase: InitiateOAuthSignInUseCase; completeOAuthSignInUseCase: CompleteOAuthSignInUseCase; - getMyProfileUseCase: GetProfileUseCase; + getProfileUseCase: GetProfileUseCase; refreshAccessTokenUseCase: RefreshAccessTokenUseCase; generateExtensionTokensUseCase: GenerateExtensionTokensUseCase; // Card use cases @@ -109,7 +109,7 @@ export class UseCaseFactory { repositories.userRepository, services.userAuthService, ), - getMyProfileUseCase: new GetProfileUseCase( + getProfileUseCase: new GetProfileUseCase( services.profileService, services.identityResolutionService, ), -- 2.51.2