a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/api] Add visibility to NoteCreateRequest, use enum conversions instead of strings to represent note visibility

+21 -21
+2 -2
Iceshrimp.Backend/Controllers/NoteController.cs
··· 226 226 throw GracefulException.BadRequest("Renote target is nonexistent or inaccessible") 227 227 : null; 228 228 229 - var note = await noteSvc.CreateNoteAsync(user, Note.NoteVisibility.Public, request.Text, request.Cw, reply, 230 - renote); 229 + var note = await noteSvc.CreateNoteAsync(user, (Note.NoteVisibility)request.Visibility, request.Text, 230 + request.Cw, reply, renote); 231 231 232 232 return Ok(await noteRenderer.RenderOne(note, user)); 233 233 }
+1 -10
Iceshrimp.Backend/Controllers/Renderers/NoteRenderer.cs
··· 71 71 CreatedAt = note.CreatedAt.ToStringIso8601Like(), 72 72 Text = note.Text, 73 73 Cw = note.Cw, 74 - Visibility = RenderVisibility(note.Visibility), 74 + Visibility = (NoteVisibility)note.Visibility, 75 75 User = noteUser, 76 76 Attachments = attachments.ToList(), 77 77 Reactions = reactions.ToList(), ··· 81 81 Liked = liked 82 82 }; 83 83 } 84 - 85 - private static string RenderVisibility(Note.NoteVisibility visibility) => visibility switch 86 - { 87 - Note.NoteVisibility.Public => "public", 88 - Note.NoteVisibility.Home => "home", 89 - Note.NoteVisibility.Followers => "followers", 90 - Note.NoteVisibility.Specified => "specified", 91 - _ => throw new ArgumentOutOfRangeException(nameof(visibility), visibility, null) 92 - }; 93 84 94 85 private async Task<List<UserResponse>> GetUsers(List<Note> notesList) 95 86 {
+4 -4
Iceshrimp.Backend/Core/Database/Tables/Note.cs
··· 33 33 [PgName("note_visibility_enum")] 34 34 public enum NoteVisibility 35 35 { 36 - [PgName("public")] Public, 37 - [PgName("home")] Home, 38 - [PgName("followers")] Followers, 39 - [PgName("specified")] Specified 36 + [PgName("public")] Public = 0, 37 + [PgName("home")] Home = 1, 38 + [PgName("followers")] Followers = 2, 39 + [PgName("specified")] Specified = 3 40 40 } 41 41 42 42 /// <summary>
+5 -4
Iceshrimp.Shared/Schemas/NoteCreateRequest.cs
··· 4 4 5 5 public class NoteCreateRequest 6 6 { 7 - [J("text")] public required string Text { get; set; } 8 - [J("cw")] public string? Cw { get; set; } 9 - [J("replyId")] public string? ReplyId { get; set; } 10 - [J("renoteId")] public string? RenoteId { get; set; } 7 + [J("text")] public required string Text { get; set; } 8 + [J("cw")] public string? Cw { get; set; } 9 + [J("replyId")] public string? ReplyId { get; set; } 10 + [J("renoteId")] public string? RenoteId { get; set; } 11 + [J("visibility")] public required NoteVisibility Visibility { get; set; } 11 12 }
+9 -1
Iceshrimp.Shared/Schemas/NoteResponse.cs
··· 34 34 [J("createdAt")] public required string CreatedAt { get; set; } 35 35 [J("text")] public required string? Text { get; set; } 36 36 [J("cw")] public required string? Cw { get; set; } 37 - [J("visibility")] public required string Visibility { get; set; } 37 + [J("visibility")] public required NoteVisibility Visibility { get; set; } 38 38 [J("liked")] public required bool Liked { get; set; } 39 39 [J("likes")] public required int Likes { get; set; } 40 40 [J("renotes")] public required int Renotes { get; set; } ··· 67 67 [J("filterId")] public required long Id { get; set; } 68 68 [J("keyword")] public required string Keyword { get; set; } 69 69 [J("drop")] public required bool Hide { get; set; } 70 + } 71 + 72 + public enum NoteVisibility 73 + { 74 + Public = 0, 75 + Home = 1, 76 + Followers = 2, 77 + Specified = 3 70 78 }