mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 16:42:50 -05:00
Changed all C# control flow block statements to include space between keyword and open paren
This commit is contained in:
@ -39,7 +39,7 @@ namespace Bit.Notifications
|
||||
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if(_executingTask == null)
|
||||
if (_executingTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -55,14 +55,14 @@ namespace Bit.Notifications
|
||||
private async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_queueClient = new QueueClient(_globalSettings.Notifications.ConnectionString, "notifications");
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
var messages = await _queueClient.ReceiveMessagesAsync(32);
|
||||
if(messages.Value?.Any() ?? false)
|
||||
if (messages.Value?.Any() ?? false)
|
||||
{
|
||||
foreach(var message in messages.Value)
|
||||
foreach (var message in messages.Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -70,11 +70,11 @@ namespace Bit.Notifications
|
||||
message.MessageText, _hubContext, cancellationToken);
|
||||
await _queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError("Error processing dequeued message: " +
|
||||
$"{message.MessageId} x{message.DequeueCount}. {e.Message}", e);
|
||||
if(message.DequeueCount > 2)
|
||||
if (message.DequeueCount > 2)
|
||||
{
|
||||
await _queueClient.DeleteMessageAsync(message.MessageId, message.PopReceipt);
|
||||
}
|
||||
@ -86,7 +86,7 @@ namespace Bit.Notifications
|
||||
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError("Error processing messages.", e);
|
||||
}
|
||||
|
@ -31,10 +31,10 @@ namespace Bit.Notifications
|
||||
[SelfHosted(SelfHostedOnly = true)]
|
||||
public async Task PostSend()
|
||||
{
|
||||
using(var reader = new StreamReader(Request.Body, Encoding.UTF8))
|
||||
using (var reader = new StreamReader(Request.Body, Encoding.UTF8))
|
||||
{
|
||||
var notificationJson = await reader.ReadToEndAsync();
|
||||
if(!string.IsNullOrWhiteSpace(notificationJson))
|
||||
if (!string.IsNullOrWhiteSpace(notificationJson))
|
||||
{
|
||||
await HubHelpers.SendNotificationToHubAsync(notificationJson, _hubContext);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace Bit.Notifications
|
||||
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if(_executingTask == null)
|
||||
if (_executingTask == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -51,7 +51,7 @@ namespace Bit.Notifications
|
||||
|
||||
private async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
while(!cancellationToken.IsCancellationRequested)
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
await _hubContext.Clients.All.SendAsync("Heartbeat");
|
||||
await Task.Delay(120000);
|
||||
|
@ -13,7 +13,7 @@ namespace Bit.Notifications
|
||||
IHubContext<NotificationsHub> hubContext, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var notification = JsonConvert.DeserializeObject<PushNotificationData<object>>(notificationJson);
|
||||
switch(notification.Type)
|
||||
switch (notification.Type)
|
||||
{
|
||||
case PushType.SyncCipherUpdate:
|
||||
case PushType.SyncCipherCreate:
|
||||
@ -22,12 +22,12 @@ namespace Bit.Notifications
|
||||
var cipherNotification =
|
||||
JsonConvert.DeserializeObject<PushNotificationData<SyncCipherPushNotification>>(
|
||||
notificationJson);
|
||||
if(cipherNotification.Payload.UserId.HasValue)
|
||||
if (cipherNotification.Payload.UserId.HasValue)
|
||||
{
|
||||
await hubContext.Clients.User(cipherNotification.Payload.UserId.ToString())
|
||||
.SendAsync("ReceiveMessage", cipherNotification, cancellationToken);
|
||||
}
|
||||
else if(cipherNotification.Payload.OrganizationId.HasValue)
|
||||
else if (cipherNotification.Payload.OrganizationId.HasValue)
|
||||
{
|
||||
await hubContext.Clients.Group(
|
||||
$"Organization_{cipherNotification.Payload.OrganizationId}")
|
||||
|
@ -21,9 +21,9 @@ namespace Bit.Notifications
|
||||
{
|
||||
var currentContext = new CurrentContext();
|
||||
currentContext.Build(Context.User, _globalSettings);
|
||||
if(currentContext.Organizations != null)
|
||||
if (currentContext.Organizations != null)
|
||||
{
|
||||
foreach(var org in currentContext.Organizations)
|
||||
foreach (var org in currentContext.Organizations)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
|
||||
}
|
||||
@ -36,9 +36,9 @@ namespace Bit.Notifications
|
||||
{
|
||||
var currentContext = new CurrentContext();
|
||||
currentContext.Build(Context.User, _globalSettings);
|
||||
if(currentContext.Organizations != null)
|
||||
if (currentContext.Organizations != null)
|
||||
{
|
||||
foreach(var org in currentContext.Organizations)
|
||||
foreach (var org in currentContext.Organizations)
|
||||
{
|
||||
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
|
||||
}
|
||||
|
@ -18,25 +18,25 @@ namespace Bit.Notifications
|
||||
logging.AddSerilog(hostingContext, e =>
|
||||
{
|
||||
var context = e.Properties["SourceContext"].ToString();
|
||||
if(context.Contains("IdentityServer4.Validation.TokenValidator") ||
|
||||
if (context.Contains("IdentityServer4.Validation.TokenValidator") ||
|
||||
context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
|
||||
{
|
||||
return e.Level > LogEventLevel.Error;
|
||||
}
|
||||
|
||||
if(e.Level == LogEventLevel.Error &&
|
||||
if (e.Level == LogEventLevel.Error &&
|
||||
e.MessageTemplate.Text == "Failed connection handshake.")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(e.Level == LogEventLevel.Error &&
|
||||
if (e.Level == LogEventLevel.Error &&
|
||||
e.MessageTemplate.Text.StartsWith("Failed writing message."))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(e.Level == LogEventLevel.Warning &&
|
||||
if (e.Level == LogEventLevel.Warning &&
|
||||
e.MessageTemplate.Text.StartsWith("Heartbeat took longer"))
|
||||
{
|
||||
return false;
|
||||
|
@ -57,7 +57,7 @@ namespace Bit.Notifications
|
||||
MessagePack.Resolvers.ContractlessStandardResolver.Instance
|
||||
};
|
||||
});
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.Notifications?.RedisConnectionString))
|
||||
if (CoreHelpers.SettingHasValue(globalSettings.Notifications?.RedisConnectionString))
|
||||
{
|
||||
signalRServerBuilder.AddStackExchangeRedis(globalSettings.Notifications.RedisConnectionString,
|
||||
options =>
|
||||
@ -73,12 +73,12 @@ namespace Bit.Notifications
|
||||
services.AddMvc();
|
||||
|
||||
services.AddHostedService<HeartbeatHostedService>();
|
||||
if(!globalSettings.SelfHosted)
|
||||
if (!globalSettings.SelfHosted)
|
||||
{
|
||||
// Hosted Services
|
||||
Jobs.JobsHostedService.AddJobsServices(services);
|
||||
services.AddHostedService<Jobs.JobsHostedService>();
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.Notifications?.ConnectionString))
|
||||
if (CoreHelpers.SettingHasValue(globalSettings.Notifications?.ConnectionString))
|
||||
{
|
||||
services.AddHostedService<AzureQueueHostedService>();
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace Bit.Notifications
|
||||
IdentityModelEventSource.ShowPII = true;
|
||||
app.UseSerilog(env, appLifetime, globalSettings);
|
||||
|
||||
if(env.IsDevelopment())
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
Reference in New Issue
Block a user