Spaces:
Sleeping
Sleeping
Commit ·
16d5815
1
Parent(s): 03ee889
fix: allow collaborators to get graph shares and prepend graph owner to list of collaborators
Browse files
FlowAPI.Application/Services/GraphService.cs
CHANGED
|
@@ -283,18 +283,46 @@ namespace FlowAPI.Application.Services
|
|
| 283 |
public async Task<IEnumerable<SharedUserResponseDto>> GetSharedUsersAsync(Guid graphId, Guid ownerId)
|
| 284 |
{
|
| 285 |
var graph = await _repo.GetByIdAsync(graphId);
|
| 286 |
-
if (graph is null
|
| 287 |
|
| 288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
-
|
|
|
|
|
|
|
| 291 |
{
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
}
|
| 299 |
|
| 300 |
public async Task<bool> RevokeShareAsync(Guid graphId, Guid ownerId, Guid shareId)
|
|
|
|
| 283 |
public async Task<IEnumerable<SharedUserResponseDto>> GetSharedUsersAsync(Guid graphId, Guid ownerId)
|
| 284 |
{
|
| 285 |
var graph = await _repo.GetByIdAsync(graphId);
|
| 286 |
+
if (graph is null) return Enumerable.Empty<SharedUserResponseDto>();
|
| 287 |
|
| 288 |
+
// Allow access to shares list if caller is the owner or a guest with access
|
| 289 |
+
if (graph.UserId != ownerId)
|
| 290 |
+
{
|
| 291 |
+
var shareAccess = await _sharedGraphRepo.GetShareAsync(graphId, ownerId);
|
| 292 |
+
if (shareAccess is null) return Enumerable.Empty<SharedUserResponseDto>();
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
var result = new List<SharedUserResponseDto>();
|
| 296 |
|
| 297 |
+
// Get owner details
|
| 298 |
+
var owner = await _userRepo.GetByIdAsync(graph.UserId);
|
| 299 |
+
if (owner is not null)
|
| 300 |
{
|
| 301 |
+
result.Add(new SharedUserResponseDto
|
| 302 |
+
{
|
| 303 |
+
Id = Guid.Empty,
|
| 304 |
+
SharedWithUserId = owner.Id,
|
| 305 |
+
Email = owner.Email,
|
| 306 |
+
DisplayName = owner.DisplayName,
|
| 307 |
+
Permission = "Owner"
|
| 308 |
+
});
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
// Get shared users
|
| 312 |
+
var shares = await _sharedGraphRepo.GetSharesForGraphAsync(graphId);
|
| 313 |
+
if (shares is not null)
|
| 314 |
+
{
|
| 315 |
+
result.AddRange(shares.Select(s => new SharedUserResponseDto
|
| 316 |
+
{
|
| 317 |
+
Id = s.Id,
|
| 318 |
+
SharedWithUserId = s.SharedWithUserId,
|
| 319 |
+
Email = s.SharedWithUser?.Email ?? string.Empty,
|
| 320 |
+
DisplayName = s.SharedWithUser?.DisplayName ?? string.Empty,
|
| 321 |
+
Permission = s.Permission
|
| 322 |
+
}));
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
return result;
|
| 326 |
}
|
| 327 |
|
| 328 |
public async Task<bool> RevokeShareAsync(Guid graphId, Guid ownerId, Guid shareId)
|