Account status GRPC API

This commit is contained in:
2025-08-17 22:30:11 +08:00
parent 8e8965eb3d
commit aa9ae5c11e
3 changed files with 109 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ namespace DysonNetwork.Pass.Account;
public class AccountServiceGrpc(
AppDatabase db,
AccountEventService accountEvents,
RelationshipService relationships,
SubscriptionService subscriptions,
IClock clock,
@@ -68,6 +69,26 @@ public class AccountServiceGrpc(
return response;
}
public override async Task<AccountStatus> GetAccountStatus(GetAccountRequest request, ServerCallContext context)
{
var accountId = Guid.Parse(request.Id);
var status = await accountEvents.GetStatus(accountId);
return status.ToProtoValue();
}
public override async Task<GetAccountStatusBatchResponse> GetAccountStatusBatch(GetAccountBatchRequest request, ServerCallContext context)
{
var accountIds = request.Id
.Select(id => Guid.TryParse(id, out var accountId) ? accountId : (Guid?)null)
.Where(id => id.HasValue)
.Select(id => id!.Value)
.ToList();
var statuses = await accountEvents.GetStatuses(accountIds);
var response = new GetAccountStatusBatchResponse();
response.Statuses.AddRange(statuses.Select(s => s.Value.ToProtoValue()));
return response;
}
public override async Task<GetAccountBatchResponse> LookupAccountBatch(LookupAccountBatchRequest request,
ServerCallContext context)
{