mirror of
https://github.com/bitwarden/server
synced 2025-12-25 12:43:14 +00:00
remove old share solution code
This commit is contained in:
@@ -7,7 +7,6 @@ using DataTableProxy;
|
||||
using Bit.Core.Domains;
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
@@ -32,19 +31,6 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
return cipher;
|
||||
}
|
||||
|
||||
public async Task<CipherShare> GetShareByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherShare>(
|
||||
$"[{Schema}].[CipherShare_ReadById]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.FirstOrDefault(c => c.UserId == userId);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Cipher>> GetManyByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
@@ -58,19 +44,6 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<CipherShare>> GetManyShareByUserIdAsync(Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherShare>(
|
||||
$"[{Schema}].[CipherShare_ReadByUserId]",
|
||||
new { UserId = userId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Cipher>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
@@ -88,23 +61,6 @@ namespace Bit.Core.Repositories.SqlServer
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<CipherShare>> GetManyShareByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<CipherShare>(
|
||||
$"[{Schema}].[CipherShare_ReadByTypeUserId]",
|
||||
new
|
||||
{
|
||||
Type = type,
|
||||
UserId = userId
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Tuple<ICollection<Cipher>, ICollection<Guid>>>
|
||||
GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId)
|
||||
{
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using Dapper;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
public class ShareRepository : Repository<Share, Guid>, IShareRepository
|
||||
{
|
||||
public ShareRepository(GlobalSettings globalSettings)
|
||||
: this(globalSettings.SqlServer.ConnectionString)
|
||||
{ }
|
||||
|
||||
public ShareRepository(string connectionString)
|
||||
: base(connectionString)
|
||||
{ }
|
||||
|
||||
public async Task<Share> GetByIdAsync(Guid id, Guid userId)
|
||||
{
|
||||
var share = await GetByIdAsync(id);
|
||||
if(share == null || (share.UserId != userId && share.SharerUserId != userId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return share;
|
||||
}
|
||||
|
||||
public async Task<ICollection<Share>> GetManyByCipherId(Guid cipherId)
|
||||
{
|
||||
using(var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Share>(
|
||||
$"[{Schema}].[Share_ReadByCipherId]",
|
||||
new { CipherId = cipherId },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user