Compare commits
4 commits
c606e4ed02
...
6868b6a465
Author | SHA1 | Date | |
---|---|---|---|
|
6868b6a465 | ||
|
0f59ecfa5b | ||
|
468af1877b | ||
|
2b294f7137 |
3 changed files with 59 additions and 2 deletions
|
@ -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()]
|
[JsonConstructor()]
|
||||||
internal Account()
|
internal Account()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class Status : ASObject
|
||||||
/// The account that authored this status
|
/// The account that authored this status
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("account")]
|
[JsonPropertyName("account")]
|
||||||
public Account Account { get; set; } = null!;
|
public Account Author { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The date when this status was created
|
/// 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);
|
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>
|
/// <summary>
|
||||||
|
|
|
@ -3,10 +3,33 @@
|
||||||
[JsonConverter(typeof(EnumLowerCaseConverter<StatusVisibility>))]
|
[JsonConverter(typeof(EnumLowerCaseConverter<StatusVisibility>))]
|
||||||
public enum StatusVisibility
|
public enum StatusVisibility
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Visible to everyone.
|
||||||
|
/// </summary>
|
||||||
Public,
|
Public,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Post is only visible on user's timeline. Not visible on the public timeline or known network.
|
||||||
|
/// </summary>
|
||||||
Unlisted,
|
Unlisted,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Only visible to users on the same instance (not federated).
|
||||||
|
/// </summary>
|
||||||
Local,
|
Local,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Can only be seen by followers.
|
||||||
|
/// </summary>
|
||||||
Private,
|
Private,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Can only be seen by mentioned users.
|
||||||
|
/// </summary>
|
||||||
Direct,
|
Direct,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Member of a list.
|
||||||
|
/// </summary>
|
||||||
List
|
List
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue