From cb7ca6259037b12618b9c42c6b6f0768af6dbc5f Mon Sep 17 00:00:00 2001 From: limited_dev Date: Sat, 11 Feb 2023 23:04:02 +0100 Subject: [PATCH] feat: added images for ban screen, added reportscreen, added reportsscreen for mods & admins --- ImageBoardServerApp/App.razor | 2 +- ImageBoardServerApp/Data/ReportData.cs | 3 +- .../Data/Repository/ImagesRepository.cs | 2 +- .../Data/Repository/ReportsRepository.cs | 10 ++- ImageBoardServerApp/Data/Rules/Rules.cs | 13 +++ ImageBoardServerApp/Data/Rules/RulesConv.cs | 28 ++++++ .../ImageBoardServerApp.csproj | 7 ++ .../Pages/Accounts/Banned.razor | 14 +++ .../Pages/Accounts/Banned.razor.css | 6 ++ .../Pages/Accounts/Login.razor | 3 +- .../Pages/Accounts/Register.razor | 2 +- ImageBoardServerApp/Pages/Basic/Rules.razor | 11 +-- ImageBoardServerApp/Pages/Boards/Art.razor | 15 ++++ .../Pages/Boards/Art.razor.css | 7 ++ ImageBoardServerApp/Pages/Boards/M.razor | 2 - ImageBoardServerApp/Pages/Boards/M.razor.css | 4 + ImageBoardServerApp/Pages/Boards/Tec.razor | 15 ++++ .../Pages/Boards/Tec.razor.css | 7 ++ ImageBoardServerApp/Pages/Boards/Vg.razor | 15 ++++ ImageBoardServerApp/Pages/Boards/Vg.razor.css | 7 ++ .../Pages/Components/ReportPage.razor | 80 +++++++++++++++++- .../Pages/Components/ReportPage.razor.css | 13 +++ .../Pages/Moderation/ReportsPage.razor | 16 +++- .../Shared/Components/Board.razor | 7 -- .../Shared/Components/Forms/FormInfo.razor | 18 ++-- .../Shared/Components/Report.razor | 47 ++++++++++ .../Shared/Components/Reports.razor | 5 -- ImageBoardServerApp/Shared/MainLayout.razor | 9 -- ImageBoardServerApp/Shared/NavMenu.razor | 36 +++++++- .../wwwroot/img/static/banned/1.png | Bin 0 -> 50686 bytes .../wwwroot/img/static/banned/10.png | Bin 0 -> 35499 bytes .../wwwroot/img/static/banned/2.png | Bin 0 -> 148416 bytes .../wwwroot/img/static/banned/3.png | Bin 0 -> 138813 bytes .../wwwroot/img/static/banned/4.png | Bin 0 -> 694045 bytes .../wwwroot/img/static/banned/5.png | Bin 0 -> 123684 bytes .../wwwroot/img/static/banned/6.png | Bin 0 -> 251740 bytes .../wwwroot/img/static/banned/7.png | Bin 0 -> 379306 bytes .../wwwroot/img/static/banned/8.png | Bin 0 -> 183719 bytes .../wwwroot/img/static/banned/9.png | Bin 0 -> 1378578 bytes .../wwwroot/img/static/err/1.jpeg | Bin 55303 -> 0 bytes .../wwwroot/img/static/err/1.png | Bin 0 -> 533337 bytes .../wwwroot/img/static/err/2.png | Bin 0 -> 497754 bytes .../wwwroot/img/static/err/3.png | Bin 0 -> 1130122 bytes 43 files changed, 358 insertions(+), 46 deletions(-) create mode 100644 ImageBoardServerApp/Data/Rules/Rules.cs create mode 100644 ImageBoardServerApp/Data/Rules/RulesConv.cs create mode 100644 ImageBoardServerApp/Pages/Accounts/Banned.razor create mode 100644 ImageBoardServerApp/Pages/Accounts/Banned.razor.css create mode 100644 ImageBoardServerApp/Pages/Boards/Art.razor create mode 100644 ImageBoardServerApp/Pages/Boards/Art.razor.css create mode 100644 ImageBoardServerApp/Pages/Boards/Tec.razor create mode 100644 ImageBoardServerApp/Pages/Boards/Tec.razor.css create mode 100644 ImageBoardServerApp/Pages/Boards/Vg.razor create mode 100644 ImageBoardServerApp/Pages/Boards/Vg.razor.css create mode 100644 ImageBoardServerApp/Pages/Components/ReportPage.razor.css create mode 100644 ImageBoardServerApp/Shared/Components/Report.razor delete mode 100644 ImageBoardServerApp/Shared/Components/Reports.razor create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/1.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/10.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/2.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/3.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/4.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/5.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/6.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/7.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/8.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/banned/9.png delete mode 100644 ImageBoardServerApp/wwwroot/img/static/err/1.jpeg create mode 100644 ImageBoardServerApp/wwwroot/img/static/err/1.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/err/2.png create mode 100644 ImageBoardServerApp/wwwroot/img/static/err/3.png diff --git a/ImageBoardServerApp/App.razor b/ImageBoardServerApp/App.razor index f3b63cd..81642f6 100644 --- a/ImageBoardServerApp/App.razor +++ b/ImageBoardServerApp/App.razor @@ -9,7 +9,7 @@

404

- noimageFound + noimageFound

Sorry, nothing found. Please go back to the main page. Or watch the tree and find the hidden Cat..

diff --git a/ImageBoardServerApp/Data/ReportData.cs b/ImageBoardServerApp/Data/ReportData.cs index 7f18ab2..fe63066 100644 --- a/ImageBoardServerApp/Data/ReportData.cs +++ b/ImageBoardServerApp/Data/ReportData.cs @@ -37,6 +37,5 @@ public class ReportData public string ReportReason { get; set; } public string ReportExlaination { get; set; } - - + } \ No newline at end of file diff --git a/ImageBoardServerApp/Data/Repository/ImagesRepository.cs b/ImageBoardServerApp/Data/Repository/ImagesRepository.cs index 774fc2d..a3ec045 100644 --- a/ImageBoardServerApp/Data/Repository/ImagesRepository.cs +++ b/ImageBoardServerApp/Data/Repository/ImagesRepository.cs @@ -38,8 +38,8 @@ public static class ImagesRepository public static async Task deleteImageAsync(int imageId) { - await using var db = new AppDBContext(); ImageData imageToDelete = await getImageByIdAsync(imageId); + await using var db = new AppDBContext(); db.Remove(imageToDelete); return await db.SaveChangesAsync() >= 1; } diff --git a/ImageBoardServerApp/Data/Repository/ReportsRepository.cs b/ImageBoardServerApp/Data/Repository/ReportsRepository.cs index 5fc1a36..9e79b6e 100644 --- a/ImageBoardServerApp/Data/Repository/ReportsRepository.cs +++ b/ImageBoardServerApp/Data/Repository/ReportsRepository.cs @@ -7,7 +7,15 @@ public static class ReportsRepository public static async Task> getReportsAsync() { await using var db = new AppDBContext(); - return await db.Reports.ToListAsync(); + return await db.Reports + .Include(report => report.ReportedPost) + .Include(report => report.ReportedPost.Image) + .Include(report => report.ReportedPost.Comments) + .Include(report => report.ReportedComment) + .Include(report => report.ReportedComment.Image) + .Include(report => report.UserReported) + .Include(report => report.UserReporter) + .ToListAsync(); } public static async Task getReportByIdAsync(int reportId) diff --git a/ImageBoardServerApp/Data/Rules/Rules.cs b/ImageBoardServerApp/Data/Rules/Rules.cs new file mode 100644 index 0000000..93e3b4f --- /dev/null +++ b/ImageBoardServerApp/Data/Rules/Rules.cs @@ -0,0 +1,13 @@ +namespace ImageBoardServerApp.Data; + +public enum Rules +{ + AGAINSTLAW, + NSFW_NSFL, + POLITICAL_CONTENT, + RAIDS, + UNDERAGE, + VPN_PROXY_TOR, + OFF_TOPIC, + OTHER, +} \ No newline at end of file diff --git a/ImageBoardServerApp/Data/Rules/RulesConv.cs b/ImageBoardServerApp/Data/Rules/RulesConv.cs new file mode 100644 index 0000000..46f599e --- /dev/null +++ b/ImageBoardServerApp/Data/Rules/RulesConv.cs @@ -0,0 +1,28 @@ +namespace ImageBoardServerApp.Data; + +public class RulesConv +{ + public static Dictionary dict = new Dictionary() + { + { Rules.AGAINSTLAW, "You may not post stuff that would get us into trouble with the feds." }, + { Rules.NSFW_NSFL, "You may not post NSFW / NSFL on this platform." }, + { Rules.POLITICAL_CONTENT, "You may not post political content on this platform." }, + { Rules.RAIDS, "You may not plan or participate in \"raids\" on this platform." }, + { Rules.UNDERAGE, "You have to be atleast 18 years old to post." }, + { Rules.VPN_PROXY_TOR, "You may not post through VPNs, Proxies or the TOR network."}, + { Rules.OFF_TOPIC, "You may not post posts, which are not of the same topic as the target board."}, + { Rules.OTHER, "Other (Please specify)"} + }; + + public static Dictionary dict2 = new Dictionary() + { + { "AGAINSTLAW", Rules.AGAINSTLAW }, + { "NSFW_NSFL", Rules.NSFW_NSFL }, + { "POLITICAL_CONTENT", Rules.POLITICAL_CONTENT }, + { "RAIDS", Rules.RAIDS }, + { "UNDERAGE", Rules.UNDERAGE }, + { "VPN_PROXY_TOR", Rules.VPN_PROXY_TOR }, + { "OFF_TOPIC", Rules.OFF_TOPIC }, + { "OTHER", Rules.OTHER } + }; +} \ No newline at end of file diff --git a/ImageBoardServerApp/ImageBoardServerApp.csproj b/ImageBoardServerApp/ImageBoardServerApp.csproj index 4f3a75d..dc3d83a 100644 --- a/ImageBoardServerApp/ImageBoardServerApp.csproj +++ b/ImageBoardServerApp/ImageBoardServerApp.csproj @@ -19,8 +19,15 @@ + + + + + + + diff --git a/ImageBoardServerApp/Pages/Accounts/Banned.razor b/ImageBoardServerApp/Pages/Accounts/Banned.razor new file mode 100644 index 0000000..563a027 --- /dev/null +++ b/ImageBoardServerApp/Pages/Accounts/Banned.razor @@ -0,0 +1,14 @@ +@page "/banned" +

Banned

+ + + +@code { + + private Random rndm = new Random(); + private string i = ""; + protected override async Task OnInitializedAsync() + { + i = rndm.Next(1, 10) + ".png"; + } +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Accounts/Banned.razor.css b/ImageBoardServerApp/Pages/Accounts/Banned.razor.css new file mode 100644 index 0000000..b9dd837 --- /dev/null +++ b/ImageBoardServerApp/Pages/Accounts/Banned.razor.css @@ -0,0 +1,6 @@ +.image{ + margin: 6px; + max-width: 500px; + max-height: 500px; + padding: 5px; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Accounts/Login.razor b/ImageBoardServerApp/Pages/Accounts/Login.razor index 5483640..801eec0 100644 --- a/ImageBoardServerApp/Pages/Accounts/Login.razor +++ b/ImageBoardServerApp/Pages/Accounts/Login.razor @@ -18,8 +18,9 @@ [Login] - + + @code { private string Email { get; set; } private string Password { get; set; } diff --git a/ImageBoardServerApp/Pages/Accounts/Register.razor b/ImageBoardServerApp/Pages/Accounts/Register.razor index b422d38..a874fc1 100644 --- a/ImageBoardServerApp/Pages/Accounts/Register.razor +++ b/ImageBoardServerApp/Pages/Accounts/Register.razor @@ -41,8 +41,8 @@ { return; } + await UsersRepository.createUserAsync(userToCreate); - Console.WriteLine("loggin you in..."); var user = await UsersRepository.getUserByEmailAsync(Email); if (user == null) { diff --git a/ImageBoardServerApp/Pages/Basic/Rules.razor b/ImageBoardServerApp/Pages/Basic/Rules.razor index 78dcb22..0312696 100644 --- a/ImageBoardServerApp/Pages/Basic/Rules.razor +++ b/ImageBoardServerApp/Pages/Basic/Rules.razor @@ -3,13 +3,10 @@

Rules

    -
  • You may not post stuff that would get us into trouble with the feds.
  • -
  • You may not post NSFW / NSFL on this platform.
  • -
  • You may not post political content on this platform.
  • -
  • You may not plan or participate in "raids" on this platform.
  • -
  • You have to be atleast 18 years old to post.
  • -
  • You may not post through VPNs, Proxies or the TOR network.
  • -
  • You may not post posts, which are not of the same topic as the target board.
  • + @foreach (var r in RulesConv.dict.Keys) + { +
  • @RulesConv.dict[r]
  • + }
diff --git a/ImageBoardServerApp/Pages/Boards/Art.razor b/ImageBoardServerApp/Pages/Boards/Art.razor new file mode 100644 index 0000000..0de1f7a --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Art.razor @@ -0,0 +1,15 @@ +@page "/art/" + + + + +@code { + + private BoardData m { get; set; } = new() + { + BoardID = 0, + maxThreads = 10, + Tag = "art", + Topic = "Art" + }; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/Art.razor.css b/ImageBoardServerApp/Pages/Boards/Art.razor.css new file mode 100644 index 0000000..5103ea2 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Art.razor.css @@ -0,0 +1,7 @@ +.banner{ + justify-content: center; + display: block; + margin-left: auto; + margin-right: auto; + width: 50%; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/M.razor b/ImageBoardServerApp/Pages/Boards/M.razor index 84dc481..8cbd4f3 100644 --- a/ImageBoardServerApp/Pages/Boards/M.razor +++ b/ImageBoardServerApp/Pages/Boards/M.razor @@ -1,6 +1,4 @@ @page "/m/" -@using System.ComponentModel.DataAnnotations -@using ImageBoardServerApp.Data diff --git a/ImageBoardServerApp/Pages/Boards/M.razor.css b/ImageBoardServerApp/Pages/Boards/M.razor.css index 09af9e7..5103ea2 100644 --- a/ImageBoardServerApp/Pages/Boards/M.razor.css +++ b/ImageBoardServerApp/Pages/Boards/M.razor.css @@ -1,3 +1,7 @@ .banner{ justify-content: center; + display: block; + margin-left: auto; + margin-right: auto; + width: 50%; } \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/Tec.razor b/ImageBoardServerApp/Pages/Boards/Tec.razor new file mode 100644 index 0000000..5cdeaa7 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Tec.razor @@ -0,0 +1,15 @@ +@page "/tec/" + + + + +@code { + + private BoardData m { get; set; } = new() + { + BoardID = 0, + maxThreads = 10, + Tag = "tec", + Topic = "Technology" + }; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/Tec.razor.css b/ImageBoardServerApp/Pages/Boards/Tec.razor.css new file mode 100644 index 0000000..5103ea2 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Tec.razor.css @@ -0,0 +1,7 @@ +.banner{ + justify-content: center; + display: block; + margin-left: auto; + margin-right: auto; + width: 50%; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/Vg.razor b/ImageBoardServerApp/Pages/Boards/Vg.razor new file mode 100644 index 0000000..4079df2 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Vg.razor @@ -0,0 +1,15 @@ +@page "/vg/" + + + + +@code { + + private BoardData m { get; set; } = new() + { + BoardID = 0, + maxThreads = 10, + Tag = "vg", + Topic = "Video Games" + }; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Boards/Vg.razor.css b/ImageBoardServerApp/Pages/Boards/Vg.razor.css new file mode 100644 index 0000000..5103ea2 --- /dev/null +++ b/ImageBoardServerApp/Pages/Boards/Vg.razor.css @@ -0,0 +1,7 @@ +.banner{ + justify-content: center; + display: block; + margin-left: auto; + margin-right: auto; + width: 50%; +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Components/ReportPage.razor b/ImageBoardServerApp/Pages/Components/ReportPage.razor index 73f02de..2c2ea70 100644 --- a/ImageBoardServerApp/Pages/Components/ReportPage.razor +++ b/ImageBoardServerApp/Pages/Components/ReportPage.razor @@ -1,8 +1,41 @@ @page "/report/{type}/{board}/{id}" @using System.ComponentModel.DataAnnotations -

Report

+@using System.Data +@using ImageBoardServerApp.Auth +@using ImageBoardServerApp.Data.Repository +@inject AuthenticationStateProvider authStateProvider +@inject IJSRuntime js + + +

Report @type#@id on /@board/

+ +
+ +
+ @selectedItem + Explain further (optional) +
+ +
+ +
+ + Please login to report + +
@code { + private IEnumerable rules; + private string selectedItem; + private string explaination; + + [Parameter] [Required] public string type { get; set; } @@ -14,4 +47,49 @@ [Parameter] [Required] public string id { get; set; } + + + private async Task onReportClick() + { + var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider; + var user = await cauthStateProvder.GetAuthenticationStateAsync(); + var usr = user.User; + UserData foundusr = await UsersRepository.getUserByEmailAsync(usr.Identity.Name); + if (foundusr == null) + { + return; + } + + if (foundusr.TimeBanned != -1) + { + return; + } + foundusr.lastActionTimeStamp = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds(); + await UsersRepository.updateUserAsync(foundusr); + int targetID = 0; + if (type == "op") + { + var post = await PostsRepository.getPostByIdAsync(Int32.Parse(id)); + targetID = post.User.UserID; + } + else + { + var comment = await CommentsRepository.getCommentByIdAsync(Int32.Parse(id)); + targetID = comment.User.UserID; + } + + ReportData reportData = new ReportData() + { + Type = type, + ReportedCommentID = type == "op" ? null : Int32.Parse(id), + ReportedPostID = type == "op" ? Int32.Parse(id) : null, + UserReporterID = foundusr.UserID, + UserReportedID = targetID, + ReportReason = RulesConv.dict[RulesConv.dict2[selectedItem]], + ReportExlaination = explaination + }; + + var reportID = await ReportsRepository.createReportAsync(reportData); + js.InvokeVoidAsync("window.close"); + } } \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Components/ReportPage.razor.css b/ImageBoardServerApp/Pages/Components/ReportPage.razor.css new file mode 100644 index 0000000..c44cc29 --- /dev/null +++ b/ImageBoardServerApp/Pages/Components/ReportPage.razor.css @@ -0,0 +1,13 @@ +.centered { + text-align: center; + justify-content: center; + align-items: center; +} + +.pd { + padding: 5px; +} + +.marg{ + margin: 2px +} \ No newline at end of file diff --git a/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor b/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor index aaebd07..6fd8ae8 100644 --- a/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor +++ b/ImageBoardServerApp/Pages/Moderation/ReportsPage.razor @@ -1,5 +1,17 @@ @page "/modmenu/reports" - +@using ImageBoardServerApp.Data.Repository +

Reports

+@foreach (var r in reports) +{ + +
+} + @code { - + private List reports; + protected override async Task OnInitializedAsync() + { + reports = await ReportsRepository.getReportsAsync(); + Console.WriteLine("Opened Reports"); + } } \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Board.razor b/ImageBoardServerApp/Shared/Components/Board.razor index 4ad8acc..86780e8 100644 --- a/ImageBoardServerApp/Shared/Components/Board.razor +++ b/ImageBoardServerApp/Shared/Components/Board.razor @@ -10,8 +10,6 @@ - -

@@ -28,11 +26,6 @@ } } - - - - - @code { private List posts; diff --git a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor index 0db3688..0e4b85e 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor @@ -1,5 +1,13 @@ -
    -
  • The max. image size is 2MiB.
  • -
  • Supported file types are: jpeg, png & gif
  • -
  • Read the rules before posting
  • -
\ No newline at end of file +
+ The max. image size is 2MiB. +
+ Supported file types are: jpeg, png & gif +
+
+ Read the + rules + and + faq + before posting +
+
\ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Report.razor b/ImageBoardServerApp/Shared/Components/Report.razor new file mode 100644 index 0000000..0e7f97c --- /dev/null +++ b/ImageBoardServerApp/Shared/Components/Report.razor @@ -0,0 +1,47 @@ +@using System.ComponentModel.DataAnnotations +
+ @if (report.Type == "op") + { + /@report.ReportedPost.Board/ + } + else + { + /@report.ReportedComment/ + } + #@report.ReportID + @report.Type +
+ Reason: @report.ReportReason +
+ Explaination: @report.ReportExlaination +
+ Ban Reported User +
+ Ban Reporter +
+ @if (report.Type == "op") + { + + } + else + { + + } +
+ +@code { + [Parameter] + [Required] + public ReportData report { get; set; } + + + private async Task banTarget() + { + + } + + private async Task banReporter() + { + + } +} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Reports.razor b/ImageBoardServerApp/Shared/Components/Reports.razor deleted file mode 100644 index 0fe0732..0000000 --- a/ImageBoardServerApp/Shared/Components/Reports.razor +++ /dev/null @@ -1,5 +0,0 @@ -

Reports

- -@code { - -} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/MainLayout.razor b/ImageBoardServerApp/Shared/MainLayout.razor index 141e9c6..08c1d5a 100644 --- a/ImageBoardServerApp/Shared/MainLayout.razor +++ b/ImageBoardServerApp/Shared/MainLayout.razor @@ -15,15 +15,6 @@
diff --git a/ImageBoardServerApp/Shared/NavMenu.razor b/ImageBoardServerApp/Shared/NavMenu.razor index 56c5d1b..e6442da 100644 --- a/ImageBoardServerApp/Shared/NavMenu.razor +++ b/ImageBoardServerApp/Shared/NavMenu.razor @@ -1,6 +1,18 @@ -