using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Iceshrimp.Frontend.Core.Miscellaneous; using Iceshrimp.Frontend.Core.Services; using Iceshrimp.Shared.Schemas.Web; namespace Iceshrimp.Frontend.Core.ControllerModels; internal class NoteControllerModel(ApiClient api) { public Task GetNote(string id) => api.CallNullable(HttpMethod.Get, $"/notes/{id}"); public Task DeleteNote(string id) => api.CallNullable(HttpMethod.Delete, $"/notes/{id}"); public Task?> GetNoteAscendants(string id, [DefaultValue(20)] [Range(1, 100)] int? limit) { var query = new QueryString(); if (limit.HasValue) query.Add("limit", limit.Value.ToString()); return api.CallNullable>(HttpMethod.Get, $"/notes/{id}/ascendants", query); } public Task?> GetNoteDescendants(string id, [DefaultValue(20)] [Range(1, 100)] int? depth) { var query = new QueryString(); if (depth.HasValue) query.Add("depth", depth.Value.ToString()); return api.CallNullable>(HttpMethod.Get, $"/notes/{id}/descendants", query); } public Task?> GetNoteReactions(string id, string name) => api.CallNullable>(HttpMethod.Get, $"/notes/{id}/reactions/{name}"); public Task BiteNote(string id) => api.Call(HttpMethod.Post, $"/notes/{id}/bite"); public Task LikeNote(string id) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/like"); public Task UnlikeNote(string id) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/unlike"); public Task>?> GetNoteLikes(string id, PaginationQuery pq) => api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/likes", pq); public Task RenoteNote(string id, NoteVisibility? visibility = null) { var query = new QueryString(); if (visibility.HasValue) query.Add("visibility", ((int)visibility.Value).ToString().ToLowerInvariant()); return api.CallNullable(HttpMethod.Post, $"/notes/{id}/renote", query); } public Task UnrenoteNote(string id) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/unrenote"); public Task>?> GetRenotes(string id, PaginationQuery pq) => api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/renotes", pq); public Task>?> GetQuotes(string id, PaginationQuery pq) => api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/quotes"); public Task ReactToNote(string id, string name) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/react/{name}"); public Task RemoveReactionFromNote(string id, string name) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/unreact/{name}"); public Task CreateNote(NoteCreateRequest request) => api.Call(HttpMethod.Post, "/notes", data: request); public Task RefetchNote(string id) => api.CallNullable(HttpMethod.Get, $"/notes/{id}/refetch"); public Task MuteNote(string id) => api.Call(HttpMethod.Post, $"/notes/{id}/mute"); }