Adds JetBrains.Annotations to reduce amount of false positives by static code analysis
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
|
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
|
||||||
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.1" />
|
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.1" />
|
||||||
<PackageVersion Include="Google.Apis.Oauth2.v2" Version="1.67.0.1869" />
|
<PackageVersion Include="Google.Apis.Oauth2.v2" Version="1.67.0.1869" />
|
||||||
|
<PackageVersion Include="JetBrains.Annotations" Version="2024.2.0" />
|
||||||
<PackageVersion Include="MediatR" Version="12.2.0" />
|
<PackageVersion Include="MediatR" Version="12.2.0" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.4" />
|
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Facebook" Version="8.0.4" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.4" />
|
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.4" />
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adapted from https://raw.githubusercontent.com/uuidjs/uuid/main/src/v7.ts.
|
/// Adapted from https://raw.githubusercontent.com/uuidjs/uuid/main/src/v7.ts.
|
||||||
/// to match the uuidv7 generated on the client
|
/// to match the uuid v7 generated on the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class GuidHelper
|
public static class GuidHelper
|
||||||
{
|
{
|
||||||
@@ -27,14 +27,14 @@ public static class GuidHelper
|
|||||||
|
|
||||||
var values = V7Bytes(randomValues, State.Msecs, State.Seq);
|
var values = V7Bytes(randomValues, State.Msecs, State.Seq);
|
||||||
|
|
||||||
return new(values);
|
return new Guid(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateV7State(V7State state, long now, byte[] rnds)
|
private static void UpdateV7State(V7State state, long now, byte[] randomBytes)
|
||||||
{
|
{
|
||||||
if (now > state.Msecs)
|
if (now > state.Msecs)
|
||||||
{
|
{
|
||||||
state.Seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
state.Seq = (randomBytes[6] << 23) | (randomBytes[7] << 16) | (randomBytes[8] << 8) | randomBytes[9];
|
||||||
state.Msecs = now;
|
state.Msecs = now;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -47,7 +47,7 @@ public static class GuidHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] V7Bytes(byte[] rnds, long? msecs = null, int? seq = null, byte[] buf = null, int offset = 0)
|
private static byte[] V7Bytes(byte[] randomBytes, long? msecs = null, int? seq = null, byte[]? buf = null, int offset = 0)
|
||||||
{
|
{
|
||||||
if (buf == null)
|
if (buf == null)
|
||||||
{
|
{
|
||||||
@@ -57,7 +57,7 @@ public static class GuidHelper
|
|||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
msecs ??= DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
msecs ??= DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
seq ??= ((rnds[6] & 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9];
|
seq ??= ((randomBytes[6] & 0x7f) << 24) | (randomBytes[7] << 16) | (randomBytes[8] << 8) | randomBytes[9];
|
||||||
|
|
||||||
// byte 0-5: timestamp (48 bits)
|
// byte 0-5: timestamp (48 bits)
|
||||||
buf[offset++] = (byte)((msecs.Value / 0x10000000000) & 0xff);
|
buf[offset++] = (byte)((msecs.Value / 0x10000000000) & 0xff);
|
||||||
@@ -80,14 +80,14 @@ public static class GuidHelper
|
|||||||
buf[offset++] = (byte)((seq.Value >> 6) & 0xff);
|
buf[offset++] = (byte)((seq.Value >> 6) & 0xff);
|
||||||
|
|
||||||
// byte 10: sequence bits 0-5 (6 bits) | random (2 bits)
|
// byte 10: sequence bits 0-5 (6 bits) | random (2 bits)
|
||||||
buf[offset++] = (byte)(((seq.Value << 2) & 0xff) | (rnds[10] & 0x03));
|
buf[offset++] = (byte)(((seq.Value << 2) & 0xff) | (randomBytes[10] & 0x03));
|
||||||
|
|
||||||
// bytes 11-15: random (40 bits)
|
// bytes 11-15: random (40 bits)
|
||||||
buf[offset++] = rnds[11];
|
buf[offset++] = randomBytes[11];
|
||||||
buf[offset++] = rnds[12];
|
buf[offset++] = randomBytes[12];
|
||||||
buf[offset++] = rnds[13];
|
buf[offset++] = randomBytes[13];
|
||||||
buf[offset++] = rnds[14];
|
buf[offset++] = randomBytes[14];
|
||||||
buf[offset++] = rnds[15];
|
buf[offset] = randomBytes[15];
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
namespace Hutopy.Web.Common;
|
namespace Hutopy.Web.Common;
|
||||||
|
|
||||||
public class MissingClaimException(string claimName) : Exception;
|
public class MissingClaimException(
|
||||||
|
string claimName)
|
||||||
|
: Exception;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Hutopy.Web.Controllers;
|
|||||||
|
|
||||||
public class FacebookController(IIdentityService identityService) : Controller
|
public class FacebookController(IIdentityService identityService) : Controller
|
||||||
{
|
{
|
||||||
[HttpGet("/api/facebook/sign-in")]
|
[Microsoft.AspNetCore.Mvc.HttpGet("/api/facebook/sign-in")]
|
||||||
public async Task SignIn()
|
public async Task SignIn()
|
||||||
{
|
{
|
||||||
await HttpContext.ChallengeAsync(FacebookDefaults.AuthenticationScheme,
|
await HttpContext.ChallengeAsync(FacebookDefaults.AuthenticationScheme,
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ public class GoogleController(
|
|||||||
IOptionsSnapshot<JwtOptions> jwtOptions)
|
IOptionsSnapshot<JwtOptions> jwtOptions)
|
||||||
: Controller
|
: Controller
|
||||||
{
|
{
|
||||||
[HttpPost("/api/google/sign-in")]
|
[Microsoft.AspNetCore.Mvc.HttpPost("/api/google/sign-in")]
|
||||||
public async Task<IActionResult> SignIn([FromBody] GoogleSignInRequest request)
|
public async Task<IActionResult> SignIn([Microsoft.AspNetCore.Mvc.FromBody] GoogleSignInRequest request)
|
||||||
{
|
{
|
||||||
using var httpClient = httpClientFactory.CreateClient();
|
using var httpClient = httpClientFactory.CreateClient();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Azure.Identity;
|
using Azure.Identity;
|
||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Infrastructure.Data;
|
using Hutopy.Infrastructure.Data;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
using Hutopy.Web.Services;
|
using Hutopy.Web.Services;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Authentication.Facebook;
|
using Microsoft.AspNetCore.Authentication.Facebook;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Hutopy.Application.Users.Queries.GetCurrentUser;
|
using Hutopy.Application.Users.Queries.GetCurrentUser;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
namespace Hutopy.Web.Endpoints;
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Hutopy.Application.Common.Models;
|
using Hutopy.Application.Common.Models;
|
||||||
using Hutopy.Application.FutureCreators.Commands;
|
using Hutopy.Application.FutureCreators.Commands;
|
||||||
using Hutopy.Application.FutureCreators.Queries;
|
using Hutopy.Application.FutureCreators.Queries;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
namespace Hutopy.Web.Endpoints;
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Hutopy.Application.Stripe.Commands;
|
using Hutopy.Application.Stripe.Commands;
|
||||||
using Hutopy.Application.Stripe.Queries;
|
using Hutopy.Application.Stripe.Queries;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
namespace Hutopy.Web.Endpoints;
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Hutopy.Application.Users.Commands;
|
using Hutopy.Application.Users.Commands;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
namespace Hutopy.Web.Endpoints;
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Hutopy.Application.Users.Commands;
|
using Hutopy.Application.Users.Commands;
|
||||||
using Hutopy.Application.Users.Queries.GetUser;
|
using Hutopy.Application.Users.Queries.GetUser;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
namespace Hutopy.Web.Endpoints;
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
namespace Hutopy.Web.Features.Contents.Data;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Data;
|
|
||||||
|
|
||||||
public class ContentDbContext(
|
public class ContentDbContext(
|
||||||
DbContextOptions<ContentDbContext> options)
|
DbContextOptions<ContentDbContext> options)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents;
|
namespace Hutopy.Web.Features.Contents;
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record ChangeAboutRequest(
|
public record ChangeAboutRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
string? Title,
|
string? Title,
|
||||||
string? Description);
|
string? Description);
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class ChangeAboutHandler(
|
public class ChangeAboutHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<ChangeAboutRequest>
|
: Endpoint<ChangeAboutRequest>
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
|
||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record ChangeBannerRequest(
|
public record ChangeBannerRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
IFormFile File);
|
IFormFile File);
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class ChangeBannerHandler(
|
public class ChangeBannerHandler(
|
||||||
IHttpContextAccessor contextAccessor,
|
|
||||||
ContentDbContext context,
|
ContentDbContext context,
|
||||||
IBlobStorage blobStorage)
|
IBlobStorage blobStorage)
|
||||||
: Endpoint<ChangeBannerRequest>
|
: Endpoint<ChangeBannerRequest>
|
||||||
@@ -22,7 +21,7 @@ public class ChangeBannerHandler(
|
|||||||
Options(o => o.WithTags("Contents"));
|
Options(o => o.WithTags("Contents"));
|
||||||
AllowFileUploads();
|
AllowFileUploads();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(ChangeBannerRequest request, CancellationToken ct)
|
public override async Task HandleAsync(ChangeBannerRequest request, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var creator = await context
|
var creator = await context
|
||||||
@@ -37,7 +36,7 @@ public class ChangeBannerHandler(
|
|||||||
await SendNotFoundAsync(ct);
|
await SendNotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this upload should be done to the Creators container
|
// TODO: this upload should be done to the Creators container
|
||||||
var blobUrl = await blobStorage.UploadFileAsync(
|
var blobUrl = await blobStorage.UploadFileAsync(
|
||||||
ContainerNames.Users,
|
ContainerNames.Users,
|
||||||
@@ -45,11 +44,11 @@ public class ChangeBannerHandler(
|
|||||||
request.File.OpenReadStream(),
|
request.File.OpenReadStream(),
|
||||||
request.File.ContentType,
|
request.File.ContentType,
|
||||||
ct);
|
ct);
|
||||||
|
|
||||||
creator.Images.Banner = blobUrl;
|
creator.Images.Banner = blobUrl;
|
||||||
|
|
||||||
await context.SaveChangesAsync(ct);
|
await context.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await SendOkAsync(blobUrl, ct);
|
await SendOkAsync(blobUrl, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record ChangeColorsRequest(
|
public record ChangeColorsRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
string? BannerTop,
|
string? BannerTop,
|
||||||
@@ -12,7 +10,8 @@ public record ChangeColorsRequest(
|
|||||||
string? Accent,
|
string? Accent,
|
||||||
string? Menu);
|
string? Menu);
|
||||||
|
|
||||||
public sealed class ChangeColorsRequestValidator
|
[PublicAPI]
|
||||||
|
public sealed class ChangeColorsRequestValidator
|
||||||
: Validator<ChangeColorsRequest>
|
: Validator<ChangeColorsRequest>
|
||||||
{
|
{
|
||||||
public ChangeColorsRequestValidator()
|
public ChangeColorsRequestValidator()
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
|
||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record ChangeLogoRequest(
|
public record ChangeLogoRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
IFormFile File);
|
IFormFile File);
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class ChangeLogoHandler(
|
public class ChangeLogoHandler(
|
||||||
IHttpContextAccessor contextAccessor,
|
|
||||||
ContentDbContext context,
|
ContentDbContext context,
|
||||||
IBlobStorage blobStorage)
|
IBlobStorage blobStorage)
|
||||||
: Endpoint<ChangeLogoRequest>
|
: Endpoint<ChangeLogoRequest>
|
||||||
@@ -22,7 +21,7 @@ public class ChangeLogoHandler(
|
|||||||
Options(o => o.WithTags("Contents"));
|
Options(o => o.WithTags("Contents"));
|
||||||
AllowFileUploads();
|
AllowFileUploads();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task HandleAsync(ChangeLogoRequest request, CancellationToken ct)
|
public override async Task HandleAsync(ChangeLogoRequest request, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var creator = await context
|
var creator = await context
|
||||||
@@ -37,7 +36,7 @@ public class ChangeLogoHandler(
|
|||||||
await SendNotFoundAsync(ct);
|
await SendNotFoundAsync(ct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this upload should be done to the Creators container
|
// TODO: this upload should be done to the Creators container
|
||||||
var blobUrl = await blobStorage.UploadFileAsync(
|
var blobUrl = await blobStorage.UploadFileAsync(
|
||||||
ContainerNames.Users,
|
ContainerNames.Users,
|
||||||
@@ -45,11 +44,11 @@ public class ChangeLogoHandler(
|
|||||||
request.File.OpenReadStream(),
|
request.File.OpenReadStream(),
|
||||||
request.File.ContentType,
|
request.File.ContentType,
|
||||||
ct);
|
ct);
|
||||||
|
|
||||||
creator.Images.Logo = blobUrl;
|
creator.Images.Logo = blobUrl;
|
||||||
|
|
||||||
await context.SaveChangesAsync(ct);
|
await context.SaveChangesAsync(ct);
|
||||||
|
|
||||||
await SendOkAsync(blobUrl, ct);
|
await SendOkAsync(blobUrl, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record ChangeSocialsRequest(
|
public record ChangeSocialsRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
string? FacebookUrl,
|
string? FacebookUrl,
|
||||||
@@ -15,6 +14,7 @@ public record ChangeSocialsRequest(
|
|||||||
string? RedditUrl,
|
string? RedditUrl,
|
||||||
string? WebsiteUrl);
|
string? WebsiteUrl);
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class ChangeSocialsHandler(
|
public class ChangeSocialsHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<ChangeSocialsRequest>
|
: Endpoint<ChangeSocialsRequest>
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using FastEndpoints;
|
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Web.Common;
|
using Hutopy.Web.Common;
|
||||||
@@ -8,6 +6,7 @@ using Hutopy.Web.Features.Contents.Data;
|
|||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record PostContentRequest(
|
public record PostContentRequest(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
@@ -15,6 +14,7 @@ public record PostContentRequest(
|
|||||||
string Description,
|
string Description,
|
||||||
IFormFileCollection Files);
|
IFormFileCollection Files);
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class PostContentRequestValidator : Validator<PostContentRequest>
|
public sealed class PostContentRequestValidator : Validator<PostContentRequest>
|
||||||
{
|
{
|
||||||
public PostContentRequestValidator()
|
public PostContentRequestValidator()
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record CreateCreatorRequest(
|
public record CreateCreatorRequest(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
string Name);
|
string Name);
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
public sealed class CreateCreatorRequestValidator : Validator<CreateCreatorRequest>
|
public sealed class CreateCreatorRequestValidator : Validator<CreateCreatorRequest>
|
||||||
{
|
{
|
||||||
public CreateCreatorRequestValidator()
|
public CreateCreatorRequestValidator()
|
||||||
@@ -23,6 +23,7 @@ public sealed class CreateCreatorRequestValidator : Validator<CreateCreatorReque
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class CreateCreatorHandler(
|
public sealed class CreateCreatorHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<CreateCreatorRequest>
|
: Endpoint<CreateCreatorRequest>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class GetContentRequest
|
public sealed class GetContentRequest
|
||||||
{
|
{
|
||||||
public Guid ContentId { get; set; }
|
public Guid ContentId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class GetContent(
|
public class GetContent(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<GetContentRequest, Content>
|
: Endpoint<GetContentRequest, Content>
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
using System.Linq.Expressions;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using FastEndpoints;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class GetContentsByCreatorRequest
|
public sealed class GetContentsByCreatorRequest
|
||||||
{
|
{
|
||||||
public Guid UserId { get; set; }
|
public Guid UserId { get; set; }
|
||||||
@@ -13,6 +11,7 @@ public sealed class GetContentsByCreatorRequest
|
|||||||
[BindFrom("last_id")] public Guid? LastId { get; set; }
|
[BindFrom("last_id")] public Guid? LastId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class GetContentsByCreatorHandler(
|
public class GetContentsByCreatorHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<GetContentsByCreatorRequest, List<ContentModel>>
|
: Endpoint<GetContentsByCreatorRequest, List<ContentModel>>
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class GetCreatorByAliasRequest
|
public sealed class GetCreatorByAliasRequest
|
||||||
{
|
{
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
public sealed class GetCreatorByAliasRequestValidator
|
public sealed class GetCreatorByAliasRequestValidator
|
||||||
: Validator<GetCreatorByAliasRequest>
|
: Validator<GetCreatorByAliasRequest>
|
||||||
{
|
{
|
||||||
@@ -22,6 +21,7 @@ public sealed class GetCreatorByAliasRequestValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class GetCreatorByAliasHandler(
|
public class GetCreatorByAliasHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<GetCreatorByAliasRequest, CreatorModel>
|
: Endpoint<GetCreatorByAliasRequest, CreatorModel>
|
||||||
@@ -54,18 +54,16 @@ public class GetCreatorByAliasHandler(
|
|||||||
s => s.CreatorId == creator.Id,
|
s => s.CreatorId == creator.Id,
|
||||||
cancellationToken: ct);
|
cancellationToken: ct);
|
||||||
|
|
||||||
var model = new CreatorModel
|
var model = new CreatorModel(
|
||||||
{
|
creator.Id,
|
||||||
Id = creator.Id,
|
creator.CreatedBy,
|
||||||
CreatedBy = creator.CreatedBy,
|
creator.CreatedAt,
|
||||||
CreatedAt = creator.CreatedAt,
|
creator.Name,
|
||||||
Name = creator.Name,
|
creator.About,
|
||||||
About = creator.About,
|
creator.Socials,
|
||||||
Socials = creator.Socials,
|
creator.Colors,
|
||||||
Colors = creator.Colors,
|
creator.Images,
|
||||||
Images = creator.Images,
|
subscriberCount);
|
||||||
SubscriberCount = subscriberCount,
|
|
||||||
};
|
|
||||||
|
|
||||||
await SendAsync(model, cancellation: ct);
|
await SendAsync(model, cancellation: ct);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class GetCreatorByIdRequest
|
public sealed class GetCreatorByIdRequest
|
||||||
{
|
{
|
||||||
public required Guid CreatorId { get; set; }
|
public required Guid CreatorId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
public sealed class GetCreatorByIdRequestValidator
|
public sealed class GetCreatorByIdRequestValidator
|
||||||
: Validator<GetCreatorByIdRequest>
|
: Validator<GetCreatorByIdRequest>
|
||||||
{
|
{
|
||||||
@@ -20,6 +20,7 @@ public sealed class GetCreatorByIdRequestValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class GetCreatorByIdHandler(
|
public class GetCreatorByIdHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<GetCreatorByIdRequest, Creator>
|
: Endpoint<GetCreatorByIdRequest, Creator>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class GetSubscriptionsHandler(
|
public class GetSubscriptionsHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: EndpointWithoutRequest<List<SubscriptionModel>>
|
: EndpointWithoutRequest<List<SubscriptionModel>>
|
||||||
@@ -25,7 +24,7 @@ public class GetSubscriptionsHandler(
|
|||||||
.Subscriptions
|
.Subscriptions
|
||||||
.Where(s => s.CreatedBy == userId)
|
.Where(s => s.CreatedBy == userId)
|
||||||
.Select(s => new SubscriptionModel(
|
.Select(s => new SubscriptionModel(
|
||||||
s.CreatorId,
|
s.CreatorId,
|
||||||
s.Creator!.Name,
|
s.Creator!.Name,
|
||||||
s.Creator.Images.Logo))
|
s.Creator.Images.Logo))
|
||||||
.ToListAsync(cancellationToken: ct);
|
.ToListAsync(cancellationToken: ct);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record struct ContentModel(
|
public record struct ContentModel(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
Guid CreatedBy,
|
Guid CreatedBy,
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
|
|
||||||
public class CreatorModel
|
[PublicAPI]
|
||||||
{
|
public record struct CreatorModel(
|
||||||
public Guid Id { get; set; }
|
Guid Id,
|
||||||
public Guid CreatedBy { get; set; }
|
Guid CreatedBy,
|
||||||
public DateTimeOffset CreatedAt { get; set; }
|
DateTimeOffset CreatedAt,
|
||||||
public string Name { get; set; }
|
string Name,
|
||||||
public About About { get; set; }
|
About About,
|
||||||
public Socials Socials { get; set; }
|
Socials Socials,
|
||||||
public Colors Colors { get; set; }
|
Colors Colors,
|
||||||
public Images Images { get; set; }
|
Images Images,
|
||||||
public int SubscriberCount { get; set; }
|
int SubscriberCount);
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public record SubscriptionModel(
|
public record SubscriptionModel(
|
||||||
Guid CreatorId,
|
Guid CreatorId,
|
||||||
string CreatorName,
|
string CreatorName,
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class SubscribeToCreatorRequest
|
public sealed class SubscribeToCreatorRequest
|
||||||
{
|
{
|
||||||
public Guid CreatorId { get; set; }
|
public Guid CreatorId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class SubscribeToCreatorHandler(
|
public sealed class SubscribeToCreatorHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<SubscribeToCreatorRequest, SubscriptionModel>
|
: Endpoint<SubscribeToCreatorRequest, SubscriptionModel>
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public sealed class UnsubscribeFromCreatorRequest
|
public sealed class UnsubscribeFromCreatorRequest
|
||||||
{
|
{
|
||||||
public Guid CreatorId { get; set; }
|
public Guid CreatorId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
public class UnsubscribeFromCreatorHandler(
|
public class UnsubscribeFromCreatorHandler(
|
||||||
ContentDbContext context)
|
ContentDbContext context)
|
||||||
: Endpoint<UnsubscribeFromCreatorRequest>
|
: Endpoint<UnsubscribeFromCreatorRequest>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Hutopy.Web.Features.Messages.Handlers.Models;
|
using Hutopy.Web.Features.Messages.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Data;
|
namespace Hutopy.Web.Features.Messages.Data;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Hutopy.Web.Features.Messages.Data;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages;
|
namespace Hutopy.Web.Features.Messages;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Common;
|
||||||
using FluentValidation;
|
|
||||||
using Hutopy.Web.Common;
|
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
|
||||||
using Hutopy.Web.Features.Messages.Handlers.Models;
|
using Hutopy.Web.Features.Messages.Handlers.Models;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
|
||||||
using Hutopy.Web.Features.Messages.Handlers.Models;
|
using Hutopy.Web.Features.Messages.Handlers.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using FastEndpoints;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
|
||||||
using Hutopy.Web.Features.Messages.Handlers.Models;
|
using Hutopy.Web.Features.Messages.Handlers.Models;
|
||||||
|
|
||||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
global using Ardalis.GuardClauses;
|
global using Ardalis.GuardClauses;
|
||||||
global using Hutopy.Web.Infrastructure;
|
global using FastEndpoints;
|
||||||
|
global using FluentValidation;
|
||||||
|
global using JetBrains.Annotations;
|
||||||
global using MediatR;
|
global using MediatR;
|
||||||
|
global using Microsoft.EntityFrameworkCore;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Hutopy.Application.Common.Exceptions;
|
using Hutopy.Application.Common.Exceptions;
|
||||||
using Microsoft.AspNetCore.Diagnostics;
|
using Microsoft.AspNetCore.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using ProblemDetails = Microsoft.AspNetCore.Mvc.ProblemDetails;
|
||||||
|
using ValidationException = Hutopy.Application.Common.Exceptions.ValidationException;
|
||||||
|
|
||||||
namespace Hutopy.Web.Infrastructure;
|
namespace Hutopy.Web.Infrastructure;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
@using Hutopy.Infrastructure.Identity
|
@using Hutopy.Infrastructure.Identity
|
||||||
@using Microsoft.AspNetCore.Identity
|
@using Microsoft.AspNetCore.Identity
|
||||||
|
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
@inject SignInManager<ApplicationUser> SignInManager
|
@inject SignInManager<ApplicationUser> SignInManager
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Azure.Identity;
|
using Azure.Identity;
|
||||||
using FastEndpoints;
|
|
||||||
using Hutopy.Application;
|
using Hutopy.Application;
|
||||||
using Hutopy.Infrastructure;
|
using Hutopy.Infrastructure;
|
||||||
using Hutopy.Infrastructure.Data;
|
using Hutopy.Infrastructure.Data;
|
||||||
@@ -9,8 +8,8 @@ using Hutopy.Web.Features.Contents;
|
|||||||
using Hutopy.Web.Features.Contents.Data;
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Messages;
|
using Hutopy.Web.Features.Messages;
|
||||||
using Hutopy.Web.Features.Messages.Data;
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
|
using Hutopy.Web.Infrastructure;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NSwag;
|
using NSwag;
|
||||||
using NSwag.Generation.AspNetCore.Processors;
|
using NSwag.Generation.AspNetCore.Processors;
|
||||||
using NSwag.Generation.Processors.Security;
|
using NSwag.Generation.Processors.Security;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
|
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
|
||||||
<PackageReference Include="Azure.Identity" />
|
<PackageReference Include="Azure.Identity" />
|
||||||
<PackageReference Include="FastEndpoints" />
|
<PackageReference Include="FastEndpoints" />
|
||||||
|
<PackageReference Include="JetBrains.Annotations" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||||
|
|||||||
Reference in New Issue
Block a user