mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05: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>
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using Bit.Core.Enums;
|
|
using Bit.Core.IdentityServer;
|
|
using Bit.Core.Models.Api;
|
|
using Bit.Core.Settings;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Bit.Core.Services;
|
|
|
|
public class RelayPushRegistrationService : BaseIdentityClientService, IPushRegistrationService
|
|
{
|
|
|
|
public RelayPushRegistrationService(
|
|
IHttpClientFactory httpFactory,
|
|
GlobalSettings globalSettings,
|
|
ILogger<RelayPushRegistrationService> logger)
|
|
: base(
|
|
httpFactory,
|
|
globalSettings.PushRelayBaseUri,
|
|
globalSettings.Installation.IdentityUri,
|
|
ApiScopes.ApiPush,
|
|
$"installation.{globalSettings.Installation.Id}",
|
|
globalSettings.Installation.Key,
|
|
logger)
|
|
{
|
|
}
|
|
|
|
public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
|
|
string identifier, DeviceType type)
|
|
{
|
|
var requestModel = new PushRegistrationRequestModel
|
|
{
|
|
DeviceId = deviceId,
|
|
Identifier = identifier,
|
|
PushToken = pushToken,
|
|
Type = type,
|
|
UserId = userId
|
|
};
|
|
await SendAsync(HttpMethod.Post, "push/register", requestModel);
|
|
}
|
|
|
|
public async Task DeleteRegistrationAsync(string deviceId)
|
|
{
|
|
var requestModel = new PushDeviceRequestModel
|
|
{
|
|
Id = deviceId,
|
|
};
|
|
await SendAsync(HttpMethod.Post, "push/delete", requestModel);
|
|
}
|
|
|
|
public async Task AddUserRegistrationOrganizationAsync(
|
|
IEnumerable<string> deviceIds, string organizationId)
|
|
{
|
|
if (!deviceIds.Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
var requestModel = new PushUpdateRequestModel(deviceIds, organizationId);
|
|
await SendAsync(HttpMethod.Put, "push/add-organization", requestModel);
|
|
}
|
|
|
|
public async Task DeleteUserRegistrationOrganizationAsync(
|
|
IEnumerable<string> deviceIds, string organizationId)
|
|
{
|
|
if (!deviceIds.Any())
|
|
{
|
|
return;
|
|
}
|
|
|
|
var requestModel = new PushUpdateRequestModel(deviceIds, organizationId);
|
|
await SendAsync(HttpMethod.Put, "push/delete-organization", requestModel);
|
|
}
|
|
}
|