1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-20 19:14:32 -05:00

Add Notes column to OrganizationSponsorships table

This commit is contained in:
Jonas Hendrickx 2025-03-26 10:29:53 +01:00
parent c457b0bb9c
commit bbb109cba8
No known key found for this signature in database
GPG Key ID: C4B27F601CE4317D
26 changed files with 120 additions and 40 deletions

View File

@ -81,7 +81,10 @@ public class OrganizationSponsorshipsController : Controller
var sponsorship = await _createSponsorshipCommand.CreateSponsorshipAsync( var sponsorship = await _createSponsorshipCommand.CreateSponsorshipAsync(
sponsoringOrg, sponsoringOrg,
await _organizationUserRepository.GetByOrganizationAsync(sponsoringOrgId, targetUser), await _organizationUserRepository.GetByOrganizationAsync(sponsoringOrgId, targetUser),
model.PlanSponsorshipType, model.SponsoredEmail, model.FriendlyName); model.PlanSponsorshipType,
model.SponsoredEmail,
model.FriendlyName,
model.Notes);
await _sendSponsorshipOfferCommand.SendSponsorshipOfferAsync(sponsorship, sponsoringOrg.Name); await _sendSponsorshipOfferCommand.SendSponsorshipOfferAsync(sponsorship, sponsoringOrg.Name);
} }

View File

@ -44,7 +44,7 @@ public class SelfHostedOrganizationSponsorshipsController : Controller
await _offerSponsorshipCommand.CreateSponsorshipAsync( await _offerSponsorshipCommand.CreateSponsorshipAsync(
await _organizationRepository.GetByIdAsync(sponsoringOrgId), await _organizationRepository.GetByIdAsync(sponsoringOrgId),
await _organizationUserRepository.GetByOrganizationAsync(sponsoringOrgId, _currentContext.UserId ?? default), await _organizationUserRepository.GetByOrganizationAsync(sponsoringOrgId, _currentContext.UserId ?? default),
model.PlanSponsorshipType, model.SponsoredEmail, model.FriendlyName); model.PlanSponsorshipType, model.SponsoredEmail, model.FriendlyName, model.Notes);
} }
[HttpDelete("{sponsoringOrgId}")] [HttpDelete("{sponsoringOrgId}")]

View File

@ -22,4 +22,6 @@ public class OrganizationSponsorshipCreateRequestModel
/// </summary> /// </summary>
/// <remarks>Left empty when creating a sponsorship for the authenticated user.</remarks> /// <remarks>Left empty when creating a sponsorship for the authenticated user.</remarks>
public Guid? SponsoringUserId { get; set; } public Guid? SponsoringUserId { get; set; }
public string Notes { get; set; }
} }

View File

@ -21,6 +21,7 @@ public class OrganizationSponsorship : ITableObject<Guid>
public DateTime? ValidUntil { get; set; } public DateTime? ValidUntil { get; set; }
public bool ToDelete { get; set; } public bool ToDelete { get; set; }
public bool IsAdminInitiated { get; set; } public bool IsAdminInitiated { get; set; }
public string? Notes { get; set; }
public void SetNewId() public void SetNewId()
{ {

View File

@ -17,6 +17,7 @@ public class OrganizationSponsorshipData
ValidUntil = sponsorship.ValidUntil; ValidUntil = sponsorship.ValidUntil;
ToDelete = sponsorship.ToDelete; ToDelete = sponsorship.ToDelete;
IsAdminInitiated = sponsorship.IsAdminInitiated; IsAdminInitiated = sponsorship.IsAdminInitiated;
Notes = sponsorship.Notes;
} }
public Guid SponsoringOrganizationUserId { get; set; } public Guid SponsoringOrganizationUserId { get; set; }
public Guid? SponsoredOrganizationId { get; set; } public Guid? SponsoredOrganizationId { get; set; }
@ -27,6 +28,7 @@ public class OrganizationSponsorshipData
public DateTime? ValidUntil { get; set; } public DateTime? ValidUntil { get; set; }
public bool ToDelete { get; set; } public bool ToDelete { get; set; }
public bool IsAdminInitiated { get; set; } public bool IsAdminInitiated { get; set; }
public string Notes { get; set; }
public bool CloudSponsorshipRemoved { get; set; } public bool CloudSponsorshipRemoved { get; set; }
} }

View File

@ -28,9 +28,9 @@ public class CreateSponsorshipCommand : ICreateSponsorshipCommand
} }
public async Task<OrganizationSponsorship> CreateSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, public async Task<OrganizationSponsorship> CreateSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
PlanSponsorshipType sponsorshipType, string sponsoredEmail, string friendlyName) PlanSponsorshipType sponsorshipType, string sponsoredEmail, string friendlyName, string notes)
{ {
var createSponsorshipRequest = new CreateSponsorshipRequest(sponsoringOrg, sponsoringOrgUser, sponsorshipType, sponsoredEmail, friendlyName); var createSponsorshipRequest = new CreateSponsorshipRequest(sponsoringOrg, sponsoringOrgUser, sponsorshipType, sponsoredEmail, friendlyName, notes);
var sponsorship = await _createSponsorshipHandler.HandleAsync(createSponsorshipRequest); var sponsorship = await _createSponsorshipHandler.HandleAsync(createSponsorshipRequest);
try try

View File

@ -7,5 +7,5 @@ namespace Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnte
public interface ICreateSponsorshipCommand public interface ICreateSponsorshipCommand
{ {
Task<OrganizationSponsorship> CreateSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, Task<OrganizationSponsorship> CreateSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
PlanSponsorshipType sponsorshipType, string sponsoredEmail, string friendlyName); PlanSponsorshipType sponsorshipType, string sponsoredEmail, string friendlyName, string notes);
} }

View File

@ -40,6 +40,7 @@ public class CreateAdminInitiatedSponsorshipHandler(
var sponsorship = await base.HandleAsync(request) ?? new OrganizationSponsorship(); var sponsorship = await base.HandleAsync(request) ?? new OrganizationSponsorship();
sponsorship.IsAdminInitiated = isAdminInitiated; sponsorship.IsAdminInitiated = isAdminInitiated;
sponsorship.Notes = request.Notes;
return sponsorship; return sponsorship;
} }

View File

@ -9,4 +9,5 @@ public record CreateSponsorshipRequest(
OrganizationUser SponsoringMember, OrganizationUser SponsoringMember,
PlanSponsorshipType SponsorshipType, PlanSponsorshipType SponsorshipType,
string SponsoredEmail, string SponsoredEmail,
string FriendlyName); string FriendlyName,
string Notes);

View File

@ -9,7 +9,8 @@ CREATE PROCEDURE [dbo].[OrganizationSponsorship_Create]
@ToDelete BIT, @ToDelete BIT,
@LastSyncDate DATETIME2 (7), @LastSyncDate DATETIME2 (7),
@ValidUntil DATETIME2 (7), @ValidUntil DATETIME2 (7),
@IsAdminInitiated BIT @IsAdminInitiated BIT,
@Notes NVARCHAR(512)
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -26,7 +27,8 @@ BEGIN
[ToDelete], [ToDelete],
[LastSyncDate], [LastSyncDate],
[ValidUntil], [ValidUntil],
[IsAdminInitiated] [IsAdminInitiated],
[Notes]
) )
VALUES VALUES
( (
@ -40,7 +42,8 @@ BEGIN
@ToDelete, @ToDelete,
@LastSyncDate, @LastSyncDate,
@ValidUntil, @ValidUntil,
@IsAdminInitiated @IsAdminInitiated,
@Notes
) )
END END
GO GO

View File

@ -16,7 +16,8 @@ BEGIN
[ToDelete], [ToDelete],
[LastSyncDate], [LastSyncDate],
[ValidUntil], [ValidUntil],
[IsAdminInitiated] [IsAdminInitiated],
[Notes]
) )
SELECT SELECT
OS.[Id], OS.[Id],
@ -29,7 +30,8 @@ BEGIN
OS.[ToDelete], OS.[ToDelete],
OS.[LastSyncDate], OS.[LastSyncDate],
OS.[ValidUntil], OS.[ValidUntil],
OS.[IsAdminInitiated] OS.[IsAdminInitiated],
OS.[Notes]
FROM FROM
@OrganizationSponsorshipsInput OS @OrganizationSponsorshipsInput OS
END END

View File

@ -9,7 +9,8 @@ CREATE PROCEDURE [dbo].[OrganizationSponsorship_Update]
@ToDelete BIT, @ToDelete BIT,
@LastSyncDate DATETIME2 (7), @LastSyncDate DATETIME2 (7),
@ValidUntil DATETIME2 (7), @ValidUntil DATETIME2 (7),
@IsAdminInitiated BIT @IsAdminInitiated BIT,
@Notes NVARCHAR(512)
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -26,7 +27,8 @@ BEGIN
[ToDelete] = @ToDelete, [ToDelete] = @ToDelete,
[LastSyncDate] = @LastSyncDate, [LastSyncDate] = @LastSyncDate,
[ValidUntil] = @ValidUntil, [ValidUntil] = @ValidUntil,
[IsAdminInitiated] = @IsAdminInitiated [IsAdminInitiated] = @IsAdminInitiated,
[Notes] = @Notes
WHERE WHERE
[Id] = @Id [Id] = @Id
END END

View File

@ -17,7 +17,8 @@ BEGIN
[ToDelete] = OSI.[ToDelete], [ToDelete] = OSI.[ToDelete],
[LastSyncDate] = OSI.[LastSyncDate], [LastSyncDate] = OSI.[LastSyncDate],
[ValidUntil] = OSI.[ValidUntil], [ValidUntil] = OSI.[ValidUntil],
[IsAdminInitiated] = OSI.[IsAdminInitiated] [IsAdminInitiated] = OSI.[IsAdminInitiated],
[Notes] = OSI.[Notes]
FROM FROM
[dbo].[OrganizationSponsorship] OS [dbo].[OrganizationSponsorship] OS
INNER JOIN INNER JOIN

View File

@ -10,6 +10,7 @@ CREATE TABLE [dbo].[OrganizationSponsorship] (
[LastSyncDate] DATETIME2 (7) NULL, [LastSyncDate] DATETIME2 (7) NULL,
[ValidUntil] DATETIME2 (7) NULL, [ValidUntil] DATETIME2 (7) NULL,
[IsAdminInitiated] BIT NOT NULL CONSTRAINT [DF_OrganizationSponsorship_IsAdminInitiated] DEFAULT (0), [IsAdminInitiated] BIT NOT NULL CONSTRAINT [DF_OrganizationSponsorship_IsAdminInitiated] DEFAULT (0),
[Notes] NVARCHAR(512) NULL,
CONSTRAINT [PK_OrganizationSponsorship] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [PK_OrganizationSponsorship] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationSponsorship_SponsoringOrg] FOREIGN KEY ([SponsoringOrganizationId]) REFERENCES [dbo].[Organization] ([Id]), CONSTRAINT [FK_OrganizationSponsorship_SponsoringOrg] FOREIGN KEY ([SponsoringOrganizationId]) REFERENCES [dbo].[Organization] ([Id]),
CONSTRAINT [FK_OrganizationSponsorship_SponsoredOrg] FOREIGN KEY ([SponsoredOrganizationId]) REFERENCES [dbo].[Organization] ([Id]), CONSTRAINT [FK_OrganizationSponsorship_SponsoredOrg] FOREIGN KEY ([SponsoredOrganizationId]) REFERENCES [dbo].[Organization] ([Id]),

View File

@ -9,5 +9,6 @@ CREATE TYPE [dbo].[OrganizationSponsorshipType] AS TABLE(
[LastSyncDate] DATETIME2(7), [LastSyncDate] DATETIME2(7),
[ValidUntil] DATETIME2(7), [ValidUntil] DATETIME2(7),
[ToDelete] BIT, [ToDelete] BIT,
[IsAdminInitiated] BIT [IsAdminInitiated] BIT,
[Notes] NVARCHAR(512)
) )

View File

@ -41,7 +41,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).ReturnsNull(); sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).ReturnsNull();
var exception = await Assert.ThrowsAsync<BadRequestException>(() => var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
sutProvider.Sut.CreateSponsorshipAsync(null, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default)); sutProvider.Sut.CreateSponsorshipAsync(null, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default, null));
Assert.Contains("Cannot offer a Families Organization Sponsorship to yourself. Choose a different email.", exception.Message); Assert.Contains("Cannot offer a Families Organization Sponsorship to yourself. Choose a different email.", exception.Message);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs()
@ -55,7 +55,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user); sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user);
var exception = await Assert.ThrowsAsync<BadRequestException>(() => var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
sutProvider.Sut.CreateSponsorshipAsync(null, orgUser, PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, default)); sutProvider.Sut.CreateSponsorshipAsync(null, orgUser, PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, default, null));
Assert.Contains("Cannot offer a Families Organization Sponsorship to yourself. Choose a different email.", exception.Message); Assert.Contains("Cannot offer a Families Organization Sponsorship to yourself. Choose a different email.", exception.Message);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs()
@ -72,7 +72,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user); sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user);
var exception = await Assert.ThrowsAsync<BadRequestException>(() => var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default)); sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default, null));
Assert.Contains("Specified Organization cannot sponsor other organizations.", exception.Message); Assert.Contains("Specified Organization cannot sponsor other organizations.", exception.Message);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs()
@ -91,7 +91,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user); sutProvider.GetDependency<IUserService>().GetUserByIdAsync(orgUser.UserId.Value).Returns(user);
var exception = await Assert.ThrowsAsync<BadRequestException>(() => var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default)); sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, PlanSponsorshipType.FamiliesForEnterprise, default, default, null));
Assert.Contains("Only confirmed users can sponsor other organizations.", exception.Message); Assert.Contains("Only confirmed users can sponsor other organizations.", exception.Message);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs()
@ -115,7 +115,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
sutProvider.GetDependency<ICurrentContext>().UserId.Returns(orgUser.UserId.Value); sutProvider.GetDependency<ICurrentContext>().UserId.Returns(orgUser.UserId.Value);
var exception = await Assert.ThrowsAsync<BadRequestException>(() => var exception = await Assert.ThrowsAsync<BadRequestException>(() =>
sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, sponsorship.PlanSponsorshipType.Value, default, default)); sutProvider.Sut.CreateSponsorshipAsync(org, orgUser, sponsorship.PlanSponsorshipType.Value, default, default, null));
Assert.Contains("Can only sponsor one organization per Organization User.", exception.Message); Assert.Contains("Can only sponsor one organization per Organization User.", exception.Message);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs() await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().DidNotReceiveWithAnyArgs()
@ -140,7 +140,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser, await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName); PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName, null);
var expectedSponsorship = new OrganizationSponsorship var expectedSponsorship = new OrganizationSponsorship
{ {
@ -150,7 +150,8 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
FriendlyName = friendlyName, FriendlyName = friendlyName,
OfferedToEmail = sponsoredEmail, OfferedToEmail = sponsoredEmail,
PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise, PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise,
IsAdminInitiated = false IsAdminInitiated = false,
Notes = null
}; };
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1) await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
@ -178,7 +179,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
var actualException = await Assert.ThrowsAsync<Exception>(() => var actualException = await Assert.ThrowsAsync<Exception>(() =>
sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser, sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName)); PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName, null));
Assert.Same(expectedException, actualException); Assert.Same(expectedException, actualException);
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1) await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)
@ -213,7 +214,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
var actual = await Assert.ThrowsAsync<UnauthorizedAccessException>(async () => var actual = await Assert.ThrowsAsync<UnauthorizedAccessException>(async () =>
await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser, await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName)); PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName, null));
Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message); Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message);
} }
@ -250,7 +251,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
var actual = await Assert.ThrowsAsync<UnauthorizedAccessException>(async () => var actual = await Assert.ThrowsAsync<UnauthorizedAccessException>(async () =>
await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser, await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName)); PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName, null));
Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message); Assert.Equal("You do not have permissions to send sponsorships on behalf of the organization.", actual.Message);
} }
@ -262,7 +263,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
public async Task CreateSponsorship_CreatesAdminInitiatedSponsorship( public async Task CreateSponsorship_CreatesAdminInitiatedSponsorship(
OrganizationUserType organizationUserType, OrganizationUserType organizationUserType,
Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, User user, string sponsoredEmail, Organization sponsoringOrg, OrganizationUser sponsoringOrgUser, User user, string sponsoredEmail,
string friendlyName, Guid sponsorshipId, Guid currentUserId, SutProvider<CreateSponsorshipCommand> sutProvider) string friendlyName, Guid sponsorshipId, Guid currentUserId, string notes, SutProvider<CreateSponsorshipCommand> sutProvider)
{ {
sponsoringOrg.PlanType = PlanType.EnterpriseAnnually; sponsoringOrg.PlanType = PlanType.EnterpriseAnnually;
sponsoringOrgUser.Status = OrganizationUserStatusType.Confirmed; sponsoringOrgUser.Status = OrganizationUserStatusType.Confirmed;
@ -287,7 +288,7 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
]); ]);
await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser, await sutProvider.Sut.CreateSponsorshipAsync(sponsoringOrg, sponsoringOrgUser,
PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName); PlanSponsorshipType.FamiliesForEnterprise, sponsoredEmail, friendlyName, notes);
var expectedSponsorship = new OrganizationSponsorship var expectedSponsorship = new OrganizationSponsorship
@ -298,7 +299,8 @@ public class CreateSponsorshipCommandTests : FamiliesForEnterpriseTestsBase
FriendlyName = friendlyName, FriendlyName = friendlyName,
OfferedToEmail = sponsoredEmail, OfferedToEmail = sponsoredEmail,
PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise, PlanSponsorshipType = PlanSponsorshipType.FamiliesForEnterprise,
IsAdminInitiated = true IsAdminInitiated = true,
Notes = notes
}; };
await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1) await sutProvider.GetDependency<IOrganizationSponsorshipRepository>().Received(1)

View File

@ -364,7 +364,8 @@ CREATE OR ALTER PROCEDURE [dbo].[OrganizationSponsorship_Update]
@ToDelete BIT, @ToDelete BIT,
@LastSyncDate DATETIME2 (7), @LastSyncDate DATETIME2 (7),
@ValidUntil DATETIME2 (7), @ValidUntil DATETIME2 (7),
@IsAdminInitiated BIT @IsAdminInitiated BIT,
@Notes NVARCHAR(512)
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -381,7 +382,8 @@ SET
[ToDelete] = @ToDelete, [ToDelete] = @ToDelete,
[LastSyncDate] = @LastSyncDate, [LastSyncDate] = @LastSyncDate,
[ValidUntil] = @ValidUntil, [ValidUntil] = @ValidUntil,
[IsAdminInitiated] = @IsAdminInitiated [IsAdminInitiated] = @IsAdminInitiated,
[Notes] = @Notes
WHERE WHERE
[Id] = @Id [Id] = @Id
END END
@ -398,7 +400,8 @@ CREATE OR ALTER PROCEDURE [dbo].[OrganizationSponsorship_Create]
@ToDelete BIT, @ToDelete BIT,
@LastSyncDate DATETIME2 (7), @LastSyncDate DATETIME2 (7),
@ValidUntil DATETIME2 (7), @ValidUntil DATETIME2 (7),
@IsAdminInitiated BIT @IsAdminInitiated BIT,
@Notes NVARCHAR(512)
AS AS
BEGIN BEGIN
SET NOCOUNT ON SET NOCOUNT ON
@ -415,7 +418,8 @@ BEGIN
[ToDelete], [ToDelete],
[LastSyncDate], [LastSyncDate],
[ValidUntil], [ValidUntil],
[IsAdminInitiated] [IsAdminInitiated],
[Notes]
) )
VALUES VALUES
( (
@ -429,7 +433,8 @@ BEGIN
@ToDelete, @ToDelete,
@LastSyncDate, @LastSyncDate,
@ValidUntil, @ValidUntil,
@IsAdminInitiated @IsAdminInitiated,
@Notes
) )
END END
GO; GO;
@ -449,7 +454,8 @@ CREATE TYPE [dbo].[OrganizationSponsorshipType] AS TABLE(
[LastSyncDate] DATETIME2(7), [LastSyncDate] DATETIME2(7),
[ValidUntil] DATETIME2(7), [ValidUntil] DATETIME2(7),
[ToDelete] BIT, [ToDelete] BIT,
[IsAdminInitiated] BIT [IsAdminInitiated] BIT,
[Notes] NVARCHAR(512)
); );
GO; GO;
@ -471,7 +477,8 @@ BEGIN
[ToDelete], [ToDelete],
[LastSyncDate], [LastSyncDate],
[ValidUntil], [ValidUntil],
[IsAdminInitiated] [IsAdminInitiated],
[Notes]
) )
SELECT SELECT
OS.[Id], OS.[Id],
@ -484,7 +491,8 @@ SELECT
OS.[ToDelete], OS.[ToDelete],
OS.[LastSyncDate], OS.[LastSyncDate],
OS.[ValidUntil], OS.[ValidUntil],
OS.[IsAdminInitiated] OS.[IsAdminInitiated],
OS.[Notes]
FROM FROM
@OrganizationSponsorshipsInput OS @OrganizationSponsorshipsInput OS
END END
@ -509,7 +517,8 @@ SET
[ToDelete] = OSI.[ToDelete], [ToDelete] = OSI.[ToDelete],
[LastSyncDate] = OSI.[LastSyncDate], [LastSyncDate] = OSI.[LastSyncDate],
[ValidUntil] = OSI.[ValidUntil], [ValidUntil] = OSI.[ValidUntil],
[IsAdminInitiated] = OSI.[IsAdminInitiated] [IsAdminInitiated] = OSI.[IsAdminInitiated],
[Notes] = OSI.[Notes]
FROM FROM
[dbo].[OrganizationSponsorship] OS [dbo].[OrganizationSponsorship] OS
INNER JOIN INNER JOIN

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.MySqlMigrations.Migrations namespace Bit.MySqlMigrations.Migrations
{ {
[DbContext(typeof(DatabaseContext))] [DbContext(typeof(DatabaseContext))]
[Migration("20250312084349_PM17830_AdminInitiatedSponsorships")] [Migration("20250326092653_PM17830_AdminInitiatedSponsorships")]
partial class PM17830_AdminInitiatedSponsorships partial class PM17830_AdminInitiatedSponsorships
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -1261,6 +1261,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)");
b.Property<string>("Notes")
.HasColumnType("longtext");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(256)");

View File

@ -17,6 +17,13 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
nullable: false, nullable: false,
defaultValue: false); defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Notes",
table: "OrganizationSponsorship",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>( migrationBuilder.AddColumn<bool>(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization", table: "Organization",
@ -32,6 +39,10 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
name: "IsAdminInitiated", name: "IsAdminInitiated",
table: "OrganizationSponsorship"); table: "OrganizationSponsorship");
migrationBuilder.DropColumn(
name: "Notes",
table: "OrganizationSponsorship");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization"); table: "Organization");

View File

@ -1258,6 +1258,9 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)");
b.Property<string>("Notes")
.HasColumnType("longtext");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(256)");

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.PostgresMigrations.Migrations namespace Bit.PostgresMigrations.Migrations
{ {
[DbContext(typeof(DatabaseContext))] [DbContext(typeof(DatabaseContext))]
[Migration("20250312084357_PM17830_AdminInitiatedSponsorships")] [Migration("20250326092700_PM17830_AdminInitiatedSponsorships")]
partial class PM17830_AdminInitiatedSponsorships partial class PM17830_AdminInitiatedSponsorships
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -1266,6 +1266,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("character varying(256)"); .HasColumnType("character varying(256)");

View File

@ -17,6 +17,12 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
nullable: false, nullable: false,
defaultValue: false); defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Notes",
table: "OrganizationSponsorship",
type: "text",
nullable: true);
migrationBuilder.AddColumn<bool>( migrationBuilder.AddColumn<bool>(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization", table: "Organization",
@ -32,6 +38,10 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
name: "IsAdminInitiated", name: "IsAdminInitiated",
table: "OrganizationSponsorship"); table: "OrganizationSponsorship");
migrationBuilder.DropColumn(
name: "Notes",
table: "OrganizationSponsorship");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization"); table: "Organization");

View File

@ -1263,6 +1263,9 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("character varying(256)"); .HasColumnType("character varying(256)");

View File

@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.SqliteMigrations.Migrations namespace Bit.SqliteMigrations.Migrations
{ {
[DbContext(typeof(DatabaseContext))] [DbContext(typeof(DatabaseContext))]
[Migration("20250312084403_PM17830_AdminInitiatedSponsorships")] [Migration("20250326092645_PM17830_AdminInitiatedSponsorships")]
partial class PM17830_AdminInitiatedSponsorships partial class PM17830_AdminInitiatedSponsorships
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -1250,6 +1250,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Notes")
.HasColumnType("TEXT");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("TEXT"); .HasColumnType("TEXT");

View File

@ -17,6 +17,12 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
nullable: false, nullable: false,
defaultValue: false); defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Notes",
table: "OrganizationSponsorship",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<bool>( migrationBuilder.AddColumn<bool>(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization", table: "Organization",
@ -32,6 +38,10 @@ public partial class PM17830_AdminInitiatedSponsorships : Migration
name: "IsAdminInitiated", name: "IsAdminInitiated",
table: "OrganizationSponsorship"); table: "OrganizationSponsorship");
migrationBuilder.DropColumn(
name: "Notes",
table: "OrganizationSponsorship");
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "UseAdminSponsoredFamilies", name: "UseAdminSponsoredFamilies",
table: "Organization"); table: "Organization");

View File

@ -1247,6 +1247,9 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("LastSyncDate") b.Property<DateTime?>("LastSyncDate")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("Notes")
.HasColumnType("TEXT");
b.Property<string>("OfferedToEmail") b.Property<string>("OfferedToEmail")
.HasMaxLength(256) .HasMaxLength(256)
.HasColumnType("TEXT"); .HasColumnType("TEXT");