Compare commits
3 commits
81246c09eb
...
4c0b3a9327
Author | SHA1 | Date | |
---|---|---|---|
|
4c0b3a9327 | ||
|
75255633e0 | ||
|
7a4ead1839 |
3 changed files with 73 additions and 3 deletions
31
Pleroma/Models/ModerationLogEntry.cs
Normal file
31
Pleroma/Models/ModerationLogEntry.cs
Normal 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;
|
||||
}
|
|
@ -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!;
|
||||
|
|
|
@ -236,6 +236,7 @@ public class Pleroma
|
|||
/// <param name="quoting"> ID of the status being quoted.</param>
|
||||
/// <param name="language">ISO 639 language code for this status.</param>
|
||||
/// <param name="attachments">Array of Attachment ids to be attached as media.</param>
|
||||
/// <param name="to">A list of nicknames (like <c>lain@soykaf.club</c> or <c>lain</c> on the local server) that will be used to determine who is going to be addressed by this post. Using this will disable the implicit addressing by mentioned names in the <paramref name="content"/>, only the people in the <paramref name="to"/> list will be addressed. The normal rules for post visibility are not affected by this and will still apply</param>
|
||||
/// <param name="visibility">Visibility of the posted status.</param>
|
||||
/// <exception cref="HttpRequestException">Thrown if something goes wrong while publishing the status.</exception>
|
||||
/// <returns>The newly published status if posting was successful.</returns>
|
||||
|
@ -246,6 +247,7 @@ public class Pleroma
|
|||
string? quoting = null,
|
||||
string? language = null,
|
||||
MediaID[]? attachments = null,
|
||||
string[]? to = null,
|
||||
StatusVisibility visibility = StatusVisibility.Public)
|
||||
{
|
||||
if (content == null && (attachments == null || attachments.Length == 0))
|
||||
|
@ -305,6 +307,15 @@ public class Pleroma
|
|||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
if (to != null)
|
||||
{
|
||||
writer.WritePropertyName("to");
|
||||
writer.WriteStartArray();
|
||||
foreach (string name in to)
|
||||
writer.WriteStringValue(name);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
if (visibility != StatusVisibility.Public)
|
||||
{
|
||||
writer.WritePropertyName("visibility");
|
||||
|
@ -392,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>
|
||||
|
@ -805,7 +836,7 @@ public class PleromaAdmin : Pleroma
|
|||
})))!;
|
||||
}
|
||||
|
||||
public Task<Status> ChangeScope(StatusID id, bool? sensitive = null, StatusVisibility? visibility = null)
|
||||
public Task<Status> ChangeScope(StatusID status, bool? sensitive = null, StatusVisibility? visibility = null)
|
||||
{
|
||||
MemoryStream mem = new MemoryStream();
|
||||
|
||||
|
@ -832,12 +863,20 @@ public class PleromaAdmin : Pleroma
|
|||
return Retry<Status>(() =>
|
||||
{
|
||||
mem.Position = 0;
|
||||
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Put, $"/api/v1/pleroma/admin/statuses/{id}");
|
||||
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Put, $"/api/v1/pleroma/admin/statuses{WebUtility.UrlEncode(status.ID)}");
|
||||
req.Content = new StreamContent(mem);
|
||||
req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
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>))]
|
||||
|
|
Loading…
Reference in a new issue