many fixes and improvements - rework for modules/ and common/
feat(emailer): add Postmark and Resend providers
This commit is contained in:
42
backend/Modules/Messaging/Handlers/GetMessages.cs
Normal file
42
backend/Modules/Messaging/Handlers/GetMessages.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Hutopy.Modules.Messaging.Data;
|
||||
using Hutopy.Modules.Messaging.Models;
|
||||
|
||||
namespace Hutopy.Modules.Messaging.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetMessagesRequest
|
||||
{
|
||||
public Guid SubjectId { get; set; }
|
||||
[BindFrom("page_size")] public int PageSize { get; set; } = 10;
|
||||
[BindFrom("last_id")] public Guid? LastId { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public record struct GetMessagesResponse(
|
||||
IEnumerable<MessageDto> Messages);
|
||||
|
||||
public class GetMessages(
|
||||
MessagingDbContext context)
|
||||
: Endpoint<GetMessagesRequest, GetMessagesResponse>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/messages/{SubjectId:guid}");
|
||||
Options(o => o.WithTags("Messages"));
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
GetMessagesRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var messages = await context.GetMessagesAsync(
|
||||
req.SubjectId,
|
||||
null,
|
||||
req.LastId,
|
||||
req.PageSize,
|
||||
ct);
|
||||
|
||||
await SendOkAsync(new GetMessagesResponse(messages), ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user