1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22:50 -05:00

PM-10600: Fix FeatureService service discoverability error

The `IFeatureService` is scoped service, yet it is provided as non-scoped via service provider. This results in exception on runtime. No Android device can register for push notifications as a result.
This commit is contained in:
Maciej Zieniuk
2024-11-05 14:52:27 +00:00
parent 89b0848002
commit cbc1e0ffe4

View File

@ -52,20 +52,23 @@ public class NotificationHubPushRegistrationService : IPushRegistrationService
switch (type) switch (type)
{ {
case DeviceType.Android: case DeviceType.Android:
var featureService = _serviceProvider.GetRequiredService<IFeatureService>(); await using (var serviceScope = _serviceProvider.CreateAsyncScope())
if (featureService.IsEnabled(FeatureFlagKeys.AnhFcmv1Migration))
{ {
payloadTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\",\"payload\":\"$(payload)\"}}}"; var featureService = serviceScope.ServiceProvider.GetRequiredService<IFeatureService>();
messageTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\"}," + if (featureService.IsEnabled(FeatureFlagKeys.AnhFcmv1Migration))
"\"notification\":{\"title\":\"$(title)\",\"body\":\"$(message)\"}}}"; {
installation.Platform = NotificationPlatform.FcmV1; payloadTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\",\"payload\":\"$(payload)\"}}}";
} messageTemplate = "{\"message\":{\"data\":{\"type\":\"$(type)\"}," +
else "\"notification\":{\"title\":\"$(title)\",\"body\":\"$(message)\"}}}";
{ installation.Platform = NotificationPlatform.FcmV1;
payloadTemplate = "{\"data\":{\"data\":{\"type\":\"#(type)\",\"payload\":\"$(payload)\"}}}"; }
messageTemplate = "{\"data\":{\"data\":{\"type\":\"#(type)\"}," + else
"\"notification\":{\"title\":\"$(title)\",\"body\":\"$(message)\"}}}"; {
installation.Platform = NotificationPlatform.Fcm; payloadTemplate = "{\"data\":{\"data\":{\"type\":\"#(type)\",\"payload\":\"$(payload)\"}}}";
messageTemplate = "{\"data\":{\"data\":{\"type\":\"#(type)\"}," +
"\"notification\":{\"title\":\"$(title)\",\"body\":\"$(message)\"}}}";
installation.Platform = NotificationPlatform.Fcm;
}
} }
break; break;