-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/reports #22
Merged
Merged
Feature/reports #22
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7b1dc75
Update publication tags
JonathanDuvalV dfba4f2
Added reports
JonathanDuvalV db2b12f
Merge branch 'main' into feature/reports
JonathanDuvalV 086c21e
Updated time to utc
JonathanDuvalV 03873bb
Merge branch 'main' into feature/reports
JonathanDuvalV 273f914
Add rate limiting
JonathanDuvalV 45576e6
Avoid duplicates
JonathanDuvalV fd6b23c
Also check publication id
JonathanDuvalV fc7a4d3
Added Category, removed Date
JonathanDuvalV 945b1e1
Merge branch 'main' into feature/reports
JonathanDuvalV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace api.core.Data.Enums; | ||
|
||
/// <summary> | ||
/// 1 - InappropriateContent | ||
/// 2 - FalseInformation | ||
/// 3 - AbusiveBehavior | ||
/// 4 - ObsoleteInformation | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
[Flags] | ||
JonathanDuvalV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public enum ReportCategory | ||
{ | ||
InappropriateContent = 1, | ||
FalseInformation = 2, | ||
AbusiveBehavior = 3, | ||
ObsoleteInformation = 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using api.core.Data.Enums; | ||
|
||
namespace api.core.Data.Requests; | ||
|
||
public class CreateReportRequestDTO | ||
{ | ||
public string Reason { get; set; } | ||
|
||
public ReportCategory Category { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using api.core.data.entities; | ||
using api.core.Data.Enums; | ||
|
||
namespace api.core.Data.Responses; | ||
|
||
public class ReportResponseDTO | ||
{ | ||
public Guid Id { get; set; } | ||
|
||
public string Reason { get; set; } | ||
|
||
public ReportCategory Category { get; set; } | ||
|
||
public EventResponseDTO Publication { get; set; } | ||
|
||
public DateTime CreatedAt { get; set; } | ||
|
||
public DateTime UpdatedAt { get; set; } | ||
|
||
public static ReportResponseDTO Map(Report report) | ||
{ | ||
return new ReportResponseDTO | ||
{ | ||
Id = report.Id, | ||
Reason = report.Reason, | ||
Category = report.Category, | ||
CreatedAt = report.CreatedAt, | ||
UpdatedAt = report.UpdatedAt, | ||
Publication = new EventResponseDTO | ||
{ | ||
Id = report.Publication.Id, | ||
Title = report.Publication.Title, | ||
Content = report.Publication.Content, | ||
ImageUrl = report.Publication.ImageUrl, | ||
ImageAltText = report.Publication.ImageAltText, | ||
Tags = report.Publication.Tags.Select(TagResponseDTO.Map), | ||
State = report.Publication.State, | ||
PublicationDate = report.Publication.PublicationDate, | ||
CreatedAt = report.Publication.CreatedAt, | ||
UpdatedAt = report.Publication.UpdatedAt, | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Threading.RateLimiting; | ||
|
||
using api.core.controllers; | ||
|
||
using Microsoft.AspNetCore.RateLimiting; | ||
|
||
namespace api.core.Extensions; | ||
|
||
public static class RateLimiterExtension | ||
{ | ||
public static IServiceCollection AddRateLimiters(this IServiceCollection services) | ||
JonathanDuvalV marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
services.AddRateLimiter(options => | ||
{ | ||
var windowInSeconds = int.Parse(Environment.GetEnvironmentVariable("RATE_LIMIT_TIME_WINDOW_SECONDS") ?? "10"); | ||
var permitLimit = int.Parse(Environment.GetEnvironmentVariable("RATE_LIMIT_MAX_REQUESTS") ?? "4"); | ||
|
||
var window = TimeSpan.FromSeconds(windowInSeconds); | ||
|
||
options.AddFixedWindowLimiter(EventsController.RATE_LIMITING_POLICY_NAME, limiterOptions => | ||
{ | ||
limiterOptions.PermitLimit = permitLimit; | ||
limiterOptions.QueueProcessingOrder = QueueProcessingOrder.OldestFirst; | ||
limiterOptions.QueueLimit = 0; | ||
limiterOptions.Window = window; | ||
}); | ||
}); | ||
|
||
return services; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quand la PR avec les policy va etre merger, je vais retirer ca!