Spaces:
Running
Running
Commit ·
16d5815
1
Parent(s): 03ee889
fix: allow collaborators to get graph shares and prepend graph owner to list of collaborators
Browse files282 unmodified lines283284285286286287288288289290291292293294295296290297298299300301302303304305306307308309310311312313314315316292293294295296297317318319320321322323324325326327328282 unmodified lines public async Task<IEnumerable<SharedUserResponseDto>> GetSharedUsersAsync(Guid graphId, Guid ownerId) { var graph = await _repo.GetByIdAsync(graphId); if (graph is null || graph.UserId != ownerId) return Enumerable.Empty<SharedUserResponseDto>(); if (graph is null) return Enumerable.Empty<SharedUserResponseDto>();
var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId); // Allow access to shares list if caller is the owner or a guest with access if (graph.UserId != ownerId) { var shareAccess = await _sharedGraphRepo.GetShareAsync(graphId, ownerId); if (shareAccess is null) return Enumerable.Empty<SharedUserResponseDto>(); }
var result = new List<SharedUserResponseDto>();
return shares.Select(s => new SharedUserResponseDto // Get owner details var owner = await _userRepo.GetByIdAsync(graph.UserId); if (owner is not null) { result.Add(new SharedUserResponseDto { Id = Guid.Empty, SharedWithUserId = owner.Id, Email = owner.Email, DisplayName = owner.DisplayName, Permission = "Owner" }); }
// Get shared users var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId); if (shares is not null) { result.AddRange(shares.Select(s => new SharedUserResponseDto { Id = s.Id, SharedWithUserId = s.SharedWithUserId, Email = s.SharedWithUser?.Email ?? string.Empty, DisplayName = s.SharedWithUser?.DisplayName ?? string.Empty, Permission = s.Permission }); Id = s.Id, SharedWithUserId = s.SharedWithUserId, Email = s.SharedWithUser?.Email ?? string.Empty, DisplayName = s.SharedWithUser?.DisplayName ?? string.Empty, Permission = s.Permission })); }
return result; }
public async Task<bool> RevokeShareAsync(Guid graphId, Guid ownerId, Guid shareId)FlowAPI.Application/Services/GraphService.cs+37-9