From 95eb63e502babd340bd1a3ca0b11f95800733cd9 Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Wed, 12 Jul 2023 21:44:36 -0400 Subject: [PATCH] UsersController optimisations --- src/BirdsiteLive/Controllers/UsersController.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/BirdsiteLive/Controllers/UsersController.cs b/src/BirdsiteLive/Controllers/UsersController.cs index aa82d92..e6ec7b3 100644 --- a/src/BirdsiteLive/Controllers/UsersController.cs +++ b/src/BirdsiteLive/Controllers/UsersController.cs @@ -157,9 +157,10 @@ namespace BirdsiteLive.Controllers var tweet = await _twitterTweetService.GetTweetAsync(parsedStatusId); if (tweet == null) return NotFound(); - - var user = await _twitterUserService.GetUserAsync(id); + if (tweet.Author.Acct != id) + return NotFound(); + var status = _statusService.GetStatus(id, tweet); if (acceptHeaders.Any()) @@ -178,8 +179,8 @@ namespace BirdsiteLive.Controllers { Text = tweet.MessageContent, OgUrl = $"https://twitter.com/{id}/status/{statusId}", - UserProfileImage = user.ProfileImageUrl, - UserName = user.Name, + UserProfileImage = tweet.Author.ProfileImageUrl, + UserName = tweet.Author.Name, }; return View(displayTweet); } @@ -233,8 +234,6 @@ namespace BirdsiteLive.Controllers if (tweet == null) return NotFound(); - var user = await _twitterUserService.GetUserAsync(id); - var status = _statusService.GetActivity(id, tweet); var jsonApUser = JsonSerializer.Serialize(status);