🐛 Trying to fix develop
This commit is contained in:
@@ -16,7 +16,7 @@ namespace DysonNetwork.Develop.Identity;
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class BotAccountController(
|
public class BotAccountController(
|
||||||
BotAccountService botService,
|
BotAccountService botService,
|
||||||
DeveloperService developerService,
|
DeveloperService ds,
|
||||||
DevProjectService projectService,
|
DevProjectService projectService,
|
||||||
ILogger<BotAccountController> logger,
|
ILogger<BotAccountController> logger,
|
||||||
AccountClientHelper accounts,
|
AccountClientHelper accounts,
|
||||||
@@ -83,11 +83,11 @@ public class BotAccountController(
|
|||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer is null)
|
if (developer is null)
|
||||||
return NotFound("Developer not found");
|
return NotFound("Developer not found");
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
||||||
Shared.Proto.PublisherMemberRole.Viewer))
|
Shared.Proto.PublisherMemberRole.Viewer))
|
||||||
return StatusCode(403, "You must be an viewer of the developer to list bots");
|
return StatusCode(403, "You must be an viewer of the developer to list bots");
|
||||||
|
|
||||||
@@ -108,11 +108,11 @@ public class BotAccountController(
|
|||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer is null)
|
if (developer is null)
|
||||||
return NotFound("Developer not found");
|
return NotFound("Developer not found");
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
||||||
Shared.Proto.PublisherMemberRole.Viewer))
|
Shared.Proto.PublisherMemberRole.Viewer))
|
||||||
return StatusCode(403, "You must be an viewer of the developer to view bot details");
|
return StatusCode(403, "You must be an viewer of the developer to view bot details");
|
||||||
|
|
||||||
@@ -137,11 +137,11 @@ public class BotAccountController(
|
|||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer is null)
|
if (developer is null)
|
||||||
return NotFound("Developer not found");
|
return NotFound("Developer not found");
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
||||||
Shared.Proto.PublisherMemberRole.Editor))
|
Shared.Proto.PublisherMemberRole.Editor))
|
||||||
return StatusCode(403, "You must be an editor of the developer to create a bot");
|
return StatusCode(403, "You must be an editor of the developer to create a bot");
|
||||||
|
|
||||||
@@ -206,11 +206,11 @@ public class BotAccountController(
|
|||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer is null)
|
if (developer is null)
|
||||||
return NotFound("Developer not found");
|
return NotFound("Developer not found");
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
||||||
Shared.Proto.PublisherMemberRole.Editor))
|
Shared.Proto.PublisherMemberRole.Editor))
|
||||||
return StatusCode(403, "You must be an editor of the developer to update a bot");
|
return StatusCode(403, "You must be an editor of the developer to update a bot");
|
||||||
|
|
||||||
@@ -267,11 +267,11 @@ public class BotAccountController(
|
|||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer is null)
|
if (developer is null)
|
||||||
return NotFound("Developer not found");
|
return NotFound("Developer not found");
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id),
|
||||||
Shared.Proto.PublisherMemberRole.Editor))
|
Shared.Proto.PublisherMemberRole.Editor))
|
||||||
return StatusCode(403, "You must be an editor of the developer to delete a bot");
|
return StatusCode(403, "You must be an editor of the developer to delete a bot");
|
||||||
|
|
||||||
@@ -443,10 +443,10 @@ public class BotAccountController(
|
|||||||
Account currentUser,
|
Account currentUser,
|
||||||
Shared.Proto.PublisherMemberRole requiredRole)
|
Shared.Proto.PublisherMemberRole requiredRole)
|
||||||
{
|
{
|
||||||
var developer = await developerService.GetDeveloperByName(pubName);
|
var developer = await ds.GetDeveloperByName(pubName);
|
||||||
if (developer == null) return (null, null, null);
|
if (developer == null) return (null, null, null);
|
||||||
|
|
||||||
if (!await developerService.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id), requiredRole))
|
if (!await ds.IsMemberWithRole(developer.PublisherId, Guid.Parse(currentUser.Id), requiredRole))
|
||||||
return (null, null, null);
|
return (null, null, null);
|
||||||
|
|
||||||
var project = await projectService.GetProjectAsync(projectId, developer.Id);
|
var project = await projectService.GetProjectAsync(projectId, developer.Id);
|
||||||
|
@@ -155,9 +155,8 @@ public class BotAccountService(
|
|||||||
public async Task<SnBotAccount?> LoadBotAccountAsync(SnBotAccount bot) =>
|
public async Task<SnBotAccount?> LoadBotAccountAsync(SnBotAccount bot) =>
|
||||||
(await LoadBotsAccountAsync([bot])).FirstOrDefault();
|
(await LoadBotsAccountAsync([bot])).FirstOrDefault();
|
||||||
|
|
||||||
public async Task<List<SnBotAccount>> LoadBotsAccountAsync(IEnumerable<SnBotAccount> bots)
|
public async Task<List<SnBotAccount>> LoadBotsAccountAsync(List<SnBotAccount> bots)
|
||||||
{
|
{
|
||||||
bots = [.. bots];
|
|
||||||
var automatedIds = bots.Select(b => b.Id).ToList();
|
var automatedIds = bots.Select(b => b.Id).ToList();
|
||||||
var data = await accounts.GetBotAccountBatch(automatedIds);
|
var data = await accounts.GetBotAccountBatch(automatedIds);
|
||||||
|
|
||||||
@@ -168,6 +167,6 @@ public class BotAccountService(
|
|||||||
.FirstOrDefault(e => e.AutomatedId == bot.Id);
|
.FirstOrDefault(e => e.AutomatedId == bot.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bots as List<SnBotAccount> ?? [];
|
return bots;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user