Make sure websockets does not throw, fix annying warning of emails

This commit is contained in:
nicolas.dorier
2018-01-12 18:32:46 +09:00
parent 6beb7abfd2
commit 88779e7129
2 changed files with 13 additions and 5 deletions

View File

@@ -262,7 +262,7 @@ namespace BTCPayServer.Controllers
{
await webSocket.SendAsync(DummyBuffer, WebSocketMessageType.Binary, true, cts.Token);
}
catch { await CloseSocket(webSocket); }
catch { try { webSocket.Dispose(); } catch { } }
}
private static async Task CloseSocket(WebSocket webSocket)
@@ -277,7 +277,7 @@ namespace BTCPayServer.Controllers
}
}
catch { }
finally { webSocket.Dispose(); }
finally { try { webSocket.Dispose(); } catch { } }
}
[HttpPost]

View File

@@ -1,4 +1,6 @@
using Hangfire;
using BTCPayServer.Logging;
using Microsoft.Extensions.Logging;
using Hangfire;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,10 +22,16 @@ namespace BTCPayServer.Services.Mails
_JobClient = jobClient;
_Repository = repository;
}
public Task SendEmailAsync(string email, string subject, string message)
public async Task SendEmailAsync(string email, string subject, string message)
{
var settings = await _Repository.GetSettingAsync<EmailSettings>();
if (settings == null)
{
Logs.Configuration.LogWarning("Should have sent email, but email settings are not configured");
return;
}
_JobClient.Schedule(() => SendMailCore(email, subject, message), TimeSpan.Zero);
return Task.CompletedTask;
return;
}
public async Task SendMailCore(string email, string subject, string message)