Skip to content

Commit

Permalink
Update CT GlobalPermissions DTO and update packages (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-lerch authored Feb 16, 2025
1 parent 21d6fb0 commit 336c925
Show file tree
Hide file tree
Showing 8 changed files with 750 additions and 923 deletions.
2 changes: 1 addition & 1 deletion server/ChurchTools/ChurchToolsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static async ValueTask<ChurchToolsApi> Login(string host, string username

try
{
return await Login(new(), host, username, password);
return await Login(httpClient, host, username, password);
}
catch
{
Expand Down
416 changes: 235 additions & 181 deletions server/ChurchTools/Model/GlobalPermissions.cs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions server/Korga.Tests/ChurchToolsApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ public async Task TestCreateWithToken()
// This call fails if client is not authenticated
await client.GetPerson();
}

[Fact]
public async Task TestGetGlobalPermissions()
{
using ChurchToolsApi client = await ChurchToolsApi.Login(churchToolsHost, churchToolsUsername, churchToolsPassword);

await client.GetGlobalPermissions();
}
}
8 changes: 4 additions & 4 deletions server/Korga.Tests/Korga.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
18 changes: 18 additions & 0 deletions server/Korga/ChurchTools/ChurchToolsPermissionsHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ protected override async Task ExecuteAsync(CancellationToken cancellationToken)

private async ValueTask CheckSyncPermissions(GlobalPermissions permissions, IChurchToolsApi churchTools, CancellationToken cancellationToken)
{
if (permissions.ChurchDb == null)
{
logger.LogWarning("ChurchTools people and groups module is disabled. Sync will not work.");
return;
}

if (!permissions.ChurchCore.AdministerPersons)
logger.LogWarning("ChurchTools user does not have permission 'churchcore:administer persons'. Sync will not work.");
if (!permissions.ChurchDb.View)
Expand Down Expand Up @@ -71,6 +77,18 @@ private async ValueTask CheckSyncPermissions(GlobalPermissions permissions, IChu

private void CheckServiceHistoryPermissions(GlobalPermissions permissions)
{
if (permissions.ChurchDb == null)
{
logger.LogWarning("ChurchTools people and groups module is disabled. Event history will not work.");
return;
}

if (permissions.ChurchService == null)
{
logger.LogWarning("ChurchTools events module is disabled. Event history will not work.");
return;
}

if (!permissions.ChurchDb.EditGroupMemberships)
// https://forum.church.tools/topic/10368/berechtigungen-f%C3%BCr-groups-groupid-members-endpunkt
logger.LogWarning("ChurchTools user does not have permission 'churchdb:edit group memberships'. Event history will not show comments.");
Expand Down
10 changes: 5 additions & 5 deletions server/Korga/Korga.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MailKit" Version="4.9.0" />
<PackageReference Include="MailKit" Version="4.10.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11">
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.12" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.12" />
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="NSwag.AspNetCore" Version="14.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
Expand Down
Loading

0 comments on commit 336c925

Please sign in to comment.