mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
return share information with cipher API response
This commit is contained in:
8
src/Core/Enums/SharePermissionType.cs
Normal file
8
src/Core/Enums/SharePermissionType.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Bit.Core.Enums
|
||||
{
|
||||
public enum SharePermissionType : byte
|
||||
{
|
||||
Reshare = 0,
|
||||
Edit = 1
|
||||
}
|
||||
}
|
11
src/Core/Models/Data/CipherShare.cs
Normal file
11
src/Core/Models/Data/CipherShare.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class CipherShare : Cipher
|
||||
{
|
||||
public string Key { get; internal set; }
|
||||
public string Permissions { get; internal set; }
|
||||
public Enums.ShareStatusType? Status { get; internal set; }
|
||||
}
|
||||
}
|
@ -2,13 +2,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Domains;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Repositories
|
||||
{
|
||||
public interface ICipherRepository : IRepository<Cipher, Guid>
|
||||
{
|
||||
Task<Cipher> GetByIdAsync(Guid id, Guid userId);
|
||||
Task<CipherShare> GetShareByIdAsync(Guid id, Guid userId);
|
||||
Task<ICollection<Cipher>> GetManyByUserIdAsync(Guid userId);
|
||||
Task<ICollection<CipherShare>> GetManyShareByUserIdAsync(Guid userId);
|
||||
Task<ICollection<Cipher>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId);
|
||||
Task<Tuple<ICollection<Cipher>, ICollection<Guid>>>
|
||||
GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId);
|
||||
|
@ -7,6 +7,7 @@ using DataTableProxy;
|
||||
using Bit.Core.Domains;
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Repositories.SqlServer
|
||||
{
|
||||
@ -31,6 +32,19 @@ 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))
|
||||
@ -44,6 +58,19 @@ 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))
|
||||
|
Reference in New Issue
Block a user