mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
PM-10600: Startup fix
This commit is contained in:
@ -4,6 +4,7 @@ using Bit.Core.Repositories;
|
|||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using Microsoft.Azure.NotificationHubs;
|
using Microsoft.Azure.NotificationHubs;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Bit.Core.NotificationHub;
|
namespace Bit.Core.NotificationHub;
|
||||||
|
|
||||||
@ -11,16 +12,16 @@ public class NotificationHubPushRegistrationService : IPushRegistrationService
|
|||||||
{
|
{
|
||||||
private readonly IInstallationDeviceRepository _installationDeviceRepository;
|
private readonly IInstallationDeviceRepository _installationDeviceRepository;
|
||||||
private readonly INotificationHubPool _notificationHubPool;
|
private readonly INotificationHubPool _notificationHubPool;
|
||||||
private readonly IFeatureService _featureService;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
public NotificationHubPushRegistrationService(
|
public NotificationHubPushRegistrationService(
|
||||||
IInstallationDeviceRepository installationDeviceRepository,
|
IInstallationDeviceRepository installationDeviceRepository,
|
||||||
INotificationHubPool notificationHubPool,
|
INotificationHubPool notificationHubPool,
|
||||||
IFeatureService featureService)
|
IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
_installationDeviceRepository = installationDeviceRepository;
|
_installationDeviceRepository = installationDeviceRepository;
|
||||||
_notificationHubPool = notificationHubPool;
|
_notificationHubPool = notificationHubPool;
|
||||||
_featureService = featureService;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
|
public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
|
||||||
@ -51,7 +52,8 @@ public class NotificationHubPushRegistrationService : IPushRegistrationService
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case DeviceType.Android:
|
case DeviceType.Android:
|
||||||
if (_featureService.IsEnabled(FeatureFlagKeys.AnhFcmv1Migration))
|
var featureService = _serviceProvider.GetRequiredService<IFeatureService>();
|
||||||
|
if (featureService.IsEnabled(FeatureFlagKeys.AnhFcmv1Migration))
|
||||||
{
|
{
|
||||||
payloadTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\",\"payload\":\"$(payload)\"}}}";
|
payloadTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\",\"payload\":\"$(payload)\"}}}";
|
||||||
messageTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\"}," +
|
messageTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\"}," +
|
||||||
|
@ -35,7 +35,9 @@ public class NotificationHubPushRegistrationServiceTests
|
|||||||
public async void CreateOrUpdateRegistrationAsync_DeviceTypeAndroid_InstallationCreated(bool identifierNull,
|
public async void CreateOrUpdateRegistrationAsync_DeviceTypeAndroid_InstallationCreated(bool identifierNull,
|
||||||
SutProvider<NotificationHubPushRegistrationService> sutProvider, Guid deviceId, Guid userId, Guid? identifier)
|
SutProvider<NotificationHubPushRegistrationService> sutProvider, Guid deviceId, Guid userId, Guid? identifier)
|
||||||
{
|
{
|
||||||
sutProvider.GetDependency<IFeatureService>().IsEnabled(FeatureFlagKeys.AnhFcmv1Migration).Returns(true);
|
var featureService = Substitute.For<IFeatureService>();
|
||||||
|
featureService.IsEnabled(FeatureFlagKeys.AnhFcmv1Migration).Returns(true);
|
||||||
|
sutProvider.GetDependency<IServiceProvider>().GetService(typeof(IFeatureService)).Returns(featureService);
|
||||||
var notificationHubClient = Substitute.For<INotificationHubClient>();
|
var notificationHubClient = Substitute.For<INotificationHubClient>();
|
||||||
sutProvider.GetDependency<INotificationHubPool>().ClientFor(Arg.Any<Guid>()).Returns(notificationHubClient);
|
sutProvider.GetDependency<INotificationHubPool>().ClientFor(Arg.Any<Guid>()).Returns(notificationHubClient);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user