diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs index 2f61b891..41938186 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs @@ -8,8 +8,11 @@ using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Controllers.Mastodon.Renderers; -public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer, UserRenderer userRenderer) - : IScopedService +public class NotificationRenderer( + DatabaseContext db, + NoteRenderer noteRenderer, + UserRenderer userRenderer +) : IScopedService { public async Task RenderAsync( Notification notification, User user, bool isPleroma, List? accounts = null, @@ -107,8 +110,8 @@ public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer, Url = e.PublicUrl }) .ToArrayAsync() - .ContinueWithResultAsync(res => res.DistinctBy(e => e.Name) - .ToDictionary(e => e.Name, e => e.Url)); + .ContinueWithResult(res => res.DistinctBy(e => e.Name) + .ToDictionary(e => e.Name, e => e.Url)); return await notificationList .Select(p => RenderAsync(p, user, isPleroma, accounts, notes, emojiUrls)) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs index b49cb78a..e1581270 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs @@ -120,7 +120,7 @@ public sealed class WebSocketConnection( .Select(p => p.UserId) .Distinct() .ToArrayAsync() - .ContinueWithResultAsync(p => p.ToHashSet()); + .ContinueWithResult(p => p.ToHashSet()); } public async Task HandleSocketMessageAsync(string payload) @@ -350,7 +350,7 @@ public sealed class WebSocketConnection( .Where(p => p.UserList.UserId == Token.User.Id && p.UserList.HideFromHomeTl) .Select(p => p.UserId) .ToArrayAsync() - .ContinueWithResultAsync(p => p.ToHashSet()); + .ContinueWithResult(p => p.ToHashSet()); } catch (Exception e) { diff --git a/Iceshrimp.Backend/Controllers/Web/AdminController.cs b/Iceshrimp.Backend/Controllers/Web/AdminController.cs index 603c9bb9..be6fc90d 100644 --- a/Iceshrimp.Backend/Controllers/Web/AdminController.cs +++ b/Iceshrimp.Backend/Controllers/Web/AdminController.cs @@ -263,13 +263,13 @@ public class AdminController( { return await db.Relays .ToArrayAsync() - .ContinueWithResultAsync(res => res.Select(p => new RelaySchemas.RelayResponse - { - Id = p.Id, - Inbox = p.Inbox, - Status = (RelaySchemas.RelayStatus)p.Status - }) - .ToList()); + .ContinueWithResult(res => res.Select(p => new RelaySchemas.RelayResponse + { + Id = p.Id, + Inbox = p.Inbox, + Status = (RelaySchemas.RelayStatus)p.Status + }) + .ToList()); } [HttpPost("relays")] diff --git a/Iceshrimp.Backend/Controllers/Web/MigrationController.cs b/Iceshrimp.Backend/Controllers/Web/MigrationController.cs index 7631e5ef..9f5401eb 100644 --- a/Iceshrimp.Backend/Controllers/Web/MigrationController.cs +++ b/Iceshrimp.Backend/Controllers/Web/MigrationController.cs @@ -71,9 +71,7 @@ public class MigrationController( aliasUri ??= await db.Users.IncludeCommonProperties() .Where(p => p.Id == rq.UserId) .FirstOrDefaultAsync() - .ContinueWithResultAsync(p => p is null - ? null - : p.Uri ?? p.GetPublicUri(config.Value)); + .ContinueWithResult(p => p is null ? null : p.Uri ?? p.GetPublicUri(config.Value)); } if (aliasUri is null) throw GracefulException.NotFound("Alias user not found"); diff --git a/Iceshrimp.Backend/Controllers/Web/UserController.cs b/Iceshrimp.Backend/Controllers/Web/UserController.cs index 17c79592..e0971bed 100644 --- a/Iceshrimp.Backend/Controllers/Web/UserController.cs +++ b/Iceshrimp.Backend/Controllers/Web/UserController.cs @@ -95,7 +95,7 @@ public class UserController( .Paginate(pq, ControllerContext) .PrecomputeVisibilities(localUser) .ToListAsync() - .ContinueWithResultAsync(res => res.EnforceRenoteReplyVisibility()); + .ContinueWithResult(res => res.EnforceRenoteReplyVisibility()); return await noteRenderer.RenderManyAsync(notes, localUser, Filter.FilterContext.Accounts); } diff --git a/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs b/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs index 4229d3b3..f7174122 100644 --- a/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs @@ -1,5 +1,8 @@ +using System.Diagnostics.CodeAnalysis; + namespace Iceshrimp.Backend.Core.Extensions; +[SuppressMessage("ReSharper", "InconsistentNaming")] public static class TaskExtensions { public static async Task SafeWaitAsync(this Task task, TimeSpan timeSpan) @@ -58,13 +61,13 @@ public static class TaskExtensions return (await task).ToList(); } - public static async Task ContinueWithResultAsync(this Task task, Action continuation) + public static async Task ContinueWithResult(this Task task, Action continuation) { await task; continuation(); } - public static async Task ContinueWithResultAsync( + public static async Task ContinueWithResult( this Task task, Func continuation ) { @@ -72,25 +75,25 @@ public static class TaskExtensions return continuation(); } - public static async Task ContinueWithResultAsync(this Task task, Action continuation) + public static async Task ContinueWithResult(this Task task, Action continuation) { continuation(await task); } - public static async Task ContinueWithResultAsync( + public static async Task ContinueWithResult( this Task task, Func continuation ) { return continuation(await task); } - public static async Task ContinueWithResultAsync(this Task task, Func continuation) + public static async Task ContinueWithResult(this Task task, Func continuation) { await task; await continuation(); } - public static async Task ContinueWithResultAsync( + public static async Task ContinueWithResult( this Task task, Func> continuation ) { @@ -98,12 +101,12 @@ public static class TaskExtensions return await continuation(); } - public static async Task ContinueWithResultAsync(this Task task, Func continuation) + public static async Task ContinueWithResult(this Task task, Func continuation) { await continuation(await task); } - public static async Task ContinueWithResultAsync( + public static async Task ContinueWithResult( this Task task, Func> continuation ) { diff --git a/Iceshrimp.Backend/Core/Services/DriveService.cs b/Iceshrimp.Backend/Core/Services/DriveService.cs index 525d158e..a84febcb 100644 --- a/Iceshrimp.Backend/Core/Services/DriveService.cs +++ b/Iceshrimp.Backend/Core/Services/DriveService.cs @@ -286,7 +286,7 @@ public class DriveService( .Select(p => ProcessAndStoreFileVersionAsync(p.Key, p.Value, request.Filename)) .AwaitAllNoConcurrencyAsync() - .ContinueWithResultAsync(p => p.ToImmutableArray()); + .ContinueWithResult(p => p.ToImmutableArray()); original = processed.FirstOrDefault(p => p?.format.Key == KeyEnum.Original) ?? throw new Exception("Image processing didn't result in an original version"); diff --git a/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs b/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs index 8594b879..a96e91f8 100644 --- a/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs +++ b/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs @@ -247,15 +247,15 @@ public class StorageMaintenanceService( p.PublicAccessKey }) .ToArrayAsync() - .ContinueWithResultAsync(res => res.SelectMany(p => new List - { - p.AccessKey, - p.ThumbnailAccessKey, - p.PublicAccessKey - }) - .NotNull() - .Append(".iceshrimp-test") - .ToHashSet()); + .ContinueWithResult(res => res.SelectMany(p => new List + { + p.AccessKey, + p.ThumbnailAccessKey, + p.PublicAccessKey + }) + .NotNull() + .Append(".iceshrimp-test") + .ToHashSet()); logger.LogInformation("Loaded {count} files from database.", filenames.Count); var count = 0;