using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Iceshrimp.Frontend.Core.Services; using Iceshrimp.Shared.Schemas; using Microsoft.AspNetCore.Http; namespace Iceshrimp.Frontend.Core.ControllerModels; internal class NoteControllerModel(ApiClient api) { public Task GetNote(string id) => api.CallNullable(HttpMethod.Get, $"/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.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.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 LikeNote(string id) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/like"); public Task UnlikeNote(string id) => api.CallNullable(HttpMethod.Post, $"/notes/{id}/unlike"); 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); }