Uwaa/Pleroma/Models/Status.cs
2024-12-13 12:25:20 +00:00

111 lines
3.2 KiB
C#

namespace Uwaa.Pleroma;
public class Status
{
/// <summary>
/// Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However just like Mastodon's ids they are lexically sortable strings
/// </summary>
[JsonPropertyName("id")]
public string ID { get; set; } = null!;
/// <summary>
/// HTML-encoded status content
/// </summary>
[JsonPropertyName("content")]
public string HtmlContent { get; set; } = null!;
/// <summary>
/// The account that authored this status
/// </summary>
[JsonPropertyName("account")]
public Account Account { get; set; } = null!;
/// <summary>
/// The date when this status was created
/// </summary>
[JsonPropertyName("created_at")]
public DateTime CreatedAt { get; set; }
[JsonPropertyName("pleroma")]
public PleromaObject Pleroma { get; set; } = null!;
/// <summary>
/// ID of the account being replied to
/// </summary>
[JsonPropertyName("in_reply_to_account_id")]
public string? ReplyToAccount { get; set; } = null;
/// <summary>
/// ID of the status being replied
/// </summary>
[JsonPropertyName("in_reply_to_id")]
public string? ReplyToStatus { get; set; } = null;
/// <summary>
/// Mentions of users within the status content
/// </summary>
[JsonPropertyName("mentions")]
public Mention[] Mentions { get; set; } = Array.Empty<Mention>();
/// <summary>
/// Primary language of this status
/// </summary>
[JsonPropertyName("language")]
public string? Language { get; set; }
/// <summary>
/// Have you pinned this status? Only appears if the status is pinnable.
/// </summary>
[JsonPropertyName("pinned")]
public bool Pinned { get; set; }
/// <summary>
/// Visibility of this status
/// </summary>
[JsonPropertyName("visibility")]
public StatusVisibility Visibility { get; set; }
/// <summary>
/// Plain text content of that status.
/// </summary>
[JsonIgnore]
public string Content => Pleroma?.Content?.Plain ?? HtmlContent;
public bool CheckMention(string id)
{
return ReplyToAccount == id || Mentions.Any(m => m.ID == id);
}
public override string ToString() => $"{Account?.Username ?? "unknown"}: \"{Content}\"";
}
public class Mention
{
public static implicit operator string(Mention mention) => mention.ID;
/// <summary>
/// The webfinger acct: URI of the mentioned user. Equivalent to <c>username</c> for local users, or <c>username@domain</c> for remote users.
/// </summary>
[JsonPropertyName("acct")]
public string Account { get; set; } = null!;
/// <summary>
/// The account id of the mentioned user
/// </summary>
[JsonPropertyName("id")]
public string ID { get; set; } = null!;
/// <summary>
/// The location of the mentioned user's profile
/// </summary>
[JsonPropertyName("url")]
public string URL { get; set; } = null!;
/// <summary>
/// The username of the mentioned user
/// </summary>
[JsonPropertyName("username")]
public string Username { get; set; } = null!;
public override string ToString() => $"@{Account}";
}