Skip to content

Commit 8bf3303

Browse files
authored
Merge branch 'main' into feature/#24/create-audit-log-implementation
2 parents e5c4db7 + d0ff385 commit 8bf3303

File tree

9 files changed

+88
-12
lines changed

9 files changed

+88
-12
lines changed

src/bundles/Voxen.Server/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using FastEndpoints.Swagger;
33
using Voxen.Server.Audits.Extensions;
44
using Voxen.Server.Authentication.Extensions;
5+
using Voxen.Server.Channels.Extensions;
56
using Voxen.Server.Domain.Extensions;
67
using Voxen.Server.Extensions;
78
using Voxen.Server.Info.Extensions;
@@ -24,9 +25,7 @@
2425
app
2526
.UseFastEndpoints()
2627
.UseSwaggerGen()
27-
.UseStaticFiles()
28-
.UseAuthentication()
29-
.UseAuthorization();
28+
.UseStaticFiles();
3029

3130
app.UseVoxenAuthentication();
3231
await app.Services.UseVoxenDb();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<ItemGroup>
3+
<PackageReference Include="FastEndpoints" />
34
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
45
</ItemGroup>
56
<ItemGroup>
67
<ProjectReference Include="..\Voxen.Server.Domain\Voxen.Server.Domain.csproj" />
7-
<ProjectReference Include="..\Voxen.Server.Info\Voxen.Server.Info.csproj" />
88
</ItemGroup>
99
</Project>

src/modules/Voxen.Server.Channels/Endpoints/CreateChannel/CreateChannelEndpoint.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Voxen.Server.Domain;
33
using Voxen.Server.Domain.Entities;
44
using Voxen.Server.Domain.Enums;
5-
using Voxen.Server.Endpoints.Channels.CreateChannel;
65

76
namespace Voxen.Server.Channels.Endpoints.CreateChannel;
87

src/modules/Voxen.Server.Channels/Endpoints/CreateChannel/CreateChannelRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Voxen.Server.Domain.Enums;
22

3-
namespace Voxen.Server.Endpoints.Channels.CreateChannel;
3+
namespace Voxen.Server.Channels.Endpoints.CreateChannel;
44

55
/// <summary>
66
/// Represents a request to create a new channel within the server.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using FastEndpoints;
2+
using Microsoft.EntityFrameworkCore;
3+
using Voxen.Server.Domain;
4+
using Voxen.Server.Domain.Constants;
5+
6+
namespace Voxen.Server.Channels.Endpoints.GetChannels;
7+
8+
/// <summary>
9+
/// Retrieve all channels on the server
10+
/// </summary>
11+
public sealed class GetServerInfoEndpoint(VoxenDbContext db) : EndpointWithoutRequest<List<GetChannelsResponse>>
12+
{
13+
/// <inheritdoc />
14+
public override void Configure()
15+
{
16+
Get("/channels");
17+
Roles(RoleGroups.Everyone);
18+
}
19+
20+
/// <inheritdoc />
21+
public override async Task HandleAsync(CancellationToken ct)
22+
{
23+
var channels = await db.Channels
24+
.AsNoTracking()
25+
.Select(c => new GetChannelsResponse
26+
{
27+
Id = c.Id,
28+
Name = c.Name,
29+
CreatedAt = c.CreatedAt,
30+
Type = c.Type
31+
})
32+
.ToListAsync(ct);
33+
34+
await Send.OkAsync(channels, ct);
35+
}
36+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Voxen.Server.Domain.Enums;
2+
3+
namespace Voxen.Server.Channels.Endpoints.GetChannels;
4+
5+
/// <summary>
6+
/// Represents the response containing details about a channel.
7+
/// </summary>
8+
public class GetChannelsResponse
9+
{
10+
/// <summary>
11+
/// Unique identifier for the channel.
12+
/// </summary>
13+
public Guid Id { get; set; }
14+
15+
/// <summary>
16+
/// Channel name.
17+
/// </summary>
18+
public required string Name { get; set; }
19+
20+
/// <summary>
21+
/// Creation timestamp (UTC).
22+
/// </summary>
23+
public DateTime CreatedAt { get; set; }
24+
25+
/// <summary>
26+
/// Channel type.
27+
/// </summary>
28+
public ChannelType Type { get; set; }
29+
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<ItemGroup>
3-
<ProjectReference Include="..\Voxen.Server.Info\Voxen.Server.Info.csproj" />
3+
<PackageReference Include="FastEndpoints" />
4+
</ItemGroup>
5+
<ItemGroup>
6+
<ProjectReference Include="..\Voxen.Server.Domain\Voxen.Server.Domain.csproj" />
47
</ItemGroup>
58
</Project>
9+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Voxen.Server.Domain.Enums;
2+
3+
namespace Voxen.Server.Domain.Constants;
4+
5+
/// <summary>
6+
/// Provides a set of predefined role groups.
7+
/// </summary>
8+
public static class RoleGroups
9+
{
10+
/// <summary>
11+
/// Represents a predefined role group that includes all roles defined in the <see cref="ServerRole"/> enumeration.
12+
/// </summary>
13+
public static readonly string Everyone = string.Join(",", Enum.GetNames<ServerRole>());
14+
}

src/modules/Voxen.Server.Domain/VoxenDbContext.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ protected override void OnModelCreating(ModelBuilder builder)
4242
{
4343
base.OnModelCreating(builder);
4444

45-
builder.Entity<Channel>()
46-
.HasDiscriminator(c => c.Type)
47-
.HasValue<Channel>(ChannelType.Text)
48-
.HasValue<Channel>(ChannelType.Voice);
49-
5045
builder.Entity<Message>()
5146
.HasOne(m => m.Channel)
5247
.WithMany(c => c.Messages)

0 commit comments

Comments
 (0)