pleroma stuff
This commit is contained in:
parent
5b8b31932d
commit
c606e4ed02
6 changed files with 46 additions and 19 deletions
|
@ -15,9 +15,7 @@ static class Program
|
||||||
static void PrintStatus(Status status)
|
static void PrintStatus(Status status)
|
||||||
{
|
{
|
||||||
Console.Write('\t');
|
Console.Write('\t');
|
||||||
Console.Write(status.CreatedAt.ToShortDateString());
|
Console.Write(status.CreatedAt.ToString("dd/MM/yy HH:mm:ss"));
|
||||||
Console.Write(' ');
|
|
||||||
Console.Write(status.CreatedAt.ToLongTimeString());
|
|
||||||
Console.Write(' ');
|
Console.Write(' ');
|
||||||
Console.WriteLine(status);
|
Console.WriteLine(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class AccountField
|
||||||
[JsonPropertyName("value")]
|
[JsonPropertyName("value")]
|
||||||
public string Value { get; set; } = null!;
|
public string Value { get; set; } = null!;
|
||||||
|
|
||||||
public DateTime? VerifiedAt { get; set; }
|
public DateTimeOffset? VerifiedAt { get; set; }
|
||||||
|
|
||||||
[JsonConstructor()]
|
[JsonConstructor()]
|
||||||
internal AccountField()
|
internal AccountField()
|
||||||
|
|
|
@ -54,16 +54,6 @@ public class Attachment
|
||||||
internal Attachment()
|
internal Attachment()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Downloads the attachment.
|
|
||||||
/// </summary>
|
|
||||||
public async Task<byte[]> Download()
|
|
||||||
{
|
|
||||||
using HttpClient client = new HttpClient();
|
|
||||||
HttpResponseMessage res = await client.GetAsync(URL);
|
|
||||||
return await res.Content.ReadAsByteArrayAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(EnumLowerCaseConverter<AttachmentType>))]
|
[JsonConverter(typeof(EnumLowerCaseConverter<AttachmentType>))]
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class Notification : ASObject
|
||||||
public Account Account { get; set; } = null!;
|
public Account Account { get; set; } = null!;
|
||||||
|
|
||||||
[JsonPropertyName("created_at")]
|
[JsonPropertyName("created_at")]
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTimeOffset CreatedAt { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Group key shared by similar notifications
|
/// Group key shared by similar notifications
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class Status : ASObject
|
||||||
/// The date when this status was created
|
/// The date when this status was created
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonPropertyName("created_at")]
|
[JsonPropertyName("created_at")]
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTimeOffset CreatedAt { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Have you favourited this status?
|
/// Have you favourited this status?
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class Pleroma
|
||||||
public Task<Status> PostStatus(string? content = null,
|
public Task<Status> PostStatus(string? content = null,
|
||||||
bool sensitive = false,
|
bool sensitive = false,
|
||||||
int? expiresIn = null,
|
int? expiresIn = null,
|
||||||
string? replyTo = null,
|
StatusID? replyTo = null,
|
||||||
string? quoting = null,
|
string? quoting = null,
|
||||||
string? language = null,
|
string? language = null,
|
||||||
MediaID[]? attachments = null,
|
MediaID[]? attachments = null,
|
||||||
|
@ -273,10 +273,10 @@ public class Pleroma
|
||||||
writer.WriteNumberValue(expiresIn.Value);
|
writer.WriteNumberValue(expiresIn.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replyTo != null)
|
if (replyTo.HasValue)
|
||||||
{
|
{
|
||||||
writer.WritePropertyName("in_reply_to_id");
|
writer.WritePropertyName("in_reply_to_id");
|
||||||
writer.WriteStringValue(replyTo);
|
writer.WriteStringValue(replyTo.Value.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quoting != null)
|
if (quoting != null)
|
||||||
|
@ -615,6 +615,26 @@ public class Pleroma
|
||||||
})))!;
|
})))!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downloads an attachment.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<byte[]> Download(Attachment attachment)
|
||||||
|
{
|
||||||
|
HttpResponseMessage res = await HttpClient.GetAsync(attachment.URL);
|
||||||
|
res.EnsureSuccessStatusCode();
|
||||||
|
return await res.Content.ReadAsByteArrayAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downloads an attachment as a <see cref="Stream"/>.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<Stream> DownloadStream(Attachment attachment)
|
||||||
|
{
|
||||||
|
HttpResponseMessage res = await HttpClient.GetAsync(attachment.URL);
|
||||||
|
res.EnsureSuccessStatusCode();
|
||||||
|
return await res.Content.ReadAsStreamAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Notifications concerning the user. This API returns Link headers containing links to the next/previous page. However, the links can also be constructed dynamically using query params and <c>id</c> values.
|
/// Notifications concerning the user. This API returns Link headers containing links to the next/previous page. However, the links can also be constructed dynamically using query params and <c>id</c> values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -683,6 +703,25 @@ public class Pleroma
|
||||||
/// <param name="notifications">Array of notification IDs to dismiss</param>
|
/// <param name="notifications">Array of notification IDs to dismiss</param>
|
||||||
public Task Dismiss(NotificationID[] notifications)
|
public Task Dismiss(NotificationID[] notifications)
|
||||||
{
|
{
|
||||||
|
if (notifications.Length == 0)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
|
return Retry(() => new HttpRequestMessage(HttpMethod.Delete, $"/api/v1/notifications/destroy_multiple" + CreateQuery(addPair =>
|
||||||
|
{
|
||||||
|
foreach (NotificationID id in notifications)
|
||||||
|
addPair("ids[]", id.ID);
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears multiple notifications from the server.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="notifications">Array of notifications to dismiss</param>
|
||||||
|
public Task Dismiss(Notification[] notifications)
|
||||||
|
{
|
||||||
|
if (notifications.Length == 0)
|
||||||
|
return Task.CompletedTask;
|
||||||
|
|
||||||
return Retry(() => new HttpRequestMessage(HttpMethod.Delete, $"/api/v1/notifications/destroy_multiple" + CreateQuery(addPair =>
|
return Retry(() => new HttpRequestMessage(HttpMethod.Delete, $"/api/v1/notifications/destroy_multiple" + CreateQuery(addPair =>
|
||||||
{
|
{
|
||||||
foreach (NotificationID id in notifications)
|
foreach (NotificationID id in notifications)
|
||||||
|
|
Loading…
Reference in a new issue