Implement basic privacy settings (#392)

* Add ability for clients to submit and retrieve privacy settings data

* Make slot pages and user pages respect user's privacy settings

* Prevent webhook from publishing new levels if user's privacy settings disallow it

* Hide levels/profiles from respective pages depending on privacy settings

* Apply suggestions from review
This commit is contained in:
Jayden 2022-08-02 18:22:56 -04:00 committed by GitHub
parent 5a3439e634
commit 2ab1e72037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 210 additions and 12 deletions

View file

@ -31,6 +31,29 @@ public class SlotPage : BaseLayout
.Where(s => s.Type == SlotType.User)
.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound();
System.Diagnostics.Debug.Assert(slot.Creator != null);
// Determine if user can view slot according to creator's privacy settings
if (this.User == null || !this.User.IsAdmin)
{
switch (slot.Creator.ProfileVisibility)
{
case PrivacyType.PSN:
{
if (this.User != null) return this.NotFound();
break;
}
case PrivacyType.Game:
{
if (slot.Creator != this.User) return this.NotFound();
break;
}
case PrivacyType.All: break;
default: throw new ArgumentOutOfRangeException();
}
}
this.Slot = slot;