1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-16 01:51:21 +01:00

update libs and remove old code/workarounds

This commit is contained in:
Kyle Spearrin 2019-02-26 08:15:56 -05:00
parent 8a0a39f068
commit 35e986a077
6 changed files with 19 additions and 43 deletions

View File

@ -14,14 +14,14 @@
<ItemGroup>
<PackageReference Include="Handlebars.Net" Version="1.9.5" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
<PackageReference Include="MailKit" Version="2.1.2" />
<PackageReference Include="MailKit" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.3" />
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="2.0.1" />
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.3" />
@ -39,7 +39,7 @@
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
<PackageReference Include="Braintree" Version="4.9.0" />
<PackageReference Include="Sendgrid" Version="9.10.0" />
<PackageReference Include="Stripe.net" Version="23.0.0" />
<PackageReference Include="Stripe.net" Version="24.0.2" />
<PackageReference Include="U2F.Core" Version="1.0.4" />
<PackageReference Include="Otp.NET" Version="1.2.1" />
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" />

View File

@ -16,7 +16,6 @@ namespace Bit.Core.Services
private readonly IHttpContextAccessor _httpContextAccessor;
private NotificationHubClient _client = null;
private DateTime? _clientExpires = null;
public NotificationHubPushNotificationService(
GlobalSettings globalSettings,
@ -24,6 +23,9 @@ namespace Bit.Core.Services
{
_globalSettings = globalSettings;
_httpContextAccessor = httpContextAccessor;
_client = NotificationHubClient.CreateClientFromConnectionString(
_globalSettings.NotificationHub.ConnectionString,
_globalSettings.NotificationHub.HubName);
}
public async Task PushSyncCipherCreateAsync(Cipher cipher, IEnumerable<Guid> collectionIds)
@ -175,25 +177,12 @@ namespace Bit.Core.Services
private async Task SendPayloadAsync(string tag, PushType type, object payload)
{
await RenewClientAndExecuteAsync(async client => await client.SendTemplateNotificationAsync(
await _client.SendTemplateNotificationAsync(
new Dictionary<string, string>
{
{ "type", ((byte)type).ToString() },
{ "payload", JsonConvert.SerializeObject(payload) }
}, tag));
}
private async Task RenewClientAndExecuteAsync(Func<NotificationHubClient, Task> task)
{
var now = DateTime.UtcNow;
if(_client == null || !_clientExpires.HasValue || _clientExpires.Value < now)
{
_clientExpires = now.Add(TimeSpan.FromMinutes(30));
_client = NotificationHubClient.CreateClientFromConnectionString(
_globalSettings.NotificationHub.ConnectionString,
_globalSettings.NotificationHub.HubName);
}
await task(_client);
}, tag);
}
}
}

View File

@ -12,12 +12,14 @@ namespace Bit.Core.Services
private readonly GlobalSettings _globalSettings;
private NotificationHubClient _client = null;
private DateTime? _clientExpires = null;
public NotificationHubPushRegistrationService(
GlobalSettings globalSettings)
{
_globalSettings = globalSettings;
_client = NotificationHubClient.CreateClientFromConnectionString(
_globalSettings.NotificationHub.ConnectionString,
_globalSettings.NotificationHub.HubName);
}
public async Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
@ -53,7 +55,7 @@ namespace Bit.Core.Services
messageTemplate = "{\"data\":{\"data\":{\"type\":\"#(type)\"}," +
"\"notification\":{\"title\":\"$(title)\",\"body\":\"$(message)\"}}}";
installation.Platform = NotificationPlatform.Gcm;
installation.Platform = NotificationPlatform.Fcm;
break;
case DeviceType.iOS:
payloadTemplate = "{\"data\":{\"type\":\"#(type)\",\"payload\":\"$(payload)\"}," +
@ -80,8 +82,7 @@ namespace Bit.Core.Services
BuildInstallationTemplate(installation, "badgeMessage", badgeMessageTemplate ?? messageTemplate,
userId, identifier);
await RenewClientAndExecuteAsync(async client =>
await client.CreateOrUpdateInstallationAsync(installation));
await _client.CreateOrUpdateInstallationAsync(installation);
}
private void BuildInstallationTemplate(Installation installation, string templateId, string templateBody,
@ -116,7 +117,7 @@ namespace Bit.Core.Services
{
try
{
await RenewClientAndExecuteAsync(async client => await client.DeleteInstallationAsync(deviceId));
await _client.DeleteInstallationAsync(deviceId);
}
catch(Exception e)
{
@ -165,8 +166,7 @@ namespace Bit.Core.Services
{
try
{
await RenewClientAndExecuteAsync(async client =>
await client.PatchInstallationAsync(id, new List<PartialUpdateOperation> { operation }));
await _client.PatchInstallationAsync(id, new List<PartialUpdateOperation> { operation });
}
catch(Exception e)
{
@ -177,18 +177,5 @@ namespace Bit.Core.Services
}
}
}
private async Task RenewClientAndExecuteAsync(Func<NotificationHubClient, Task> task)
{
var now = DateTime.UtcNow;
if(_client == null || !_clientExpires.HasValue || _clientExpires.Value < now)
{
_clientExpires = now.Add(TimeSpan.FromMinutes(30));
_client = NotificationHubClient.CreateClientFromConnectionString(
_globalSettings.NotificationHub.ConnectionString,
_globalSettings.NotificationHub.HubName);
}
await task(_client);
}
}
}

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AngleSharp" Version="0.9.10" />
<PackageReference Include="AngleSharp" Version="0.11.0" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
</ItemGroup>

View File

@ -6,10 +6,10 @@ using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Bit.Icons.Models;
using AngleSharp.Parser.Html;
using Microsoft.Extensions.Logging;
using System.Text.RegularExpressions;
using System.Text;
using AngleSharp.Html.Parser;
namespace Bit.Icons.Services
{
@ -116,7 +116,7 @@ namespace Bit.Icons.Services
var parser = new HtmlParser();
using(response)
using(var htmlStream = await response.Content.ReadAsStreamAsync())
using(var document = await parser.ParseAsync(htmlStream))
using(var document = await parser.ParseDocumentAsync(htmlStream))
{
uri = response.RequestMessage.RequestUri;
if(document.DocumentElement == null)

View File

@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="1.0.4" />
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.7" />
</ItemGroup>
<ItemGroup>