refactor: Remove ICurrentUserService dependency from query handlers and update user ID handling logic
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8s

This commit is contained in:
masoodafar-web
2026-02-10 23:01:49 +03:30
parent b42d9e141d
commit d1ca72300d
13 changed files with 77 additions and 95 deletions
@@ -8,6 +8,7 @@ using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkMembershipHistory;
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
using CMSMicroservice.Application.NetworkMembershipCQ.Queries.GetMyNetworkTree;
using CMSMicroservice.Application.Common.Interfaces;
using Mapster;
using CMSMicroservice.Domain.Enums;
@@ -17,13 +18,16 @@ public class NetworkMembershipService : NetworkMembershipContract.NetworkMembers
{
private readonly IDispatchRequestToCQRS _dispatchRequestToCQRS;
private readonly ISender _sender;
private readonly ICurrentUserService _currentUserService;
public NetworkMembershipService(
IDispatchRequestToCQRS dispatchRequestToCQRS,
ISender sender)
ISender sender,
ICurrentUserService currentUserService)
{
_dispatchRequestToCQRS = dispatchRequestToCQRS;
_sender = sender;
_currentUserService = currentUserService;
}
public override async Task<Empty> JoinNetwork(JoinNetworkRequest request, ServerCallContext context)
@@ -128,8 +132,11 @@ public class NetworkMembershipService : NetworkMembershipContract.NetworkMembers
public override async Task<GetMyNetworkStatisticsResponse> GetMyNetworkStatistics(Google.Protobuf.WellKnownTypes.Empty request, ServerCallContext context)
{
// Get statistics for current user's network
var query = new GetNetworkStatisticsQuery { UserId = 0 }; // Will use ICurrentUserService
// Customer endpoint: resolve userId from JWT
if (!long.TryParse(_currentUserService.UserId, out var userId) || userId <= 0)
throw new RpcException(new Status(StatusCode.Unauthenticated, "کاربر احراز هویت نشده است"));
var query = new GetNetworkStatisticsQuery { UserId = userId };
var stats = await _sender.Send(query, context.CancellationToken);
return stats.Adapt<GetMyNetworkStatisticsResponse>();