mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
removed GetManyByRevisionDate access
This commit is contained in:
parent
0d92042e28
commit
d7cb3d47cb
@ -37,19 +37,11 @@ namespace Bit.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("")]
|
[HttpGet("")]
|
||||||
public async Task<ListResponseModel<FolderResponseModel>> Get(DateTime? since = null)
|
public async Task<ListResponseModel<FolderResponseModel>> Get()
|
||||||
{
|
{
|
||||||
ICollection<Folder> folders = null;
|
ICollection<Folder> folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId());
|
||||||
if(since.HasValue)
|
var responses = folders.Select(f => new FolderResponseModel(f));
|
||||||
{
|
return new ListResponseModel<FolderResponseModel>(responses);
|
||||||
folders = await _folderRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ListResponseModel<FolderResponseModel>(folders.Select(f => new FolderResponseModel(f)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("")]
|
[HttpPost("")]
|
||||||
|
@ -42,18 +42,9 @@ namespace Bit.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("")]
|
[HttpGet("")]
|
||||||
public async Task<ListResponseModel<SiteResponseModel>> Get(DateTime? since = null, string[] expand = null)
|
public async Task<ListResponseModel<SiteResponseModel>> Get(string[] expand = null)
|
||||||
{
|
{
|
||||||
ICollection<Site> sites = null;
|
ICollection<Site> sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId());
|
||||||
if(since.HasValue)
|
|
||||||
{
|
|
||||||
sites = await _siteRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
var responses = sites.Select(s => new SiteResponseModel(s)).ToList();
|
var responses = sites.Select(s => new SiteResponseModel(s)).ToList();
|
||||||
await ExpandManyAsync(sites, responses, expand, null);
|
await ExpandManyAsync(sites, responses, expand, null);
|
||||||
return new ListResponseModel<SiteResponseModel>(responses);
|
return new ListResponseModel<SiteResponseModel>(responses);
|
||||||
|
@ -9,6 +9,5 @@ namespace Bit.Core.Repositories
|
|||||||
{
|
{
|
||||||
Task<Folder> GetByIdAsync(string id, string userId);
|
Task<Folder> GetByIdAsync(string id, string userId);
|
||||||
Task<ICollection<Folder>> GetManyByUserIdAsync(string userId);
|
Task<ICollection<Folder>> GetManyByUserIdAsync(string userId);
|
||||||
Task<ICollection<Folder>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,5 @@ namespace Bit.Core.Repositories
|
|||||||
{
|
{
|
||||||
Task<Site> GetByIdAsync(string id, string userId);
|
Task<Site> GetByIdAsync(string id, string userId);
|
||||||
Task<ICollection<Site>> GetManyByUserIdAsync(string userId);
|
Task<ICollection<Site>> GetManyByUserIdAsync(string userId);
|
||||||
Task<ICollection<Site>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer
|
|||||||
return results.Select(f => f.ToDomain()).ToList();
|
return results.Select(f => f.ToDomain()).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ICollection<Folder>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate)
|
|
||||||
{
|
|
||||||
using(var connection = new SqlConnection(ConnectionString))
|
|
||||||
{
|
|
||||||
var results = await connection.QueryAsync<FolderTableModel>(
|
|
||||||
$"[{Schema}].[{Table}_ReadByRevisionDate]",
|
|
||||||
new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate },
|
|
||||||
commandType: CommandType.StoredProcedure);
|
|
||||||
|
|
||||||
return results.Select(f => f.ToDomain()).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer
|
|||||||
return results.Select(s => s.ToDomain()).ToList();
|
return results.Select(s => s.ToDomain()).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ICollection<Site>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate)
|
|
||||||
{
|
|
||||||
using(var connection = new SqlConnection(ConnectionString))
|
|
||||||
{
|
|
||||||
var results = await connection.QueryAsync<SiteTableModel>(
|
|
||||||
$"[{Schema}].[{Table}_ReadByRevisionDate]",
|
|
||||||
new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate },
|
|
||||||
commandType: CommandType.StoredProcedure);
|
|
||||||
|
|
||||||
return results.Select(f => f.ToDomain()).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,5 @@
|
|||||||
<Build Include="dbo\Stored Procedures\Folder_Update.sql" />
|
<Build Include="dbo\Stored Procedures\Folder_Update.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\Cipher_ReadByUserId.sql" />
|
<Build Include="dbo\Stored Procedures\Cipher_ReadByUserId.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\User_UpdateEmailPassword.sql" />
|
<Build Include="dbo\Stored Procedures\User_UpdateEmailPassword.sql" />
|
||||||
<Build Include="dbo\Stored Procedures\Folder_ReadByRevisionDate.sql" />
|
|
||||||
<Build Include="dbo\Stored Procedures\Site_ReadByRevisionDate.sql" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,13 +0,0 @@
|
|||||||
CREATE PROCEDURE [dbo].[Folder_ReadByRevisionDate]
|
|
||||||
@UserId UNIQUEIDENTIFIER,
|
|
||||||
@SinceRevisionDate DATETIME
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
[dbo].[FolderView]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @UserId
|
|
||||||
AND [RevisionDate] >= @SinceRevisionDate
|
|
||||||
END
|
|
@ -1,13 +0,0 @@
|
|||||||
CREATE PROCEDURE [dbo].[Site_ReadByRevisionDate]
|
|
||||||
@UserId UNIQUEIDENTIFIER,
|
|
||||||
@SinceRevisionDate DATETIME
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
[dbo].[SiteView]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @UserId
|
|
||||||
AND [RevisionDate] >= @SinceRevisionDate
|
|
||||||
END
|
|
Loading…
Reference in New Issue
Block a user