1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 17:12:49 -05:00

[AC-1864] Event type for initiation path (#3869)

* initial commit

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* handle the upgrade path reference

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* code improvement

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* resolve pr comment

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* change the comment

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* move the private method down

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* code review changes

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

---------

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
cyprain-okeke
2024-03-22 21:01:22 +01:00
committed by GitHub
parent 743465273c
commit 5dd1a9410a
2 changed files with 36 additions and 0 deletions

View File

@ -279,6 +279,7 @@ public class UpgradeOrganizationPlanCommand : IUpgradeOrganizationPlanCommand
if (success)
{
var upgradePath = GetUpgradePath(existingPlan.Product, newPlan.Product);
await _referenceEventService.RaiseEventAsync(
new ReferenceEvent(ReferenceEventType.UpgradePlan, organization, _currentContext)
{
@ -287,6 +288,8 @@ public class UpgradeOrganizationPlanCommand : IUpgradeOrganizationPlanCommand
OldPlanName = existingPlan.Name,
OldPlanType = existingPlan.Type,
Seats = organization.Seats,
SignupInitiationPath = "Upgrade in-product",
PlanUpgradePath = upgradePath,
Storage = organization.MaxStorageGb,
// TODO: add reference events for SmSeats and Service Accounts - see AC-1481
});
@ -338,4 +341,26 @@ public class UpgradeOrganizationPlanCommand : IUpgradeOrganizationPlanCommand
{
return await _organizationRepository.GetByIdAsync(id);
}
private static string GetUpgradePath(ProductType oldProductType, ProductType newProductType)
{
var oldDescription = _upgradePath.TryGetValue(oldProductType, out var description)
? description
: $"{oldProductType:G}";
var newDescription = _upgradePath.TryGetValue(newProductType, out description)
? description
: $"{newProductType:G}";
return $"{oldDescription} → {newDescription}";
}
private static readonly Dictionary<ProductType, string> _upgradePath = new()
{
[ProductType.Free] = "2-person org",
[ProductType.Families] = "Families",
[ProductType.TeamsStarter] = "Teams Starter",
[ProductType.Teams] = "Teams",
[ProductType.Enterprise] = "Enterprise"
};
}