diff --git a/Pleroma/Models/Status.cs b/Pleroma/Models/Status.cs index cca9cb1..90f9883 100644 --- a/Pleroma/Models/Status.cs +++ b/Pleroma/Models/Status.cs @@ -154,6 +154,35 @@ public class Status : ASObject return ReplyToAccount == user.ID || Mentions.Any(m => m.ID == user.ID); } + /// + /// Returns true if the status is visible to a particular account. + /// + public bool VisibleTo(Account account) + { + if (Author.ID == account.ID) + return true; + + switch (Visibility) + { + case StatusVisibility.Public: + case StatusVisibility.Unlisted: + return true; + + case StatusVisibility.Local: + return Author.Instance == account.Instance; + + case StatusVisibility.Private: //TODO: Not correctly implemented, but finding the correct answer would require fetching the relationship + case StatusVisibility.Direct: + return Mentions.Any(mention => mention.ID == account.ID); + + case StatusVisibility.List: + return false; + + default: + return false; + } + } + public override string ToString() => $"{Author?.Username ?? "unknown"}: \"{Content}\""; }