From 768ba098248cbdca2935968441831bf3bd64e2dc Mon Sep 17 00:00:00 2001 From: Cyrus AI Date: Thu, 16 Oct 2025 19:20:56 +0000 Subject: [PATCH] refactor: use existing callerDid instead of redundant callingUserId Cleaned up controllers to use the existing callerDid variable directly instead of creating redundant callingUserId variables. This improves code consistency and reduces duplication. Changes: - GetMyUrlCardsController: Renamed userId to callerDid for consistency - GetUserUrlCardsController: Use callerDid instead of callingUserId - GetCollectionPageController: Removed duplicate callerDid parameter - GetCollectionPageByAtUriController: Removed duplicate callerDid parameter - GetUrlCardViewController: Removed duplicate callerDid parameter - GetGlobalFeedController: Use callerDid instead of callingUserId --- .../controllers/GetCollectionPageByAtUriController.ts | 1 - .../http/controllers/GetCollectionPageController.ts | 1 - .../http/controllers/GetMyUrlCardsController.ts | 8 ++++---- .../http/controllers/GetUrlCardViewController.ts | 1 - .../http/controllers/GetUserUrlCardsController.ts | 4 ++-- .../http/controllers/GetGlobalFeedController.ts | 4 ++-- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/modules/cards/infrastructure/http/controllers/GetCollectionPageByAtUriController.ts b/src/modules/cards/infrastructure/http/controllers/GetCollectionPageByAtUriController.ts index 25154eee..a9d81e22 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetCollectionPageByAtUriController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetCollectionPageByAtUriController.ts @@ -23,7 +23,6 @@ export class GetCollectionPageByAtUriController extends Controller { const result = await this.getCollectionPageByAtUriUseCase.execute({ handle, recordKey, - callerDid, callingUserId: callerDid, page: page ? parseInt(page as string) : undefined, limit: limit ? parseInt(limit as string) : undefined, diff --git a/src/modules/cards/infrastructure/http/controllers/GetCollectionPageController.ts b/src/modules/cards/infrastructure/http/controllers/GetCollectionPageController.ts index caf700c7..be7cadd8 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetCollectionPageController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetCollectionPageController.ts @@ -21,7 +21,6 @@ export class GetCollectionPageController extends Controller { const result = await this.getCollectionPageUseCase.execute({ collectionId, - callerDid, callingUserId: callerDid, page: page ? parseInt(page as string) : undefined, limit: limit ? parseInt(limit as string) : undefined, diff --git a/src/modules/cards/infrastructure/http/controllers/GetMyUrlCardsController.ts b/src/modules/cards/infrastructure/http/controllers/GetMyUrlCardsController.ts index c248f6d2..6f2ef281 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetMyUrlCardsController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetMyUrlCardsController.ts @@ -11,16 +11,16 @@ export class GetMyUrlCardsController extends Controller { async executeImpl(req: AuthenticatedRequest, res: Response): Promise { try { - const userId = req.did; + const callerDid = req.did; const { page, limit, sortBy, sortOrder } = req.query; - if (!userId) { + if (!callerDid) { return this.unauthorized(res); } const result = await this.getUrlCardsUseCase.execute({ - userId, - callingUserId: userId, + userId: callerDid, + callingUserId: callerDid, page: page ? parseInt(page as string) : undefined, limit: limit ? parseInt(limit as string) : undefined, sortBy: sortBy as CardSortField, diff --git a/src/modules/cards/infrastructure/http/controllers/GetUrlCardViewController.ts b/src/modules/cards/infrastructure/http/controllers/GetUrlCardViewController.ts index 68675f0c..b092894a 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetUrlCardViewController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetUrlCardViewController.ts @@ -19,7 +19,6 @@ export class GetUrlCardViewController extends Controller { const result = await this.getUrlCardViewUseCase.execute({ cardId, - callerDid, callingUserId: callerDid, }); diff --git a/src/modules/cards/infrastructure/http/controllers/GetUserUrlCardsController.ts b/src/modules/cards/infrastructure/http/controllers/GetUserUrlCardsController.ts index b068e0a4..653c6e8c 100644 --- a/src/modules/cards/infrastructure/http/controllers/GetUserUrlCardsController.ts +++ b/src/modules/cards/infrastructure/http/controllers/GetUserUrlCardsController.ts @@ -13,7 +13,7 @@ export class GetUserUrlCardsController extends Controller { try { const { identifier } = req.params; const { page, limit, sortBy, sortOrder } = req.query; - const callingUserId = req.did; + const callerDid = req.did; if (!identifier) { return this.fail(res, 'Identifier (DID or handle) is required'); @@ -21,7 +21,7 @@ export class GetUserUrlCardsController extends Controller { const result = await this.getUrlCardsUseCase.execute({ userId: identifier, - callingUserId, + callingUserId: callerDid, page: page ? parseInt(page as string) : undefined, limit: limit ? parseInt(limit as string) : undefined, sortBy: sortBy as CardSortField, diff --git a/src/modules/feeds/infrastructure/http/controllers/GetGlobalFeedController.ts b/src/modules/feeds/infrastructure/http/controllers/GetGlobalFeedController.ts index a7c2ad95..fbb5a830 100644 --- a/src/modules/feeds/infrastructure/http/controllers/GetGlobalFeedController.ts +++ b/src/modules/feeds/infrastructure/http/controllers/GetGlobalFeedController.ts @@ -13,10 +13,10 @@ export class GetGlobalFeedController extends Controller { const page = parseInt(req.query.page as string) || 1; const limit = parseInt(req.query.limit as string) || 20; const beforeActivityId = req.query.beforeActivityId as string; - const callingUserId = req.did; + const callerDid = req.did; const result = await this.getGlobalFeedUseCase.execute({ - callingUserId, + callingUserId: callerDid, page, limit, beforeActivityId, -- 2.51.2