using Hutopy.Web.Common; using Hutopy.Web.Features.Memberships.Data; namespace Hutopy.Web.Features.Memberships.Handlers; [PublicAPI] public record struct TipSentModel( Guid Id, DateTimeOffset CreatedAt, Guid CreatorId, string CreatorName, decimal Amount, string Currency, string Message); [PublicAPI] public class GetSentTipsHandler( MembershipDbContext dbContext) : EndpointWithoutRequest> { public override void Configure() { Get("/api/tips/sent"); Options(o => o.WithTags("Memberships")); } public override async Task HandleAsync( CancellationToken ct) { var tips = await dbContext .Tips .Where(t => t.TipperId == User.GetUserId()) .Select(tip => new TipSentModel( tip.Id, tip.CreatedAt, tip.CreatorId, tip.CreatorName, tip.Amount, tip.Currency, tip.Message)) .ToListAsync(ct); await SendOkAsync(tips, ct); } }