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 lines283284285286287288289290291292293294295296297298299300282 unmodified linespublic 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>();var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId);return 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});}public async Task<bool> RevokeShareAsync(Guid graphId, Guid ownerId, Guid shareId)282 unmodified lines283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328282 unmodified linespublic async Task<IEnumerable<SharedUserResponseDto>> GetSharedUsersAsync(Guid graphId, Guid ownerId){var graph = await _repo.GetByIdAsync(graphId);if (graph is null) return Enumerable.Empty<SharedUserResponseDto>();// Allow access to shares list if caller is the owner or a guest with accessif (graph.UserId != ownerId){var shareAccess = await _sharedGraphRepo.GetShareAsync(graphId, ownerId);if (shareAccess is null) return Enumerable.Empty<SharedUserResponseDto>();}var result = new List<SharedUserResponseDto>();// Get owner detailsvar 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 usersvar 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}));}return result;}public async Task<bool> RevokeShareAsync(Guid graphId, Guid ownerId, Guid shareId)
FlowAPI.Application/Services/GraphService.cs+37-9