1
0
mirror of https://github.com/bitwarden/server synced 2026-02-21 11:53:42 +00:00

First pass at semaphore

This commit is contained in:
Thomas Rittson
2025-12-30 14:21:38 +10:00
parent 34b4dc3985
commit f069fafea1
13 changed files with 785 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
namespace Bit.Core.Entities;
public class DefaultCollectionSemaphore
{
public Guid OrganizationId { get; set; }
public Guid OrganizationUserId { get; set; }
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
}

View File

@@ -65,10 +65,21 @@ public interface ICollectionRepository : IRepository<Collection, Guid>
/// <summary>
/// Creates default user collections for the specified organization users if they do not already have one.
/// Uses the stored procedure approach with semaphore-based duplicate prevention.
/// </summary>
/// <param name="organizationId">The Organization ID.</param>
/// <param name="organizationUserIds">The Organization User IDs to create default collections for.</param>
/// <param name="defaultCollectionName">The encrypted string to use as the default collection name.</param>
/// <returns></returns>
Task UpsertDefaultCollectionsAsync(Guid organizationId, IEnumerable<Guid> organizationUserIds, string defaultCollectionName);
/// <summary>
/// Creates default user collections for the specified organization users using bulk insert operations.
/// Inserts semaphore entries before collections to prevent duplicates.
/// </summary>
/// <param name="organizationId">The Organization ID.</param>
/// <param name="organizationUserIds">The Organization User IDs to create default collections for.</param>
/// <param name="defaultCollectionName">The encrypted string to use as the default collection name.</param>
/// <returns></returns>
Task UpsertDefaultCollectionsBulkAsync(Guid organizationId, IEnumerable<Guid> organizationUserIds, string defaultCollectionName);
}