Compare commits
3 commits
b4052c6460
...
e5273860a6
Author | SHA1 | Date | |
---|---|---|---|
|
e5273860a6 | ||
|
b623cb5fc6 | ||
|
79f15e0439 |
11 changed files with 61 additions and 15 deletions
|
@ -53,6 +53,10 @@ public class Account : ASObject
|
|||
}
|
||||
}
|
||||
|
||||
internal Account()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => $"@{Webfinger}";
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,8 @@ public class AccountField
|
|||
public string Value { get; set; } = null!;
|
||||
|
||||
public DateTime? VerifiedAt { get; set; }
|
||||
|
||||
internal AccountField()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ public class Attachment
|
|||
[JsonPropertyName("url")]
|
||||
public string URL { get; set; } = null!;
|
||||
|
||||
internal Attachment()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downloads the attachment.
|
||||
/// </summary>
|
||||
|
|
|
@ -7,4 +7,8 @@ public class Context
|
|||
|
||||
[JsonPropertyName("descendants")]
|
||||
public Status[] Descendants { get; set; } = null!;
|
||||
|
||||
internal Context()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -14,5 +14,9 @@ public class Hashtag
|
|||
[JsonPropertyName("url")]
|
||||
public string URL { get; set; } = null!;
|
||||
|
||||
internal Hashtag()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => $"#{Name}";
|
||||
}
|
|
@ -28,5 +28,9 @@ public class Mention
|
|||
[JsonPropertyName("username")]
|
||||
public string Username { get; set; } = null!;
|
||||
|
||||
internal Mention()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => $"@{Account}";
|
||||
}
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
namespace Uwaa.Pleroma;
|
||||
|
||||
public class PleromaException : Exception
|
||||
public abstract class PleromaException : Exception
|
||||
{
|
||||
public override string ToString() => Message;
|
||||
}
|
||||
|
||||
public class PleromaSimpleException : PleromaException
|
||||
{
|
||||
[JsonPropertyName("error")]
|
||||
public string Text { get; set; } = null!;
|
||||
|
||||
public override string Message => Text;
|
||||
|
||||
public override string ToString() => Message;
|
||||
}
|
||||
|
||||
public class PleromaAggregateException : Exception
|
||||
public class PleromaAggregateException : PleromaException
|
||||
{
|
||||
[JsonPropertyName("errors")]
|
||||
public PleromaInnerException[] Text { get; set; } = null!;
|
||||
|
||||
public override string Message => string.Join("\n", (object?[])Text);
|
||||
|
||||
public override string ToString() => Message;
|
||||
public override Exception GetBaseException() => Text == null ? this : Text[0];
|
||||
}
|
||||
|
||||
public class PleromaInnerException : Exception
|
||||
public class PleromaInnerException : PleromaException
|
||||
{
|
||||
[JsonPropertyName("detail")]
|
||||
public string Text { get; set; } = null!;
|
||||
|
||||
public override string Message => Text;
|
||||
|
||||
public override string ToString() => Message;
|
||||
}
|
|
@ -49,4 +49,8 @@ public class Relationship
|
|||
|
||||
[JsonPropertyName("subscribing")]
|
||||
public bool Subscribing { get; set; }
|
||||
|
||||
internal Relationship()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,8 @@ public class SearchResults
|
|||
/// </summary>
|
||||
[JsonPropertyName("statuses")]
|
||||
public Status[]? Statuses { get; set; }
|
||||
|
||||
internal SearchResults()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,6 +140,10 @@ public class Status : ASObject
|
|||
[JsonIgnore]
|
||||
public string Content => Pleroma?.Content?.Plain ?? HtmlContent;
|
||||
|
||||
internal Status()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if a status mentions or replies to a user.
|
||||
/// </summary>
|
||||
|
@ -165,12 +169,20 @@ public class PleromaStatusData
|
|||
|
||||
[JsonPropertyName("quote_id")]
|
||||
public string? QuoteID { get; set; }
|
||||
|
||||
internal PleromaStatusData()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class PleromaStatusContent
|
||||
{
|
||||
[JsonPropertyName("text/plain")]
|
||||
public string Plain { get; set; } = null!;
|
||||
|
||||
internal PleromaStatusContent()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StatusIDConverter))]
|
||||
|
|
|
@ -69,7 +69,7 @@ public class Pleroma
|
|||
{
|
||||
try
|
||||
{
|
||||
PleromaException? err = JsonSerializer.Deserialize<PleromaException>(text, SerializerOptions);
|
||||
PleromaSimpleException? err = JsonSerializer.Deserialize<PleromaSimpleException>(text, SerializerOptions);
|
||||
if (err != null && err.Text != null)
|
||||
{
|
||||
if (err.Text == "Throttled")
|
||||
|
@ -85,7 +85,7 @@ public class Pleroma
|
|||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
//Not an error
|
||||
//Not a simple error
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -96,8 +96,10 @@ public class Pleroma
|
|||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
//Not an error
|
||||
//Not an aggregate error
|
||||
}
|
||||
|
||||
throw new HttpRequestException(text);
|
||||
}
|
||||
|
||||
if (res.StatusCode is >= (HttpStatusCode)200 and < (HttpStatusCode)300)
|
||||
|
@ -439,7 +441,6 @@ public class Pleroma
|
|||
/// <param name="instance">Show only statuses from the given domain</param>
|
||||
/// <param name="only_media">Show only statuses with media attached?</param>
|
||||
/// <param name="with_muted">Include activities by muted users</param>
|
||||
/// <param name="exclude_visibilities">Exclude the statuses with the given visibilities</param>
|
||||
/// <param name="reply_visibility">Filter replies.</param>
|
||||
/// <param name="max_id">Return items older than this ID</param>
|
||||
/// <param name="min_id">Return the oldest items newer than this ID</param>
|
||||
|
@ -452,7 +453,6 @@ public class Pleroma
|
|||
string? instance = null,
|
||||
bool only_media = false,
|
||||
bool with_muted = false,
|
||||
StatusVisibility[]? exclude_visibilities = null,
|
||||
ReplyVisibility reply_visibility = ReplyVisibility.All,
|
||||
string? max_id = null,
|
||||
string? min_id = null,
|
||||
|
@ -491,7 +491,6 @@ public class Pleroma
|
|||
if (only_media) addPair("only_media", "true");
|
||||
if (remote) addPair("remote", "true");
|
||||
if (with_muted) addPair("with_muted", "true");
|
||||
if (exclude_visibilities != null) addPair("exclude_visibilities", JsonSerializer.Serialize(exclude_visibilities));
|
||||
if (reply_visibility != ReplyVisibility.All) addPair("reply_visibility", reply_visibility.ToString().ToLowerInvariant());
|
||||
if (max_id != null) addPair("max_id", max_id);
|
||||
if (min_id != null) addPair("min_id", min_id);
|
||||
|
@ -541,7 +540,9 @@ public class Pleroma
|
|||
if (with_muted) addPair("with_muted", "true");
|
||||
if (exclude_reblogs) addPair("exclude_reblogs", "true");
|
||||
if (exclude_replies) addPair("exclude_replies", "true");
|
||||
if (exclude_visibilities != null) addPair("exclude_visibilities", JsonSerializer.Serialize(exclude_visibilities));
|
||||
if (exclude_visibilities != null)
|
||||
foreach (StatusVisibility visibility in exclude_visibilities)
|
||||
addPair("exclude_visibilities[]", visibility.ToString().ToLowerInvariant());
|
||||
if (max_id != null) addPair("max_id", max_id);
|
||||
if (min_id != null) addPair("min_id", min_id);
|
||||
if (since_id != null) addPair("since_id", since_id);
|
||||
|
|
Loading…
Reference in a new issue