pleroma: add more endpoints

This commit is contained in:
uwaa 2025-01-06 23:58:20 +00:00
parent 75255633e0
commit 4c0b3a9327
3 changed files with 60 additions and 1 deletions

View file

@ -0,0 +1,31 @@
using System.Text.Json.Nodes;
namespace Uwaa.Pleroma;
public class ModerationLog
{
[JsonPropertyName("items")]
public ModerationLogEntry[] Items { get; set; } = null!;
[JsonPropertyName("total")]
public int Total { get; set; }
}
public class ModerationLogEntry
{
[JsonPropertyName("data")]
public JsonObject Data { get; set; } = null!;
[JsonPropertyName("id")]
public int ID { get; set; }
[JsonPropertyName("message")]
public string Message { get; set; } = null!;
[JsonPropertyName("time")]
public int Time { get; set; }
public string Action => (string)Data["action"]!;
public override string ToString() => Message;
}

View file

@ -9,7 +9,7 @@ public class Page
public int PageSize { get; set; }
}
public class UsersPage
public class UsersPage : Page
{
[JsonPropertyName("users")]
public AccountInfo[] Users { get; set; } = null!;

View file

@ -403,6 +403,26 @@ public class Pleroma
}))!;
}
/// <summary>
/// Feature one of your own public statuses at the top of your profile
/// </summary>
/// <param name="status">The status to pin.</param>
/// <returns>The pinned status, if it exists.</returns>
public Task<Status?> Pin(StatusID status)
{
return Retry<Status?>(() => new HttpRequestMessage(HttpMethod.Post, $"/api/v1/statuses/{WebUtility.UrlEncode(status.ID)}/pin"));
}
/// <summary>
/// Unfeature a status from the top of your profile
/// </summary>
/// <param name="status">The status to unpin.</param>
/// <returns>The unpinned status, if it exists.</returns>
public Task<Status?> Unpin(StatusID status)
{
return Retry<Status?>(() => new HttpRequestMessage(HttpMethod.Post, $"/api/v1/statuses/{WebUtility.UrlEncode(status.ID)}/unpin"));
}
/// <summary>
/// Reposts/boosts/shares a status.
/// </summary>
@ -849,6 +869,14 @@ public class PleromaAdmin : Pleroma
return req;
})!;
}
public Task<ModerationLog> GetModerationLog(int page = 1)
{
return Retry<ModerationLog>(() => new HttpRequestMessage(HttpMethod.Get, $"/api/v1/pleroma/admin/moderation_log" + CreateQuery(addPair =>
{
addPair("page", page.ToString());
})))!;
}
}
[JsonConverter(typeof(EnumLowerCaseConverter<ActorType>))]