mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01: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:
parent
743465273c
commit
5dd1a9410a
@ -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"
|
||||
};
|
||||
}
|
||||
|
@ -243,4 +243,15 @@ public class ReferenceEvent
|
||||
/// the value should be <see langword="null" />.
|
||||
/// </value>
|
||||
public string SignupInitiationPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The upgrade applied to an account. The current plan is listed first,
|
||||
/// followed by the plan they are migrating to. For example,
|
||||
/// "Teams Starter → Teams, Enterprise".
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="null"/> when the event was not originated by an application,
|
||||
/// or when a downgrade occurred.
|
||||
/// </value>
|
||||
public string PlanUpgradePath { get; set; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user