From 319e51c95869f36858e587c34fcacc7594e14a26 Mon Sep 17 00:00:00 2001 From: Guillaume Lacasa Date: Sun, 14 Jan 2024 14:16:25 +0100 Subject: [PATCH 1/6] Fix some tests --- Mastonet.Tests/AccountTests.cs | 19 +++++++++---------- Mastonet.Tests/MastodonClientTests.cs | 2 +- Mastonet.Tests/StatusTests.cs | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Mastonet.Tests/AccountTests.cs b/Mastonet.Tests/AccountTests.cs index c822e29..20bb189 100644 --- a/Mastonet.Tests/AccountTests.cs +++ b/Mastonet.Tests/AccountTests.cs @@ -49,21 +49,20 @@ public async Task GetAccountRelationships() [Fact] public async Task UpdateAccount() { - var avatarBase64 = await DownloadBase64("http://tweeting.com/wp-content/uploads/2011/11/Doctor-Who-logo.jpg"); - Assert.Equal(15920, avatarBase64.Length); - var headerBase64 = await DownloadBase64("http://www.geekbomb.net/wp-content/uploads/2017/07/The-police-Box-TARDIS-from-Doctor-Who-in-space.jpg"); - Assert.Equal(336848, headerBase64.Length); + throw new NotImplementedException(); + //var avatarBase64 = await DownloadBase64(""); + //var headerBase64 = await DownloadBase64(""); - var client = GetTestClient(); + //var client = GetTestClient(); //var result = await client.UpdateCredentials("Just the Doctor", "Trust me", "data:image/jpg;base64," + avatarBase64, "data:image/jpg;base64," + headerBase64); //Assert.NotNull(result); } - private async Task DownloadBase64(string url) - { - var bytes = await new HttpClient().GetByteArrayAsync(url); - return Convert.ToBase64String(bytes); - } + //private async Task DownloadBase64(string url) + //{ + // var bytes = await new HttpClient().GetByteArrayAsync(url); + // return Convert.ToBase64String(bytes); + //} } } diff --git a/Mastonet.Tests/MastodonClientTests.cs b/Mastonet.Tests/MastodonClientTests.cs index d5b75c6..0c5a1e6 100644 --- a/Mastonet.Tests/MastodonClientTests.cs +++ b/Mastonet.Tests/MastodonClientTests.cs @@ -22,7 +22,7 @@ public partial class InitTest public async Task GetTokens() { var authClient = new AuthenticationClient(Instance); - var appRegistration = await authClient.CreateApp("Mastonet Unit Test", Scope.Read | Scope.Write | Scope.Follow); + var appRegistration = await authClient.CreateApp("Mastonet Unit Test", null, null, GranularScope.Read, GranularScope.Write, GranularScope.Follow); var accessToken1 = await authClient.ConnectWithPassword(Email1, Password1); var accessToken2 = await authClient.ConnectWithPassword(Email2, Password2); diff --git a/Mastonet.Tests/StatusTests.cs b/Mastonet.Tests/StatusTests.cs index 9370a30..6b6853d 100644 --- a/Mastonet.Tests/StatusTests.cs +++ b/Mastonet.Tests/StatusTests.cs @@ -72,7 +72,7 @@ public async Task GetRebloggedBy() await privateClient.Reblog(status.Id); var rbBy = await privateClient.GetRebloggedBy(status.Id); - Assert.NotNull(rbBy.FirstOrDefault(a => a.Id == "11")); + Assert.Single(rbBy); } [Fact] @@ -85,7 +85,7 @@ public async Task GetFavouritedBy() await privateClient.Favourite(status.Id); var rbBy = await privateClient.GetFavouritedBy(status.Id); - Assert.NotNull(rbBy.FirstOrDefault(a => a.Id == "11")); + Assert.Single(rbBy); } } } From 3321a19f179f053dfc7fdf18ba8fbd78bd208861 Mon Sep 17 00:00:00 2001 From: Eduardo Braga Date: Sat, 5 Oct 2024 09:26:43 -0300 Subject: [PATCH 2/6] Add new notification property and related types --- Mastonet.Entities/AccountWarning.cs | 53 +++++++++++++++++++ Mastonet.Entities/Appeal.cs | 25 +++++++++ Mastonet.Entities/Notification.cs | 26 +++++++-- .../RelationshipSeveranceEvent.cs | 49 +++++++++++++++++ 4 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 Mastonet.Entities/AccountWarning.cs create mode 100644 Mastonet.Entities/Appeal.cs create mode 100644 Mastonet.Entities/RelationshipSeveranceEvent.cs diff --git a/Mastonet.Entities/AccountWarning.cs b/Mastonet.Entities/AccountWarning.cs new file mode 100644 index 0000000..1f08bce --- /dev/null +++ b/Mastonet.Entities/AccountWarning.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + public class AccountWarning + { + /// + /// The ID of the account warning in the database. + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + + /// + /// Action taken against the account. + /// + [JsonPropertyName("action")] + public string Action { get; set; } = string.Empty; + + /// + /// Message from the moderator to the target account. + /// + [JsonPropertyName("text")] + public string Text { get; set; } = string.Empty; + + /// + /// List of status IDs that are relevant to the warning. When action is mark_statuses_as_sensitive or delete_statuses, those are the affected statuses. + /// + [JsonPropertyName("status_ids")] + public IEnumerable StatusIds { get; set; } = Enumerable.Empty(); + + /// + /// Account against which a moderation decision has been taken. + /// + [JsonPropertyName("target_account")] + public Account TargetAccount { get; set; } = new Account(); + + /// + /// Appeal submitted by the target account, if any. + /// + [JsonPropertyName("appeal")] + public Appeal? Appeal { get; set; } + + /// + /// When the event took place. + /// + [JsonPropertyName("created_at")] + public string CreatedAt { get; set; } = string.Empty; + } +} diff --git a/Mastonet.Entities/Appeal.cs b/Mastonet.Entities/Appeal.cs new file mode 100644 index 0000000..20fd1d4 --- /dev/null +++ b/Mastonet.Entities/Appeal.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + public class Appeal + { + /// + /// Text of the appeal from the moderated account to the moderators. + /// + [JsonPropertyName("text")] + public string Text { get; set; } = string.Empty; + + /// + /// State of the appeal. One of: + /// approved = The appeal has been approved by a moderator + /// rejected = The appeal has been rejected by a moderator + /// pending = The appeal has been submitted, but neither approved nor rejected yet + /// + [JsonPropertyName("state")] + public string State { get; set; } = string.Empty; + } +} diff --git a/Mastonet.Entities/Notification.cs b/Mastonet.Entities/Notification.cs index a15a8b7..e061b83 100644 --- a/Mastonet.Entities/Notification.cs +++ b/Mastonet.Entities/Notification.cs @@ -18,17 +18,25 @@ public class Notification /// /// The type of event that resulted in the notification. One of: - /// follow = Someone followed you - /// follow_request = Someone requested to follow you /// mention = Someone mentioned you in their status + /// status = Someone you enabled notifications for has posted a status /// reblog = Someone boosted one of your statuses + /// follow = Someone followed you + /// follow_request = Someone requested to follow you /// favourite = Someone favourited one of your statuses /// poll = A poll you have voted in or created has ended - /// status = Someone you enabled notifications for has posted a status + /// update = A status you interacted with has been edited + /// admin.sign_up = Someone signed up (optionally sent to admins) + /// admin.report = A new report has been filed + /// severed_relationships = Some of your follow relationships have been severed as a result of a moderation or block event + /// moderation_warning = A moderator has taken action against your account or has sent you a warning /// [JsonPropertyName("type")] public string Type { get; set; } = string.Empty; + [JsonPropertyName("group_key")] + public string GroupKey { get; set; } = string.Empty; + /// /// The timestamp of the notification. /// @@ -46,4 +54,16 @@ public class Notification /// [JsonPropertyName("status")] public Status? Status { get; set; } + + /// + /// Summary of the event that caused follow relationships to be severed. Attached when type of the notification is severed_relationships. + /// + [JsonPropertyName("relationship_severance_event")] + public RelationshipSeveranceEvent RelationshipSeveranceEvent { get; set; } = new RelationshipSeveranceEvent(); + + /// + /// Moderation warning that caused the notification. Attached when type of the notification is moderation_warning. + /// + [JsonPropertyName("moderation_warning")] + public AccountWarning ModerationWarning { get; set; } = new AccountWarning(); } diff --git a/Mastonet.Entities/RelationshipSeveranceEvent.cs b/Mastonet.Entities/RelationshipSeveranceEvent.cs new file mode 100644 index 0000000..937d493 --- /dev/null +++ b/Mastonet.Entities/RelationshipSeveranceEvent.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + public class RelationshipSeveranceEvent + { + /// + /// The ID of the relationship severance event in the database. + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + + /// + /// Type of event.One of: + /// domain_block = A moderator suspended a whole domain + /// user_domain_block = The user blocked a whole domain + /// account_suspension = A moderator suspended a specific account + /// + [JsonPropertyName("type")] + public string Type { get; set; } = string.Empty; + + /// + /// Whether the list of severed relationships is unavailable because the underlying issue has been purged. + /// + [JsonPropertyName("purged")] + public bool Purged { get; set; } + + /// + /// Name of the target of the moderation/block event. This is either a domain name or a user handle, depending on the event type. + /// + [JsonPropertyName("target_name")] + public string TargetName { get; set; } = string.Empty; + + /// + /// Number of follow relationships (in either direction) that were severed. + /// + [JsonPropertyName("relationships_count")] + public int RelationshipsCount { get; set; } + + /// + /// When the event took place. + /// + [JsonPropertyName("created_at")] + public string CrreatedAt { get; set; } = string.Empty; + } +} From d69c1159963e0bd2f484bb9e4923e5071ae04303 Mon Sep 17 00:00:00 2001 From: Eduardo Braga Date: Sat, 5 Oct 2024 09:35:53 -0300 Subject: [PATCH 3/6] Add a title property in Filter and mark IdentityProof as obsolete --- Mastonet.Entities/Filter.cs | 6 ++++++ Mastonet.Entities/IdentityProof.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/Mastonet.Entities/Filter.cs b/Mastonet.Entities/Filter.cs index fac61e3..5ee110c 100644 --- a/Mastonet.Entities/Filter.cs +++ b/Mastonet.Entities/Filter.cs @@ -16,6 +16,12 @@ public class Filter [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; + /// + /// A title given by the user to name the filter. + /// + [JsonPropertyName("title")] + public string Title { get; set; } = string.Empty; + /// /// The text to be filtered. /// diff --git a/Mastonet.Entities/IdentityProof.cs b/Mastonet.Entities/IdentityProof.cs index da6fd36..e4a44e6 100644 --- a/Mastonet.Entities/IdentityProof.cs +++ b/Mastonet.Entities/IdentityProof.cs @@ -8,6 +8,7 @@ namespace Mastonet.Entities; /// /// Represents a proof from an external identity provider. /// +[Obsolete("Identity proofs have been deprecated in 3.5.0 and newer. Previously, the only proof provider was Keybase, but development on Keybase has stalled entirely since it was acquired by Zoom.")] public class IdentityProof { /// From 7563f64e68ca62ca1eb358d73ce3cdee5ab38c6f Mon Sep 17 00:00:00 2001 From: Eduardo Braga Date: Sat, 5 Oct 2024 09:55:47 -0300 Subject: [PATCH 4/6] Add types InstanceIcon, InstanceApiVersion and InstanceConfigurationVapid and corresponding properties. --- Mastonet.Entities/IdentityProof.cs | 2 +- Mastonet.Entities/InstanceV2.cs | 36 ++++++++++++++++++++ Mastonet.Entities/InstanceV2Configuration.cs | 16 +++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Mastonet.Entities/IdentityProof.cs b/Mastonet.Entities/IdentityProof.cs index e4a44e6..3c47aee 100644 --- a/Mastonet.Entities/IdentityProof.cs +++ b/Mastonet.Entities/IdentityProof.cs @@ -8,7 +8,7 @@ namespace Mastonet.Entities; /// /// Represents a proof from an external identity provider. /// -[Obsolete("Identity proofs have been deprecated in 3.5.0 and newer. Previously, the only proof provider was Keybase, but development on Keybase has stalled entirely since it was acquired by Zoom.")] +[Obsolete("Identity proofs have been deprecated in Mastodon v3.5.0 and newer. Previously, the only proof provider was Keybase, but development on Keybase has stalled entirely since it was acquired by Zoom.")] public class IdentityProof { /// diff --git a/Mastonet.Entities/InstanceV2.cs b/Mastonet.Entities/InstanceV2.cs index f9530b8..4be9c1a 100644 --- a/Mastonet.Entities/InstanceV2.cs +++ b/Mastonet.Entities/InstanceV2.cs @@ -53,6 +53,12 @@ public class InstanceV2 [JsonPropertyName("thumbnail")] public InstanceThumbnail Thumbnail { get; set; }= new InstanceThumbnail(); + /// + /// The list of available size variants for this instance configured icon. + /// + [JsonPropertyName("icon")] + public IEnumerable Icon { get; set; } = Enumerable.Empty(); + /// /// Primary languages of the website and its staff. /// @@ -71,6 +77,12 @@ public class InstanceV2 [JsonPropertyName("registrations")] public InstanceRegistrations Registrations { get; set; }= new InstanceRegistrations(); + /// + /// Information about which version of the API is implemented by this server. It contains at least a mastodon attribute, and other implementations may have their own additional attributes. + /// + [JsonPropertyName("api_versions")] + public InstanceApiVersion InstanceApiVersion { get; set; } = new InstanceApiVersion(); + /// /// Hints related to contacting a representative of the website. /// @@ -159,6 +171,15 @@ public class InstanceRegistrations public string? Message { get; set; } } +public class InstanceApiVersion +{ + /// + /// API version number that this server implements. Starting from Mastodon v4.3.0, API changes will come with a version number, which clients can check against this value. + /// + [JsonPropertyName("mastodon")] + public int Mastodon { get; set; } +} + public class InstanceContact { /// @@ -187,4 +208,19 @@ public class InstanceRule /// [JsonPropertyName("text")] public string Text { get; set; } = string.Empty; +} + +public class InstanceIcon +{ + /// + /// The URL of this icon. + /// + [JsonPropertyName("src")] + public string Source { get; set; } = string.Empty; + + /// + /// The size of this icon. + /// + [JsonPropertyName("size")] + public string Size { get; set; } = string.Empty; } \ No newline at end of file diff --git a/Mastonet.Entities/InstanceV2Configuration.cs b/Mastonet.Entities/InstanceV2Configuration.cs index 56463f4..64d2248 100644 --- a/Mastonet.Entities/InstanceV2Configuration.cs +++ b/Mastonet.Entities/InstanceV2Configuration.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Dynamic; using System.Linq; using System.Text.Json.Serialization; @@ -41,6 +42,12 @@ public class InstanceConfiguration /// [JsonPropertyName("translation")] public InstanceConfigurationTranslation Translation { get; set; }= new InstanceConfigurationTranslation(); + + /// + /// The instances VAPID public key, used for push notifications, the same as WebPushSubscription#server_key. + /// + [JsonPropertyName("vapid")] + public InstanceConfigurationVapid Vapid { get; set; } = new InstanceConfigurationVapid(); } public class InstanceConfigurationUrls @@ -161,4 +168,13 @@ public class InstanceConfigurationTranslation /// [JsonPropertyName("enabled")] public bool Enabled { get; set; } +} + +public class InstanceConfigurationVapid +{ + /// + /// The instances VAPID public key, used for push notifications, the same as WebPushSubscription#server_key. + /// + [JsonPropertyName("public_key")] + public string PublicKey { get; set; } = string.Empty; } \ No newline at end of file From 33213e4c9024d21c9bbc219d0adb4b0d6732cba4 Mon Sep 17 00:00:00 2001 From: Eduardo Braga Date: Sat, 5 Oct 2024 10:19:19 -0300 Subject: [PATCH 5/6] Add NotificationPolicy and NotificationRequest types --- Mastonet.Entities/NotificationPolicy.cs | 61 ++++++++++++++++++++++++ Mastonet.Entities/NotificationRequest.cs | 46 ++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 Mastonet.Entities/NotificationPolicy.cs create mode 100644 Mastonet.Entities/NotificationRequest.cs diff --git a/Mastonet.Entities/NotificationPolicy.cs b/Mastonet.Entities/NotificationPolicy.cs new file mode 100644 index 0000000..57e7da2 --- /dev/null +++ b/Mastonet.Entities/NotificationPolicy.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + public class NotificationPolicy + { + /// + /// Whether to accept, filter or drop notifications from accounts the user is not following. drop will prevent creation of the notification object altogether (without preventing the underlying activity), filter will cause it to be marked as filtered, and accept will not affect its processing. + /// + [JsonPropertyName("for_not_following\r\n")] + public string ForNotFollowing { get; set; } = string.Empty; + + /// + /// Whether to accept, filter or drop notifications from accounts that are not following the user. drop will prevent creation of the notification object altogether (without preventing the underlying activity), filter will cause it to be marked as filtered, and accept will not affect its processing. + /// + [JsonPropertyName("for_not_followers")] + public string ForNotFollowers { get; set; } = string.Empty; + + /// + /// Whether to accept, filter or drop notifications from accounts created in the past 30 days. drop will prevent creation of the notification object altogether (without preventing the underlying activity), filter will cause it to be marked as filtered, and accept will not affect its processing. + /// + [JsonPropertyName("for_new_accounts")] + public string ForNewAccounts { get; set; } = string.Empty; + + /// + /// Whether to accept, filter or drop notifications from private mentions. drop will prevent creation of the notification object altogether (without preventing the underlying activity), filter will cause it to be marked as filtered, and accept will not affect its processing. Replies to private mentions initiated by the user, as well as accounts the user follows, are always allowed, regardless of this value. + /// + [JsonPropertyName("for_private_mentions")] + public string ForPrivateMentions { get; set; } = string.Empty; + + /// + /// Whether to accept, filter or drop notifications from accounts that were limited by a moderator. drop will prevent creation of the notification object altogether (without preventing the underlying activity), filter will cause it to be marked as filtered, and accept will not affect its processing. + /// + [JsonPropertyName("for_limited_accounts")] + public string ForLimitedAccounts { get; set; } = string.Empty; + + /// + /// Summary of the filtered notifications + /// + [JsonPropertyName("summary")] + public Summary Summary { get; set; } = new Summary(); + } + + public class Summary + { + /// + /// Number of different accounts from which the user has non-dismissed filtered notifications. Capped at 100. + /// + [JsonPropertyName("pending_requests_count")] + public int PendingRequestsCount { get; set; } + + /// + /// Number of total non-dismissed filtered notifications. May be inaccurate. + /// + [JsonPropertyName("pending_notifications_count")] + public int PendingNotificationsCount { get; set; } + } +} diff --git a/Mastonet.Entities/NotificationRequest.cs b/Mastonet.Entities/NotificationRequest.cs new file mode 100644 index 0000000..3c500cf --- /dev/null +++ b/Mastonet.Entities/NotificationRequest.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + public class NotificationRequest + { + /// + /// The id of the notification request in the database. + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + + /// + /// The timestamp of the notification request, i.e. when the first filtered notification from that user was created. + /// + [JsonPropertyName("created_at")] + public string CreatedAt { get; set; } = string.Empty; + + /// + /// The timestamp of when the notification request was last updated. + /// + [JsonPropertyName("updated_at")] + public string UpdatedAt { get; set; } = string.Empty; + + /// + /// The account that performed the action that generated the filtered notifications. + /// + [JsonPropertyName("account")] + public Account Account { get; set; } = new Account(); + + /// + /// How many of this account’s notifications were filtered. + /// + [JsonPropertyName("notifications_count")] + public string NotificationsCount { get; set; } = string.Empty; + + /// + /// Most recent status associated with a filtered notification from that account. + /// + [JsonPropertyName("last_status")] + public string LastStatus { get; set; } = string.Empty; + } +} From b017984c49bc38de7c6752990ad2cced0fda272d Mon Sep 17 00:00:00 2001 From: Eduardo Braga Date: Sat, 5 Oct 2024 10:53:02 -0300 Subject: [PATCH 6/6] Added requestedby property to Relationship, summary to following in Tag, and fixed some Report properties. Added translation type. --- Mastonet.Entities/Relationship.cs | 6 +++ Mastonet.Entities/Report.cs | 55 ++++++++++++++++++++- Mastonet.Entities/Tag.cs | 5 +- Mastonet.Entities/Translation.cs | 79 +++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 Mastonet.Entities/Translation.cs diff --git a/Mastonet.Entities/Relationship.cs b/Mastonet.Entities/Relationship.cs index 561896c..af48ed9 100644 --- a/Mastonet.Entities/Relationship.cs +++ b/Mastonet.Entities/Relationship.cs @@ -28,6 +28,12 @@ public class Relationship [JsonPropertyName("requested")] public bool Requested { get; set; } + /// + /// Has this user requested to follow you? + /// + [JsonPropertyName("requested_by")] + public bool RequestedBy { get; set; } + /// /// Are you featuring this user on your profile? /// diff --git a/Mastonet.Entities/Report.cs b/Mastonet.Entities/Report.cs index 6d9e2a1..6cc94cd 100644 --- a/Mastonet.Entities/Report.cs +++ b/Mastonet.Entities/Report.cs @@ -17,8 +17,59 @@ public class Report public string Id { get; set; } = string.Empty; /// - /// The action taken in response to the report + /// Whether an action was taken yet. /// [JsonPropertyName("action_taken")] - public string? ActionTaken { get; set; } + public bool ActionTaken { get; set; } + + /// + /// When an action was taken against the report. + /// + [JsonPropertyName("action_taken_at")] + public string? ActionTakenAt { get; set; } + + /// + /// The generic reason for the report. One of: + /// spam = Unwanted or repetitive content + /// violation = A specific rule was violated + /// other = Some other reason + /// + [JsonPropertyName("category")] + public string Category { get; set; } = string.Empty; + + /// + /// The reason for the report. + /// + [JsonPropertyName("comment")] + public string Comment { get; set; } = string.Empty; + + /// + /// Whether the report was forwarded to a remote domain. + /// + [JsonPropertyName("forwarded")] + public bool Forwarded { get; set; } + + /// + /// When the report was created. + /// + [JsonPropertyName("created_at")] + public string CreatedAt { get; set; } = string.Empty; + + /// + /// IDs of statuses that have been attached to this report for additional context. + /// + [JsonPropertyName("status_ids")] + public IEnumerable? StatusIds { get; set; } + + /// + /// IDs of the rules that have been cited as a violation by this report. + /// + [JsonPropertyName("rule_ids")] + public IEnumerable? RuleIds { get; set; } + + /// + /// The account that was reported. + /// + [JsonPropertyName("target_account")] + public Account TargetAccount { get; set; } = new Account(); } diff --git a/Mastonet.Entities/Tag.cs b/Mastonet.Entities/Tag.cs index 0b3742d..065b6e0 100644 --- a/Mastonet.Entities/Tag.cs +++ b/Mastonet.Entities/Tag.cs @@ -27,7 +27,10 @@ public class Tag /// [JsonPropertyName("history")] public IEnumerable? History { get; set; } - + + /// + /// Whether the current token’s authorized user is following this tag. + /// [JsonPropertyName("following")] public bool? Following { get; set; } } diff --git a/Mastonet.Entities/Translation.cs b/Mastonet.Entities/Translation.cs new file mode 100644 index 0000000..4e62d37 --- /dev/null +++ b/Mastonet.Entities/Translation.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Json.Serialization; + +namespace Mastonet.Entities +{ + /// + /// Represents the result of machine translating some status content + /// + public class Translation + { + /// + /// HTML-encoded translated content of the status. + /// + [JsonPropertyName("content")] + public string Content { get; set; } = string.Empty; + + /// + /// The translated spoiler warning of the status. + /// + [JsonPropertyName("spoiler_text")] + public string SpoilerText { get; set; } = string.Empty; + + /// + /// The translated poll of the status. + /// + [JsonPropertyName("poll")] + public TranslatedPoll? TranslatedPoll { get; set; } + + /// + /// The translated media descriptions of the status. + /// + [JsonPropertyName("media_attachments")] + public TranslatedAttachments? TranslatedAttachments { get; set; } + + /// + /// The language of the source text, as auto-detected by the machine translation provider. + /// + [JsonPropertyName("detected_source_language")] + public string DetectedSourceLanguage { get; set; } = string.Empty; + + /// + /// The language of the source text, as auto-detected by the machine translation provider. + /// + [JsonPropertyName("provider")] + public string provider { get; set; } = string.Empty; + } + + public class TranslatedPoll + { + /// + /// The ID of the poll. + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + + /// + /// The translated poll options. + /// + [JsonPropertyName("options")] + public string Options { get; set; } = string.Empty; + } + + public class TranslatedAttachments + { + /// + /// The id of the attachment. + /// + [JsonPropertyName("id")] + public string Id { get; set; } = string.Empty; + + /// + /// The translated description of the attachment. + /// + [JsonPropertyName("description")] + public string Description { get; set; } = string.Empty; + } +}