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] Use UserRenderer in AuthController instead of instantiating the response object directly (ISH-209)

+7 -24
+5 -22
Iceshrimp.Backend/Controllers/AuthController.cs
··· 1 1 using System.Diagnostics.CodeAnalysis; 2 2 using System.Net.Mime; 3 + using Iceshrimp.Backend.Controllers.Renderers; 3 4 using Iceshrimp.Backend.Controllers.Schemas; 4 5 using Iceshrimp.Backend.Core.Database; 5 6 using Iceshrimp.Backend.Core.Database.Tables; ··· 17 18 [EnableRateLimiting("sliding")] 18 19 [Produces(MediaTypeNames.Application.Json)] 19 20 [Route("/api/iceshrimp/v1/auth")] 20 - public class AuthController(DatabaseContext db, UserService userSvc) : ControllerBase 21 + public class AuthController(DatabaseContext db, UserService userSvc, UserRenderer userRenderer) : ControllerBase 21 22 { 22 23 [HttpGet] 23 24 [Authenticate] 24 25 [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthResponse))] 25 - public IActionResult GetAuthStatus() 26 + public async Task<IActionResult> GetAuthStatus() 26 27 { 27 28 var session = HttpContext.GetSession(); 28 29 ··· 33 34 { 34 35 Status = session.Active ? AuthStatusEnum.Authenticated : AuthStatusEnum.TwoFactor, 35 36 Token = session.Token, 36 - User = new UserResponse 37 - { 38 - Username = session.User.Username, 39 - Id = session.User.Id, 40 - AvatarUrl = session.User.AvatarUrl, 41 - BannerUrl = session.User.BannerUrl, 42 - DisplayName = session.User.DisplayName, 43 - InstanceName = null, 44 - InstanceIconUrl = null 45 - } 37 + User = await userRenderer.RenderOne(session.User) 46 38 }); 47 39 } 48 40 ··· 86 78 { 87 79 Status = session.Active ? AuthStatusEnum.Authenticated : AuthStatusEnum.TwoFactor, 88 80 Token = session.Token, 89 - User = new UserResponse 90 - { 91 - Username = session.User.Username, 92 - Id = session.User.Id, 93 - AvatarUrl = session.User.AvatarUrl, 94 - BannerUrl = session.User.BannerUrl, 95 - DisplayName = session.User.DisplayName, 96 - InstanceName = null, 97 - InstanceIconUrl = null 98 - } 81 + User = await userRenderer.RenderOne(user) 99 82 }); 100 83 } 101 84
+1 -1
Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs
··· 51 51 StatusesCount = user.NotesCount, 52 52 Note = await mfmConverter.ToHtmlAsync(profile?.Description ?? "", mentions, user.Host), 53 53 Url = profile?.Url ?? user.Uri ?? user.GetPublicUrl(config.Value), 54 - AvatarStaticUrl = user.AvatarUrl ?? user.GetIdenticonUrl(config.Value), //TODO 54 + AvatarStaticUrl = user.AvatarUrl ?? user.GetIdenticonUrlPng(config.Value), //TODO 55 55 HeaderUrl = user.BannerUrl ?? _transparent, 56 56 HeaderStaticUrl = user.BannerUrl ?? _transparent, //TODO 57 57 MovedToAccount = null, //TODO
+1 -1
Iceshrimp.Backend/Controllers/Renderers/UserRenderer.cs
··· 25 25 Id = user.Id, 26 26 Username = user.Username, 27 27 DisplayName = user.DisplayName, 28 - AvatarUrl = user.AvatarUrl ?? $"https://{config.Value.WebDomain}/identicon/{user.Id}", 28 + AvatarUrl = user.AvatarUrl ?? user.GetIdenticonUrl(config.Value), 29 29 BannerUrl = user.BannerUrl, 30 30 InstanceName = instanceName, 31 31 InstanceIconUrl = instanceIcon