mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 10:02:47 -05:00

* [AC-1637] Added HtmlEncodingStringConverter to encode/decode special chars on JSON serialization/deserialization
* [AC-1637] Added unit tests for HtmlEncodingStringConverter
* [AC-1637] Moved expected values on unit tests to the arrange phase
* [AC-1637] Added HtmlEncodingStringConverter to properties that are for input/output of Org Name and Business name
* [AC-1637] Modified views in Admin project to decode values to display
* [AC-1637] Replaced Html.Raw with HttpUtility.HtmlDecode
* [AC-1637] Added JsonConverter to Provider DTOs
* [AC-1637] Modified HandlebarsMailService to decode organization name before sending emails
* Revert "[AC-1637] Added JsonConverter to Provider DTOs"
This reverts commit 94d507cf93
.
* [AC-1637] Fixed Admin panel organization search
* [AC-1637] Sanitizing Organization name and business name on creation in Admin panel
* [AC-1637] Sanitizing organization name and business name on creation by a provider
* [AC-1637] Sanitizing provider name on creation and on viewing in admin panel
* [AC-1637] Added sanitization to more places where Org name is used
* [AC-1637] Swapped using HttpUtility for WebUtility since the later is part of the dotnet framework
* [AC-1637] Updated error messages
* [AC-1637] Decoding on Admin panel add existing organization
* [AC-1637] Fix HTML decoding issues
* [AC-1637] Refactor HTML decoding in View and Model classes on Admin panel
* [AC-1637] Refactor provider name and business name usages to use methods that output decoded values
* [AC-1637] Fixed typo
* [AC-1637] Renamed Provider methods to retrieve Decoded Name and BusinessName
* [AC-1637] Renamed Organization methods to retrieve Decoded Name and BusinessName
* [AC-1637] Update the display name method in the `ProviderOrganizationOrganizationDetails` class to `DisplayName()`
68 lines
2.7 KiB
C#
68 lines
2.7 KiB
C#
using Bit.Core.Enums;
|
|
using Bit.Core.Jobs;
|
|
using Bit.Core.Models.OrganizationConnectionConfigs;
|
|
using Bit.Core.OrganizationFeatures.OrganizationSponsorships.FamiliesForEnterprise.Interfaces;
|
|
using Bit.Core.Repositories;
|
|
using Bit.Core.Services;
|
|
using Bit.Core.Settings;
|
|
using Quartz;
|
|
|
|
namespace Bit.Api.Jobs;
|
|
|
|
public class SelfHostedSponsorshipSyncJob : BaseJob
|
|
{
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private IOrganizationRepository _organizationRepository;
|
|
private IOrganizationConnectionRepository _organizationConnectionRepository;
|
|
private readonly ILicensingService _licensingService;
|
|
private GlobalSettings _globalSettings;
|
|
|
|
public SelfHostedSponsorshipSyncJob(
|
|
IServiceProvider serviceProvider,
|
|
IOrganizationRepository organizationRepository,
|
|
IOrganizationConnectionRepository organizationConnectionRepository,
|
|
ILicensingService licensingService,
|
|
ILogger<SelfHostedSponsorshipSyncJob> logger,
|
|
GlobalSettings globalSettings)
|
|
: base(logger)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
_organizationRepository = organizationRepository;
|
|
_organizationConnectionRepository = organizationConnectionRepository;
|
|
_licensingService = licensingService;
|
|
_globalSettings = globalSettings;
|
|
}
|
|
|
|
protected override async Task ExecuteJobAsync(IJobExecutionContext context)
|
|
{
|
|
if (!_globalSettings.EnableCloudCommunication)
|
|
{
|
|
_logger.LogInformation("Skipping Organization sync with cloud - Cloud communication is disabled in global settings");
|
|
return;
|
|
}
|
|
|
|
var organizations = await _organizationRepository.GetManyByEnabledAsync();
|
|
|
|
using (var scope = _serviceProvider.CreateScope())
|
|
{
|
|
var syncCommand = scope.ServiceProvider.GetRequiredService<ISelfHostedSyncSponsorshipsCommand>();
|
|
foreach (var org in organizations)
|
|
{
|
|
var connection = (await _organizationConnectionRepository.GetEnabledByOrganizationIdTypeAsync(org.Id, OrganizationConnectionType.CloudBillingSync)).FirstOrDefault();
|
|
if (connection != null)
|
|
{
|
|
try
|
|
{
|
|
var config = connection.GetConfig<BillingSyncConfig>();
|
|
await syncCommand.SyncOrganization(org.Id, config.CloudOrganizationId, connection);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Sponsorship sync for organization {OrganizationName} Failed", org.DisplayName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|