Compare commits

...

4 commits

Author SHA1 Message Date
uwaa
6868b6a465 pleroma: add NoBot 2024-12-30 01:17:33 +00:00
uwaa
0f59ecfa5b pleroma: document StatusVisibility 2024-12-30 01:16:39 +00:00
uwaa
468af1877b pleroma: add Status.VisibleTo 2024-12-30 01:16:39 +00:00
uwaa
2b294f7137 pleroma: rename Status.Account to Author 2024-12-30 01:16:38 +00:00
3 changed files with 59 additions and 2 deletions

View file

@ -53,6 +53,11 @@ public class Account : ASObject
}
}
/// <summary>
/// If true, the user opts-out of automated interactions. Bots must not follow these users, nor reply, favorite, boost, or store posts from these users.
/// </summary>
public bool NoBot => Bio != null && Bio.Contains("#nobot", StringComparison.OrdinalIgnoreCase);
[JsonConstructor()]
internal Account()
{

View file

@ -12,7 +12,7 @@ public class Status : ASObject
/// The account that authored this status
/// </summary>
[JsonPropertyName("account")]
public Account Account { get; set; } = null!;
public Account Author { get; set; } = null!;
/// <summary>
/// The date when this status was created
@ -154,7 +154,36 @@ public class Status : ASObject
return ReplyToAccount == user.ID || Mentions.Any(m => m.ID == user.ID);
}
public override string ToString() => $"{Account?.Username ?? "unknown"}: \"{Content}\"";
/// <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}\"";
}
/// <summary>

View file

@ -3,10 +3,33 @@
[JsonConverter(typeof(EnumLowerCaseConverter<StatusVisibility>))]
public enum StatusVisibility
{
/// <summary>
/// Visible to everyone.
/// </summary>
Public,
/// <summary>
/// Post is only visible on user's timeline. Not visible on the public timeline or known network.
/// </summary>
Unlisted,
/// <summary>
/// Only visible to users on the same instance (not federated).
/// </summary>
Local,
/// <summary>
/// Can only be seen by followers.
/// </summary>
Private,
/// <summary>
/// Can only be seen by mentioned users.
/// </summary>
Direct,
/// <summary>
/// Member of a list.
/// </summary>
List
}