Spaces:
Running
Running
Commit ·
d479e18
1
Parent(s): 9a61fc7
fix(agent-canvas): share claimed canvas back to system agent with Edit permission automatically
Browse files20 unmodified lines2122232425261 unmodified line282930313233343536373839185 unmodified lines22522622722822923020 unmodified linesprivate readonly ITokenService _tokenService;private readonly IUserRepository _userRepo;private readonly IGraphRepository _graphRepo;private readonly IConfiguration _config;public AgentCanvasController(1 unmodified lineITokenService tokenService,IUserRepository userRepo,IGraphRepository graphRepo,IConfiguration config){_graphService = graphService;_tokenService = tokenService;_userRepo = userRepo;_graphRepo = graphRepo;_config = config;}185 unmodified linesdbGraph.UserId = CurrentUserId;await _graphRepo.UpdateAsync(dbGraph);return Ok(new { success = true, graphId = graphId.Value });}catch (Exception ex)20 unmodified lines212223242526271 unmodified line2930313233343536373839404142185 unmodified lines22822923023123223323423523623723823924024124224324424524624724824920 unmodified linesprivate readonly ITokenService _tokenService;private readonly IUserRepository _userRepo;private readonly IGraphRepository _graphRepo;private readonly ISharedGraphRepository _sharedGraphRepo;private readonly IConfiguration _config;public AgentCanvasController(1 unmodified lineITokenService tokenService,IUserRepository userRepo,IGraphRepository graphRepo,ISharedGraphRepository sharedGraphRepo,IConfiguration config){_graphService = graphService;_tokenService = tokenService;_userRepo = userRepo;_graphRepo = graphRepo;_sharedGraphRepo = sharedGraphRepo;_config = config;}185 unmodified linesdbGraph.UserId = CurrentUserId;await _graphRepo.UpdateAsync(dbGraph);// Dynamically ensure that the system agent user gets granted Edit permission,// allowing the agent's JWT token to retain full write/read access to the board!var existingShare = await _sharedGraphRepo.GetShareAsync(graphId.Value, agentId);if (existingShare == null){var share = new SharedGraph{Id = Guid.NewGuid(),GraphId = graphId.Value,SharedWithUserId = agentId,Permission = "Edit",CreatedAt = DateTime.UtcNow};await _sharedGraphRepo.CreateAsync(share);}return Ok(new { success = true, graphId = graphId.Value });}catch (Exception ex)
FlowAPI/Controllers/AgentCanvasController.cs+19