diff --git a/ImageBoardServerApp/Data/Repository/UsersRepository.cs b/ImageBoardServerApp/Data/Repository/UsersRepository.cs index 30e8267..bcd695d 100644 --- a/ImageBoardServerApp/Data/Repository/UsersRepository.cs +++ b/ImageBoardServerApp/Data/Repository/UsersRepository.cs @@ -15,6 +15,12 @@ public static class UsersRepository await using var db = new AppDBContext(); return await db.Users.FirstOrDefaultAsync(user => user.UserID == userId); } + + public static async Task getUserByIPAsync(string userIp) + { + await using var db = new AppDBContext(); + return await db.Users.FirstOrDefaultAsync(user => user.Ipv4Address == userIp); + } public static async Task createUserAsync(UserData userToCreate) { diff --git a/ImageBoardServerApp/ImageBoardServerApp.csproj b/ImageBoardServerApp/ImageBoardServerApp.csproj index 4dda036..8d9c9c3 100644 --- a/ImageBoardServerApp/ImageBoardServerApp.csproj +++ b/ImageBoardServerApp/ImageBoardServerApp.csproj @@ -19,6 +19,8 @@ + + diff --git a/ImageBoardServerApp/Pages/Rules.razor.css b/ImageBoardServerApp/Pages/Rules.razor.css index c37ac42..49f002f 100644 --- a/ImageBoardServerApp/Pages/Rules.razor.css +++ b/ImageBoardServerApp/Pages/Rules.razor.css @@ -3,6 +3,7 @@ font-weight: 1000; /*the text have to be in a biger Pixel number I do not know how to do it */ } + .rules_list{ text-align:left; display:block; diff --git a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor index f729ea6..e912a95 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/CommentForm.razor @@ -12,17 +12,19 @@ {
Comment on @post.Title in /@post.Board/ + +
-
- @if (image != null) - { - No Image - } -
- -
+
+ @if (image != null) + { + No Image + } +
+ +
@@ -36,6 +38,7 @@
+
@@ -103,7 +106,21 @@ Banned = false, lastActionTimeStamp = DateTime.Now.Millisecond }; - int userID = await UsersRepository.createUserAsync(userToCreate); + + int userID; + UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address); + if (foundusr == null) + { + userID = await UsersRepository.createUserAsync(userToCreate); + } + else + { + userID = foundusr.UserID; + if(foundusr.Banned) + return; + foundusr.lastActionTimeStamp = DateTime.Now.Millisecond; + await UsersRepository.updateUserAsync(foundusr); + } bool hasImage = image != null; CommentData commentToCreate; diff --git a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor new file mode 100644 index 0000000..4696826 --- /dev/null +++ b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor @@ -0,0 +1,5 @@ +
    +
  • The max. image size is 1MB.
  • +
  • Supported file types are: jpeg, png & gif
  • +
  • Read the rules before posting
  • +
\ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor.css b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor.css new file mode 100644 index 0000000..f8b1df7 --- /dev/null +++ b/ImageBoardServerApp/Shared/Components/Forms/FormInfo.razor.css @@ -0,0 +1,8 @@ +.notesInfo{ + font-weight: 60; + display: block; + text-align: center; + font-size: 10px; + color: #c6cfd0; + /*the text sice can stay like it is, if you do not want to change it.*/ +} \ No newline at end of file diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor index ff8af17..261a567 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor @@ -19,20 +19,35 @@
Post to /@board.Tag/ - @board.Topic -
- OnChange(args, "username")) Class="w-100"/> -
+
+
+
+ @if (image != null) + { + No Image + } +
+ +
-
- OnChange(args, "title")) Class="w-100"/> -
- -
- OnChange(args, "Content")) Class="w-100"/> +
+
+ OnChange(args, "username")) Class="w-100"/> +
+ +
+ OnChange(args, "title")) Class="w-100"/> +
+ +
+ OnChange(args, "Content")) Class="w-100"/> +
+
+
- +
@@ -100,7 +115,21 @@ Banned = false, lastActionTimeStamp = DateTime.Now.Millisecond }; - int userID = await UsersRepository.createUserAsync(userToCreate); + + int userID; + UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address); + if (foundusr == null) + { + userID = await UsersRepository.createUserAsync(userToCreate); + } + else + { + userID = foundusr.UserID; + if(foundusr.Banned) + return; + foundusr.lastActionTimeStamp = DateTime.Now.Millisecond; + await UsersRepository.updateUserAsync(foundusr); + } //TODO Add check if data is image diff --git a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor.css b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor.css index fc59e5e..15998e9 100644 --- a/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor.css +++ b/ImageBoardServerApp/Shared/Components/Forms/PostForm.razor.css @@ -20,4 +20,21 @@ .marg{ margin: 2px +} + +.formImage{ + margin: 6px; + max-width: 200px; + max-height: 200px; + padding: 5px; +} + +.formImage img{ + max-width:150px; + width: 100%; +} + +.formContent{ + text-align: left; + display: flex; } \ No newline at end of file