mirror of
https://github.com/bitwarden/server.git
synced 2025-04-09 07:08:15 -05:00
updates to logging
This commit is contained in:
parent
2f3b38a941
commit
9dedf359e5
@ -54,15 +54,12 @@ namespace Bit.Core.Services
|
||||
|
||||
protected async Task SendAsync(HttpMethod method, string path, object requestModel = null)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync1");
|
||||
var tokenStateResponse = await HandleTokenStateAsync();
|
||||
if(!tokenStateResponse)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync2");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "SendAsync3");
|
||||
var message = new TokenHttpRequestMessage(requestModel, AccessToken)
|
||||
{
|
||||
Method = method,
|
||||
|
@ -32,15 +32,12 @@ namespace Bit.Core.Services
|
||||
globalSettings.Installation?.Id != null &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.Installation?.Key))
|
||||
{
|
||||
logger.LogInformation(Constants.BypassFiltersEventId, "Use RelayPushNotificationService");
|
||||
_services.Add(new RelayPushNotificationService(_deviceRepository, globalSettings,
|
||||
httpContextAccessor, relayLogger));
|
||||
}
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.InternalIdentityKey) &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.BaseServiceUri.InternalNotifications))
|
||||
{
|
||||
logger.LogInformation(Constants.BypassFiltersEventId,
|
||||
"Use NotificationsApiPushNotificationService");
|
||||
_services.Add(new NotificationsApiPushNotificationService(
|
||||
globalSettings, httpContextAccessor, hubLogger));
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ namespace Bit.Core.Services
|
||||
|
||||
public async Task PushSyncCipherUpdateAsync(Cipher cipher, IEnumerable<Guid> collectionIds)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushSyncCipherUpdateAsync");
|
||||
await PushCipherAsync(cipher, PushType.SyncCipherUpdate, collectionIds);
|
||||
}
|
||||
|
||||
@ -73,7 +72,6 @@ namespace Bit.Core.Services
|
||||
RevisionDate = cipher.RevisionDate,
|
||||
};
|
||||
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay PushCipherAsync");
|
||||
await SendPayloadToUserAsync(cipher.UserId.Value, type, message, true);
|
||||
}
|
||||
}
|
||||
@ -143,7 +141,6 @@ namespace Bit.Core.Services
|
||||
|
||||
private async Task SendPayloadToUserAsync(Guid userId, PushType type, object payload, bool excludeCurrentContext)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync1");
|
||||
var request = new PushSendRequestModel
|
||||
{
|
||||
UserId = userId.ToString(),
|
||||
@ -151,9 +148,9 @@ namespace Bit.Core.Services
|
||||
Payload = payload
|
||||
};
|
||||
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync2");
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 1");
|
||||
await AddCurrentContextAsync(request, excludeCurrentContext);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync3");
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay SendPayloadToUserAsync 2");
|
||||
await SendAsync(HttpMethod.Post, "push/send", request);
|
||||
}
|
||||
|
||||
@ -172,20 +169,26 @@ namespace Bit.Core.Services
|
||||
|
||||
private async Task AddCurrentContextAsync(PushSendRequestModel request, bool addIdentifier)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 0");
|
||||
var currentContext = _httpContextAccessor?.HttpContext?.
|
||||
RequestServices.GetService(typeof(CurrentContext)) as CurrentContext;
|
||||
if(!string.IsNullOrWhiteSpace(currentContext?.DeviceIdentifier))
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 1");
|
||||
var device = await _deviceRepository.GetByIdentifierAsync(currentContext.DeviceIdentifier);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 2");
|
||||
if(device != null)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 3");
|
||||
request.DeviceId = device.Id.ToString();
|
||||
}
|
||||
if(addIdentifier)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 4");
|
||||
request.Identifier = currentContext.DeviceIdentifier;
|
||||
}
|
||||
}
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Relay AddCurrentContextAsync 5");
|
||||
}
|
||||
|
||||
public Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier,
|
||||
|
Loading…
x
Reference in New Issue
Block a user