Skip to content

Commit

Permalink
Upgrades to Raven 6 and other Nuget packages
Browse files Browse the repository at this point in the history
  • Loading branch information
JudahGabriel committed Dec 19, 2023
1 parent c2ead13 commit a17b741
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 27 deletions.
20 changes: 10 additions & 10 deletions Chavah.NetCore/Chavah.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.2" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Bet.Extensions.AzureVault" Version="3.1.10" />
<PackageReference Include="Bet.AspNetCore.HealthChecks" Version="3.1.10" />
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="BuildWebCompiler" Version="1.12.405" />
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.4" />
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" />
<PackageReference Include="CoreFtp" Version="1.4.0" />
<PackageReference Include="DalSoft.Hosting.BackgroundQueue" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.1" />
Expand All @@ -43,19 +43,19 @@
</PackageReference>
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageReference Include="Pwned.AspNetCore" Version="2.0.0" />
<PackageReference Include="Quartz" Version="3.2.3" />
<PackageReference Include="RavenDB.Client" Version="5.1.0" />
<PackageReference Include="RavenDB.Identity" Version="8.0.4" />
<PackageReference Include="Quartz" Version="3.8.0" />
<PackageReference Include="RavenDB.Client" Version="6.0.1" />
<PackageReference Include="RavenDB.Identity" Version="8.0.9" />
<PackageReference Include="RavenDB.StructuredLogger" Version="6.0.1" />
<PackageReference Include="RavenMigrations" Version="5.0.0" />
<PackageReference Include="RavenDB.DependencyInjection" Version="4.0.0" />
<PackageReference Include="Sendgrid" Version="9.21.2" />
<PackageReference Include="RavenMigrations" Version="5.0.1" />
<PackageReference Include="RavenDB.DependencyInjection" Version="4.0.2" />
<PackageReference Include="Sendgrid" Version="9.28.1" />
<PackageReference Include="SimpleSitemap" Version="3.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="System.Interactive" Version="5.0.0" />
<PackageReference Include="System.ServiceModel.Syndication" Version="5.0.0" />
<PackageReference Include="WebPush" Version="1.0.11" />
<PackageReference Include="Polly" Version="7.2.1" />
<PackageReference Include="WebPush" Version="1.0.12" />
<PackageReference Include="Polly" Version="8.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Chavah.NetCore/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public async Task<ConfirmEmailResult> ConfirmEmail(string email, string confirmC
if (isValidToken)
{
user.EmailConfirmed = true;
logger.LogInformation("Successfully confirmed new account", email);
logger.LogInformation("Successfully confirmed new account {email}", email);

// Add a welcome notification for the user.
user.AddNotification(Notification.Welcome(appOptions.AuthorImageUrl));
Expand Down
26 changes: 18 additions & 8 deletions Chavah.NetCore/Controllers/IftttController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

using Raven.Client.Documents;
using Raven.Client.Documents.Session;
using System.Collections.Generic;

namespace BitShuva.Chavah.Controllers
{
Expand Down Expand Up @@ -79,7 +80,7 @@ public async Task<ActionResult> GetRegisteredUsers(string key)
}

[HttpPost]
public IActionResult CreateNotification(string secretToken, string title, string? imgUrl, string sourceName, string url)
public async Task<IActionResult> CreateNotification(string secretToken, string title, string? imgUrl, string sourceName, string url)
{
AuthorizeKey(secretToken);

Expand Down Expand Up @@ -108,7 +109,7 @@ public IActionResult CreateNotification(string secretToken, string title, string
Url = url
};

AddNotificationToAllUsers(notification);
await AddNotificationToAllUsers(notification);

// Send out HTML5 push notifications.
var pushNotification = new PushNotification
Expand Down Expand Up @@ -220,16 +221,25 @@ private string GetRandomLyricSection(Song song)
return lyricsSection;
}

private void AddNotificationToAllUsers(Notification notification)
private Task AddNotificationToAllUsers(Notification notification)
{
var jsonNotification = JsonConvert.SerializeObject(notification);
var patchScript = @"
this.Notifications.unshift(" + jsonNotification + @");
if (this.Notifications.length > 10) {
this.Notifications.length = 10;
}
var existingNotification = this.Notifications.find(n => n.Url !== url);
if (!existingNotification) {
this.Notifications.unshift(json);
if (this.Notifications.length > 10) {
this.Notifications.length = 10;
}
}
";
DbSession.Advanced.DocumentStore.PatchAll<AppUser>(patchScript);
var variables = new Dictionary<string, object>
{
{ "url", notification.Url },
{ "json", jsonNotification }
};
var operation = DbSession.Advanced.DocumentStore.PatchAll<AppUser>(patchScript, variables);
return operation.WaitForCompletionAsync(TimeSpan.FromSeconds(60));
}

private void AuthorizeKey(string key)
Expand Down
2 changes: 1 addition & 1 deletion Chavah.NetCore/Controllers/SongEditsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public async Task<SongEdit> Approve([FromBody] SongEdit songEdit)
songEdit.Apply(song);
songEdit.Status = SongEditStatus.Approved;
await DbSession.StoreAsync(songEdit);
logger.LogInformation("Applied song edit", songEdit);
logger.LogInformation("Applied song edit {edit}", songEdit);

// Notify the user.
var user = await DbSession.LoadAsync<AppUser>(songEdit.UserId);
Expand Down
2 changes: 1 addition & 1 deletion Chavah.NetCore/Models/PagedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public PagedList()
Items = new List<T>();
}

public int Total { get; set; }
public long Total { get; set; }
public List<T> Items { get; set; }
public int Skip { get; set; }
public int Take { get; set; }
Expand Down
20 changes: 14 additions & 6 deletions Chavah.NetCore/Services/BlogPostNotificationCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,21 @@ private async Task<Notification> TryAddNotificationAsync(RssFeedItem post)
// Serialize it
var jsonNotification = JsonConvert.SerializeObject(notification);
var patchScript = @"
this.Notifications.unshift(" + jsonNotification + @");
if (this.Notifications.length > 10) {
this.Notifications.length = 10;
}
var existingNotification = this.Notifications.find(n => n.Url !== url);
if (!existingNotification) {
this.Notifications.unshift(json);
if (this.Notifications.length > 10) {
this.Notifications.length = 10;
}
}
";
var patchOperation = docStore.PatchAll<AppUser>(patchScript);
await patchOperation.WaitForCompletionAsync(TimeSpan.FromMinutes(1));
var variables = new Dictionary<string, object>
{
{ "url", notification.Url },
{ "json", jsonNotification }
};
var patchOperation = docStore.PatchAll<AppUser>(patchScript, variables);
await patchOperation.WaitForCompletionAsync(TimeSpan.FromSeconds(30));

return notification;
}
Expand Down
Binary file modified MessiahsMusicFundDisbursement.xlsx
Binary file not shown.

0 comments on commit a17b741

Please sign in to comment.