pleroma: add Status.VisibleTo
This commit is contained in:
parent
2b294f7137
commit
468af1877b
1 changed files with 29 additions and 0 deletions
|
@ -154,6 +154,35 @@ public class Status : ASObject
|
||||||
return ReplyToAccount == user.ID || Mentions.Any(m => m.ID == user.ID);
|
return ReplyToAccount == user.ID || Mentions.Any(m => m.ID == user.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the status is visible to a particular account.
|
||||||
|
/// </summary>
|
||||||
|
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}\"";
|
public override string ToString() => $"{Author?.Username ?? "unknown"}: \"{Content}\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue