feat: quotas
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
namespace MemeVault.Domain.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Пользователь достиг лимита пользовательских коллекций (Owner).
|
||||
/// </summary>
|
||||
public sealed class CollectionQuotaExceededException : DomainException
|
||||
{
|
||||
public int Limit { get; }
|
||||
|
||||
public CollectionQuotaExceededException(int limit)
|
||||
: base($"Cannot create more than {limit} collections.")
|
||||
{
|
||||
Limit = limit;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace MemeVault.Domain.Exceptions;
|
||||
|
||||
public sealed class DomainException : Exception
|
||||
public class DomainException : Exception
|
||||
{
|
||||
public DomainException(string message) : base(message) { }
|
||||
public DomainException(string message, Exception inner) : base(message, inner) { }
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace MemeVault.Domain.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Коллекция достигла лимита медиа-элементов.
|
||||
/// </summary>
|
||||
public sealed class MediaInCollectionQuotaExceededException : DomainException
|
||||
{
|
||||
public int Limit { get; }
|
||||
|
||||
public MediaInCollectionQuotaExceededException(int limit)
|
||||
: base($"Collection has reached the limit of {limit} items.")
|
||||
{
|
||||
Limit = limit;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,9 @@ public interface IMediaItemRepository
|
||||
bool includeNsfw = true,
|
||||
CancellationToken ct = default);
|
||||
|
||||
/// <summary>Количество элементов в указанной коллекции.</summary>
|
||||
Task<int> CountByCollectionAsync(Guid collectionId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Количество элементов в каждой из указанных коллекций за один запрос.</summary>
|
||||
Task<Dictionary<Guid, int>> GetCountsByCollectionIdsAsync(
|
||||
IReadOnlyList<Guid> collectionIds, CancellationToken ct = default);
|
||||
|
||||
Reference in New Issue
Block a user