Adds JetBrains.Annotations to reduce amount of false positives by static code analysis
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Data;
|
||||
namespace Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
public class ContentDbContext(
|
||||
DbContextOptions<ContentDbContext> options)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeAboutRequest(
|
||||
Guid CreatorId,
|
||||
string? Title,
|
||||
string? Description);
|
||||
|
||||
[PublicAPI]
|
||||
public class ChangeAboutHandler(
|
||||
ContentDbContext context)
|
||||
: 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.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeBannerRequest(
|
||||
Guid CreatorId,
|
||||
IFormFile File);
|
||||
|
||||
[PublicAPI]
|
||||
public class ChangeBannerHandler(
|
||||
IHttpContextAccessor contextAccessor,
|
||||
ContentDbContext context,
|
||||
IBlobStorage blobStorage)
|
||||
: Endpoint<ChangeBannerRequest>
|
||||
@@ -22,7 +21,7 @@ public class ChangeBannerHandler(
|
||||
Options(o => o.WithTags("Contents"));
|
||||
AllowFileUploads();
|
||||
}
|
||||
|
||||
|
||||
public override async Task HandleAsync(ChangeBannerRequest request, CancellationToken ct)
|
||||
{
|
||||
var creator = await context
|
||||
@@ -37,7 +36,7 @@ public class ChangeBannerHandler(
|
||||
await SendNotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO: this upload should be done to the Creators container
|
||||
var blobUrl = await blobStorage.UploadFileAsync(
|
||||
ContainerNames.Users,
|
||||
@@ -45,11 +44,11 @@ public class ChangeBannerHandler(
|
||||
request.File.OpenReadStream(),
|
||||
request.File.ContentType,
|
||||
ct);
|
||||
|
||||
|
||||
creator.Images.Banner = blobUrl;
|
||||
|
||||
|
||||
await context.SaveChangesAsync(ct);
|
||||
|
||||
|
||||
await SendOkAsync(blobUrl, ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeColorsRequest(
|
||||
Guid CreatorId,
|
||||
string? BannerTop,
|
||||
@@ -12,7 +10,8 @@ public record ChangeColorsRequest(
|
||||
string? Accent,
|
||||
string? Menu);
|
||||
|
||||
public sealed class ChangeColorsRequestValidator
|
||||
[PublicAPI]
|
||||
public sealed class ChangeColorsRequestValidator
|
||||
: Validator<ChangeColorsRequest>
|
||||
{
|
||||
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.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeLogoRequest(
|
||||
Guid CreatorId,
|
||||
IFormFile File);
|
||||
|
||||
[PublicAPI]
|
||||
public class ChangeLogoHandler(
|
||||
IHttpContextAccessor contextAccessor,
|
||||
ContentDbContext context,
|
||||
IBlobStorage blobStorage)
|
||||
: Endpoint<ChangeLogoRequest>
|
||||
@@ -22,7 +21,7 @@ public class ChangeLogoHandler(
|
||||
Options(o => o.WithTags("Contents"));
|
||||
AllowFileUploads();
|
||||
}
|
||||
|
||||
|
||||
public override async Task HandleAsync(ChangeLogoRequest request, CancellationToken ct)
|
||||
{
|
||||
var creator = await context
|
||||
@@ -37,7 +36,7 @@ public class ChangeLogoHandler(
|
||||
await SendNotFoundAsync(ct);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO: this upload should be done to the Creators container
|
||||
var blobUrl = await blobStorage.UploadFileAsync(
|
||||
ContainerNames.Users,
|
||||
@@ -45,11 +44,11 @@ public class ChangeLogoHandler(
|
||||
request.File.OpenReadStream(),
|
||||
request.File.ContentType,
|
||||
ct);
|
||||
|
||||
|
||||
creator.Images.Logo = blobUrl;
|
||||
|
||||
|
||||
await context.SaveChangesAsync(ct);
|
||||
|
||||
|
||||
await SendOkAsync(blobUrl, ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record ChangeSocialsRequest(
|
||||
Guid CreatorId,
|
||||
string? FacebookUrl,
|
||||
@@ -15,6 +14,7 @@ public record ChangeSocialsRequest(
|
||||
string? RedditUrl,
|
||||
string? WebsiteUrl);
|
||||
|
||||
[PublicAPI]
|
||||
public class ChangeSocialsHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<ChangeSocialsRequest>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Web.Common;
|
||||
@@ -8,6 +6,7 @@ using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record PostContentRequest(
|
||||
Guid Id,
|
||||
Guid CreatorId,
|
||||
@@ -15,6 +14,7 @@ public record PostContentRequest(
|
||||
string Description,
|
||||
IFormFileCollection Files);
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class PostContentRequestValidator : Validator<PostContentRequest>
|
||||
{
|
||||
public PostContentRequestValidator()
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public record CreateCreatorRequest(
|
||||
Guid CreatorId,
|
||||
string Name);
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class CreateCreatorRequestValidator : Validator<CreateCreatorRequest>
|
||||
{
|
||||
public CreateCreatorRequestValidator()
|
||||
@@ -23,6 +23,7 @@ public sealed class CreateCreatorRequestValidator : Validator<CreateCreatorReque
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class CreateCreatorHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<CreateCreatorRequest>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetContentRequest
|
||||
{
|
||||
public Guid ContentId { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class GetContent(
|
||||
ContentDbContext context)
|
||||
: Endpoint<GetContentRequest, Content>
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System.Linq.Expressions;
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetContentsByCreatorRequest
|
||||
{
|
||||
public Guid UserId { get; set; }
|
||||
@@ -13,6 +11,7 @@ public sealed class GetContentsByCreatorRequest
|
||||
[BindFrom("last_id")] public Guid? LastId { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class GetContentsByCreatorHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<GetContentsByCreatorRequest, List<ContentModel>>
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetCreatorByAliasRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class GetCreatorByAliasRequestValidator
|
||||
: Validator<GetCreatorByAliasRequest>
|
||||
{
|
||||
@@ -22,6 +21,7 @@ public sealed class GetCreatorByAliasRequestValidator
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class GetCreatorByAliasHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<GetCreatorByAliasRequest, CreatorModel>
|
||||
@@ -54,18 +54,16 @@ public class GetCreatorByAliasHandler(
|
||||
s => s.CreatorId == creator.Id,
|
||||
cancellationToken: ct);
|
||||
|
||||
var model = new CreatorModel
|
||||
{
|
||||
Id = creator.Id,
|
||||
CreatedBy = creator.CreatedBy,
|
||||
CreatedAt = creator.CreatedAt,
|
||||
Name = creator.Name,
|
||||
About = creator.About,
|
||||
Socials = creator.Socials,
|
||||
Colors = creator.Colors,
|
||||
Images = creator.Images,
|
||||
SubscriberCount = subscriberCount,
|
||||
};
|
||||
var model = new CreatorModel(
|
||||
creator.Id,
|
||||
creator.CreatedBy,
|
||||
creator.CreatedAt,
|
||||
creator.Name,
|
||||
creator.About,
|
||||
creator.Socials,
|
||||
creator.Colors,
|
||||
creator.Images,
|
||||
subscriberCount);
|
||||
|
||||
await SendAsync(model, cancellation: ct);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetCreatorByIdRequest
|
||||
{
|
||||
public required Guid CreatorId { get; set; }
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class GetCreatorByIdRequestValidator
|
||||
: Validator<GetCreatorByIdRequest>
|
||||
{
|
||||
@@ -20,6 +20,7 @@ public sealed class GetCreatorByIdRequestValidator
|
||||
}
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class GetCreatorByIdHandler(
|
||||
ContentDbContext context)
|
||||
: 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.Handlers.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public class GetSubscriptionsHandler(
|
||||
ContentDbContext context)
|
||||
: EndpointWithoutRequest<List<SubscriptionModel>>
|
||||
@@ -25,7 +24,7 @@ public class GetSubscriptionsHandler(
|
||||
.Subscriptions
|
||||
.Where(s => s.CreatedBy == userId)
|
||||
.Select(s => new SubscriptionModel(
|
||||
s.CreatorId,
|
||||
s.CreatorId,
|
||||
s.Creator!.Name,
|
||||
s.Creator.Images.Logo))
|
||||
.ToListAsync(cancellationToken: ct);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
|
||||
[PublicAPI]
|
||||
public record struct ContentModel(
|
||||
Guid Id,
|
||||
Guid CreatedBy,
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
|
||||
public class CreatorModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public string Name { get; set; }
|
||||
public About About { get; set; }
|
||||
public Socials Socials { get; set; }
|
||||
public Colors Colors { get; set; }
|
||||
public Images Images { get; set; }
|
||||
public int SubscriberCount { get; set; }
|
||||
}
|
||||
[PublicAPI]
|
||||
public record struct CreatorModel(
|
||||
Guid Id,
|
||||
Guid CreatedBy,
|
||||
DateTimeOffset CreatedAt,
|
||||
string Name,
|
||||
About About,
|
||||
Socials Socials,
|
||||
Colors Colors,
|
||||
Images Images,
|
||||
int SubscriberCount);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
|
||||
[PublicAPI]
|
||||
public record SubscriptionModel(
|
||||
Guid CreatorId,
|
||||
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.Handlers.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class SubscribeToCreatorRequest
|
||||
{
|
||||
public Guid CreatorId { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class SubscribeToCreatorHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<SubscribeToCreatorRequest, SubscriptionModel>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class UnsubscribeFromCreatorRequest
|
||||
{
|
||||
public Guid CreatorId { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class UnsubscribeFromCreatorHandler(
|
||||
ContentDbContext context)
|
||||
: Endpoint<UnsubscribeFromCreatorRequest>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Hutopy.Web.Features.Messages.Handlers.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Messages.Data;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Hutopy.Web.Features.Messages.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Messages;
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Messages.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Messages.Data;
|
||||
|
||||
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;
|
||||
|
||||
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 Microsoft.EntityFrameworkCore;
|
||||
|
||||
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;
|
||||
|
||||
namespace Hutopy.Web.Features.Messages.Handlers;
|
||||
|
||||
Reference in New Issue
Block a user