[backend/masto-client] Fix NullReferenceExceptions in StatusController

This commit is contained in:
Laura Hausmann 2024-05-03 01:32:19 +02:00
parent 4dd5eea946
commit 6c2215e30d
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -85,7 +85,7 @@ public class StatusController(
.FirstOrDefaultAsync() ?? .FirstOrDefaultAsync() ??
throw GracefulException.RecordNotFound(); throw GracefulException.RecordNotFound();
if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.User.IsRemoteUser && user == null) if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null)
throw GracefulException.Forbidden("Public preview is disabled on this instance"); throw GracefulException.Forbidden("Public preview is disabled on this instance");
var shouldShowContext = await db.Notes var shouldShowContext = await db.Notes
@ -550,7 +550,7 @@ public class StatusController(
.FirstOrDefaultAsync() ?? .FirstOrDefaultAsync() ??
throw GracefulException.RecordNotFound(); throw GracefulException.RecordNotFound();
if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.User.IsRemoteUser && user == null) if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null)
throw GracefulException.Forbidden("Public preview is disabled on this instance"); throw GracefulException.Forbidden("Public preview is disabled on this instance");
var res = await db.NoteLikes.Where(p => p.Note == note) var res = await db.NoteLikes.Where(p => p.Note == note)
@ -578,7 +578,7 @@ public class StatusController(
.FirstOrDefaultAsync() ?? .FirstOrDefaultAsync() ??
throw GracefulException.RecordNotFound(); throw GracefulException.RecordNotFound();
if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.User.IsRemoteUser && user == null) if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null)
throw GracefulException.Forbidden("Public preview is disabled on this instance"); throw GracefulException.Forbidden("Public preview is disabled on this instance");
var res = await db.Notes var res = await db.Notes