Adds AcceptDonation to Creator. Sync Content's Creator to Membership's Creator
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Hutopy.Web.Common.Security;
|
||||
using Hutopy.Web.Features.Memberships.Data;
|
||||
using Hutopy.Web.Features.Memberships.Infrastructure;
|
||||
using Hutopy.Web.Features.Memberships.Events;
|
||||
|
||||
namespace Hutopy.Web.Features.Memberships.Handlers;
|
||||
|
||||
@@ -9,13 +9,12 @@ public record struct ChangeStripeIdRequest(
|
||||
string StripeAccountId);
|
||||
|
||||
public class ChangeStripeIdHandler(
|
||||
MembershipDbContext dbContext,
|
||||
StripeService stripeService)
|
||||
MembershipDbContext dbContext)
|
||||
: Endpoint<ChangeStripeIdRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/creators/stripe-account");
|
||||
Post("/api/membership/stripe-account");
|
||||
Options(o => o.WithTags("Memberships"));
|
||||
}
|
||||
|
||||
@@ -36,17 +35,21 @@ public class ChangeStripeIdHandler(
|
||||
creator = new Creator
|
||||
{
|
||||
Id = creatorId,
|
||||
Name = HttpContext.User.GetAlias() ?? creatorId.ToString()
|
||||
Name = HttpContext.User.GetAlias() ?? creatorId.ToString(),
|
||||
PortraitUrl = HttpContext.User.GetPortraitUrl() ?? string.Empty
|
||||
};
|
||||
|
||||
await dbContext.AddAsync(creator, ct);
|
||||
}
|
||||
|
||||
creator.StripeAccountId = req.StripeAccountId;
|
||||
creator.PortraitUrl = HttpContext.User.GetPortraitUrl();
|
||||
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
|
||||
await PublishAsync(
|
||||
new StripeAccountConfigured(creator.Id, creator.StripeAccountId),
|
||||
cancellation: ct);
|
||||
|
||||
await SendOkAsync(creator.Id, ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using Hutopy.Web.Common.Security;
|
||||
using Hutopy.Web.Features.Memberships.Data;
|
||||
using Hutopy.Web.Features.Memberships.Infrastructure;
|
||||
|
||||
namespace Hutopy.Web.Features.Memberships.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record struct ConfigureStripeAccountRequest(
|
||||
Guid SubscriptionId,
|
||||
string StripeAccountId);
|
||||
|
||||
public class ConfigureStripeAccountHandler(
|
||||
MembershipDbContext dbContext,
|
||||
StripeService stripeService)
|
||||
: Endpoint<ConfigureStripeAccountRequest>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Post("/api/membership/stripe-account");
|
||||
Options(o => o.WithTags("Memberships"));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
ConfigureStripeAccountRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var creatorId = HttpContext.User.GetUserId();
|
||||
|
||||
var creator = await dbContext
|
||||
.Creators
|
||||
.FindAsync(
|
||||
[creatorId],
|
||||
cancellationToken: ct);
|
||||
|
||||
if (creator is null)
|
||||
{
|
||||
creator = new Creator
|
||||
{
|
||||
Id = creatorId,
|
||||
Name = HttpContext.User.GetAlias() ?? creatorId.ToString()
|
||||
};
|
||||
|
||||
await dbContext.AddAsync(creator, ct);
|
||||
}
|
||||
|
||||
creator.StripeAccountId = req.StripeAccountId;
|
||||
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
|
||||
await SendOkAsync(creator.Id, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user