mirror of
https://github.com/bitwarden/server
synced 2025-12-26 21:23:39 +00:00
* Allow for binning of comb IDs by date and value
* Introduce notification hub pool
* Replace device type sharding with comb + range sharding
* Fix proxy interface
* Use enumerable services for multiServiceNotificationHub
* Fix push interface usage
* Fix push notification service dependencies
* Fix push notification keys
* Fixup documentation
* Remove deprecated settings
* Fix tests
* PascalCase method names
* Remove unused request model properties
* Remove unused setting
* Improve DateFromComb precision
* Prefer readonly service enumerable
* Pascal case template holes
* Name TryParse methods TryParse
* Apply suggestions from code review
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
* AllClients is a set of clients and must be deduplicated
* Fix registration start time
* Add logging to initialization of a notification hub
* more logging
* Add lower level logging for hub settings
* Log when connection is resolved
* Improve log message
* Log pushes to notification hub
* temporarily elevate log messages for visibility
* Log in multi-service when relaying to another push service
* Revert to more reasonable logging free of user information
* Fixup merge
Deleting user was extracted to a command in #4803, this updates that work to use just the device ids as I did elsewhere in abd67e8ec
* Do not use bouncy castle exception types
* Add required services for logging
---------
Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
158 lines
5.0 KiB
C#
158 lines
5.0 KiB
C#
using Bit.Core.Auth.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Settings;
|
|
using Bit.Core.Tools.Entities;
|
|
using Bit.Core.Vault.Entities;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Bit.Core.Services;
|
|
|
|
public class MultiServicePushNotificationService : IPushNotificationService
|
|
{
|
|
private readonly IEnumerable<IPushNotificationService> _services;
|
|
private readonly ILogger<MultiServicePushNotificationService> _logger;
|
|
|
|
public MultiServicePushNotificationService(
|
|
[FromKeyedServices("implementation")] IEnumerable<IPushNotificationService> services,
|
|
ILogger<MultiServicePushNotificationService> logger,
|
|
GlobalSettings globalSettings)
|
|
{
|
|
_services = services;
|
|
|
|
_logger = logger;
|
|
_logger.LogInformation("Hub services: {Services}", _services.Count());
|
|
globalSettings?.NotificationHubPool?.NotificationHubs?.ForEach(hub =>
|
|
{
|
|
_logger.LogInformation("HubName: {HubName}, EnableSendTracing: {EnableSendTracing}, RegistrationStartDate: {RegistrationStartDate}, RegistrationEndDate: {RegistrationEndDate}", hub.HubName, hub.EnableSendTracing, hub.RegistrationStartDate, hub.RegistrationEndDate);
|
|
});
|
|
}
|
|
|
|
public Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable<Guid> collectionIds)
|
|
{
|
|
PushToServices((s) => s.PushSyncCipherCreateAsync(cipher, collectionIds));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable<Guid> collectionIds)
|
|
{
|
|
PushToServices((s) => s.PushSyncCipherUpdateAsync(cipher, collectionIds));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncCipherDeleteAsync(Cipher cipher)
|
|
{
|
|
PushToServices((s) => s.PushSyncCipherDeleteAsync(cipher));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncFolderCreateAsync(Folder folder)
|
|
{
|
|
PushToServices((s) => s.PushSyncFolderCreateAsync(folder));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncFolderUpdateAsync(Folder folder)
|
|
{
|
|
PushToServices((s) => s.PushSyncFolderUpdateAsync(folder));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncFolderDeleteAsync(Folder folder)
|
|
{
|
|
PushToServices((s) => s.PushSyncFolderDeleteAsync(folder));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncCiphersAsync(Guid userId)
|
|
{
|
|
PushToServices((s) => s.PushSyncCiphersAsync(userId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncVaultAsync(Guid userId)
|
|
{
|
|
PushToServices((s) => s.PushSyncVaultAsync(userId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncOrganizationsAsync(Guid userId)
|
|
{
|
|
PushToServices((s) => s.PushSyncOrganizationsAsync(userId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncOrgKeysAsync(Guid userId)
|
|
{
|
|
PushToServices((s) => s.PushSyncOrgKeysAsync(userId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncSettingsAsync(Guid userId)
|
|
{
|
|
PushToServices((s) => s.PushSyncSettingsAsync(userId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushLogOutAsync(Guid userId, bool excludeCurrentContext = false)
|
|
{
|
|
PushToServices((s) => s.PushLogOutAsync(userId, excludeCurrentContext));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncSendCreateAsync(Send send)
|
|
{
|
|
PushToServices((s) => s.PushSyncSendCreateAsync(send));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncSendUpdateAsync(Send send)
|
|
{
|
|
PushToServices((s) => s.PushSyncSendUpdateAsync(send));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushAuthRequestAsync(AuthRequest authRequest)
|
|
{
|
|
PushToServices((s) => s.PushAuthRequestAsync(authRequest));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushAuthRequestResponseAsync(AuthRequest authRequest)
|
|
{
|
|
PushToServices((s) => s.PushAuthRequestResponseAsync(authRequest));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task PushSyncSendDeleteAsync(Send send)
|
|
{
|
|
PushToServices((s) => s.PushSyncSendDeleteAsync(send));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier,
|
|
string deviceId = null)
|
|
{
|
|
PushToServices((s) => s.SendPayloadToUserAsync(userId, type, payload, identifier, deviceId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
public Task SendPayloadToOrganizationAsync(string orgId, PushType type, object payload, string identifier,
|
|
string deviceId = null)
|
|
{
|
|
PushToServices((s) => s.SendPayloadToOrganizationAsync(orgId, type, payload, identifier, deviceId));
|
|
return Task.FromResult(0);
|
|
}
|
|
|
|
private void PushToServices(Func<IPushNotificationService, Task> pushFunc)
|
|
{
|
|
if (_services != null)
|
|
{
|
|
foreach (var service in _services)
|
|
{
|
|
pushFunc(service);
|
|
}
|
|
}
|
|
}
|
|
}
|