Profile Blocking (#662)

* Added blocked user DB object

* Added user blocking functions

* Fixed DB Migration

* Updated DB Functions

* Added blocked user support to website

* Fixed DB Migration

* I forgot to save 🫠

* More migration pain

* Fixed Unblock label

* Update ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml

sounds cool

Co-authored-by: koko <68549366+sudokoko@users.noreply.github.com>

* Removed unnecessary imports in database

* Removed unnecessary  imports in UserPage.cshtml.cs

* Made comments in-game respect blocked users

* Update ProjectLighthouse/Database.cs

Co-authored-by: Josh <josh@slendy.pw>

* Update ProjectLighthouse/Database.cs

Co-authored-by: Josh <josh@slendy.pw>

* DB Code cleanup

* Cleaned up userPage block detection code

* Get only the creator id in lieu of the whole object

* Fixed null condition when not logged in

* Fixed null condition when not logged in

* Potential DB Optimisation

* Apply suggestions from code review

Co-authored-by: Josh <josh@slendy.pw>

* Fix errors and null warning

* Use explicit type in lieu of var

* changed block icons

* Optimize blocked user check and save changes when unblocking

---------

Co-authored-by: koko <68549366+sudokoko@users.noreply.github.com>
Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
Zaprit 2023-02-11 08:25:06 +00:00 committed by GitHub
parent b4326d4798
commit 3fcfaaf5cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 227 additions and 8 deletions

View file

@ -18,6 +18,8 @@ public class UserPage : BaseLayout
public bool IsProfileUserHearted;
public bool IsProfileUserBlocked;
public List<Photo>? Photos;
public List<Slot>? Slots;
@ -86,11 +88,18 @@ public class UserPage : BaseLayout
}
this.CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelCommentsEnabled && this.ProfileUser.CommentsEnabled;
if (this.CommentsEnabled)
{
List<int> blockedUsers = this.User == null ? new List<int>() : await
(from blockedProfile in this.Database.BlockedProfiles
where blockedProfile.UserId == this.User.UserId
select blockedProfile.BlockedUserId).ToListAsync();
this.Comments = await this.Database.Comments.Include(p => p.Poster)
.OrderByDescending(p => p.Timestamp)
.Where(p => p.TargetId == userId && p.Type == CommentType.Profile)
.Where(p => !blockedUsers.Contains(p.PosterUserId))
.Take(50)
.ToListAsync();
}
@ -114,6 +123,8 @@ public class UserPage : BaseLayout
.Where(h => h.UserId == this.User.UserId)
.AnyAsync();
this.IsProfileUserBlocked = await this.Database.IsUserBlockedBy(this.ProfileUser.UserId, this.User.UserId);
return this.Page();
}
}