pleroma: merge react methods

This commit is contained in:
uwaa 2025-01-14 11:58:40 +00:00
parent 82bb4438a6
commit 616837db6d

View file

@ -772,22 +772,12 @@ public class Pleroma
} }
/// <summary> /// <summary>
/// Adds a unicode reaction to a status. /// Adds a reaction to a status.
/// </summary> /// </summary>
/// <param name="status">The status to react to.</param> /// <param name="status">The status to react to.</param>
/// <param name="emoji">The unicode emoji.</param> /// <param name="emoji">The unicode emoji or custom emoji.</param>
/// <returns>The new state of the status, if it exists.</returns> /// <returns>The new state of the status, if it exists.</returns>
public Task<Status?> React(StatusID status, char emoji) => ReactInline(status, emoji.ToString()); public Task<Status?> React(StatusID status, string emoji)
/// <summary>
/// Adds a custom reaction to a status.
/// </summary>
/// <param name="status">The status to react to.</param>
/// <param name="emojiName">The custom emoji's name.</param>
/// <returns>The new state of the status, if it exists.</returns>
public Task<Status?> React(StatusID status, string emojiName) => ReactInline(status, $":{emojiName}:");
Task<Status?> ReactInline(StatusID status, string emoji)
{ {
return Retry<Status?>(() => new HttpRequestMessage(HttpMethod.Put, $"/api/v1/pleroma/statuses/{WebUtility.UrlEncode(status.ID)}/reactions/{WebUtility.UrlEncode(emoji)}")); return Retry<Status?>(() => new HttpRequestMessage(HttpMethod.Put, $"/api/v1/pleroma/statuses/{WebUtility.UrlEncode(status.ID)}/reactions/{WebUtility.UrlEncode(emoji)}"));
} }