1
0
mirror of https://github.com/bitwarden/server synced 2025-12-25 04:33:26 +00:00

[PM-328] Move files for team-tools (#2857)

* Extract Import-Api endpoints into separate controller

Moved ciphers/import and ciphers/import-organization into new ImportController
Paths have been kept intact for now (no changes on clients needed)
Moved request-models used for import into tools-subfolder

* Update CODEOWNERS for team-tools-dev

* Move HibpController (reports) to tools

* Moving files related to Send

* Moving files related to ReferenceEvent

* Removed unneeded newline
This commit is contained in:
Daniel James Smith
2023-04-18 14:05:17 +02:00
committed by GitHub
parent baec7745f7
commit 4e7b9d2edd
91 changed files with 292 additions and 178 deletions

View File

@@ -2,10 +2,12 @@
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.SecretsManager.Repositories;
using Bit.Core.Tools.Repositories;
using Bit.Core.Vault.Repositories;
using Bit.Infrastructure.EntityFramework.Auth.Repositories;
using Bit.Infrastructure.EntityFramework.Repositories;
using Bit.Infrastructure.EntityFramework.SecretsManager.Repositories;
using Bit.Infrastructure.EntityFramework.Tools.Repositories;
using Bit.Infrastructure.EntityFramework.Vault.Repositories;
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

View File

@@ -2,7 +2,7 @@
namespace Bit.Infrastructure.EntityFramework.Models;
public class Send : Core.Entities.Send
public class Send : Core.Tools.Entities.Send
{
public virtual Organization Organization { get; set; }
public virtual User User { get; set; }
@@ -12,6 +12,6 @@ public class SendMapperProfile : Profile
{
public SendMapperProfile()
{
CreateMap<Core.Entities.Send, Send>().ReverseMap();
CreateMap<Core.Tools.Entities.Send, Send>().ReverseMap();
}
}

View File

@@ -1,18 +1,19 @@
using AutoMapper;
using Bit.Core.Repositories;
using Bit.Core.Tools.Repositories;
using Bit.Infrastructure.EntityFramework.Models;
using Bit.Infrastructure.EntityFramework.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.Repositories;
namespace Bit.Infrastructure.EntityFramework.Tools.Repositories;
public class SendRepository : Repository<Core.Entities.Send, Send, Guid>, ISendRepository
public class SendRepository : Repository<Core.Tools.Entities.Send, Send, Guid>, ISendRepository
{
public SendRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
: base(serviceScopeFactory, mapper, (DatabaseContext context) => context.Sends)
{ }
public override async Task<Core.Entities.Send> CreateAsync(Core.Entities.Send send)
public override async Task<Core.Tools.Entities.Send> CreateAsync(Core.Tools.Entities.Send send)
{
send = await base.CreateAsync(send);
using (var scope = ServiceScopeFactory.CreateScope())
@@ -29,23 +30,23 @@ public class SendRepository : Repository<Core.Entities.Send, Send, Guid>, ISendR
return send;
}
public async Task<ICollection<Core.Entities.Send>> GetManyByDeletionDateAsync(DateTime deletionDateBefore)
public async Task<ICollection<Core.Tools.Entities.Send>> GetManyByDeletionDateAsync(DateTime deletionDateBefore)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.Sends.Where(s => s.DeletionDate < deletionDateBefore).ToListAsync();
return Mapper.Map<List<Core.Entities.Send>>(results);
return Mapper.Map<List<Core.Tools.Entities.Send>>(results);
}
}
public async Task<ICollection<Core.Entities.Send>> GetManyByUserIdAsync(Guid userId)
public async Task<ICollection<Core.Tools.Entities.Send>> GetManyByUserIdAsync(Guid userId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var results = await dbContext.Sends.Where(s => s.UserId == userId).ToListAsync();
return Mapper.Map<List<Core.Entities.Send>>(results);
return Mapper.Map<List<Core.Tools.Entities.Send>>(results);
}
}
}

View File

@@ -771,7 +771,7 @@ public class CipherRepository : Repository<Core.Vault.Entities.Cipher, Cipher, G
}
}
public async Task UpdateUserKeysAndCiphersAsync(User user, IEnumerable<Core.Vault.Entities.Cipher> ciphers, IEnumerable<Core.Vault.Entities.Folder> folders, IEnumerable<Core.Entities.Send> sends)
public async Task UpdateUserKeysAndCiphersAsync(User user, IEnumerable<Core.Vault.Entities.Cipher> ciphers, IEnumerable<Core.Vault.Entities.Folder> folders, IEnumerable<Core.Tools.Entities.Send> sends)
{
using (var scope = ServiceScopeFactory.CreateScope())
{