diff --git a/Iceshrimp.Backend/Components/Helpers/AsyncComponentBase.cs b/Iceshrimp.Backend/Components/Helpers/AsyncComponentBase.cs index 81119fde..948ab7ff 100644 --- a/Iceshrimp.Backend/Components/Helpers/AsyncComponentBase.cs +++ b/Iceshrimp.Backend/Components/Helpers/AsyncComponentBase.cs @@ -35,14 +35,14 @@ public class AsyncComponentBase : ComponentBase { OnParametersSet(); await OnParametersSetAsync(); - await RunMethodHandler(); + await RunMethodHandlerAsync(); StateHasChanged(); } protected virtual Task OnPost() => Task.CompletedTask; protected virtual Task OnGet() => Task.CompletedTask; - private async Task RunMethodHandler() + private async Task RunMethodHandlerAsync() { if (string.Equals(Context.Request.Method, "GET", StringComparison.InvariantCultureIgnoreCase)) await OnGet(); diff --git a/Iceshrimp.Backend/Components/PublicPreview/Renderers/MfmRenderer.cs b/Iceshrimp.Backend/Components/PublicPreview/Renderers/MfmRenderer.cs index 27885332..92af4b46 100644 --- a/Iceshrimp.Backend/Components/PublicPreview/Renderers/MfmRenderer.cs +++ b/Iceshrimp.Backend/Components/PublicPreview/Renderers/MfmRenderer.cs @@ -12,7 +12,7 @@ public class MfmRenderer(IOptions config) : ISingletonSe { private readonly MfmConverter _converter = new(config); - public async Task Render( + public async Task RenderAsync( string? text, string? host, List mentions, List emoji, string rootElement ) { diff --git a/Iceshrimp.Backend/Components/PublicPreview/Renderers/NoteRenderer.cs b/Iceshrimp.Backend/Components/PublicPreview/Renderers/NoteRenderer.cs index 8547e5c4..bbc1ba41 100644 --- a/Iceshrimp.Backend/Components/PublicPreview/Renderers/NoteRenderer.cs +++ b/Iceshrimp.Backend/Components/PublicPreview/Renderers/NoteRenderer.cs @@ -22,15 +22,15 @@ public class NoteRenderer( var allNotes = ((Note?[]) [note, note.Reply, note.Renote]).NotNull().ToList(); - var mentions = await GetMentions(allNotes); - var emoji = await GetEmoji(allNotes); - var users = await GetUsers(allNotes); - var attachments = await GetAttachments(allNotes); + var mentions = await GetMentionsAsync(allNotes); + var emoji = await GetEmojiAsync(allNotes); + var users = await GetUsersAsync(allNotes); + var attachments = await GetAttachmentsAsync(allNotes); - return await Render(note, users, mentions, emoji, attachments); + return await RenderAsync(note, users, mentions, emoji, attachments); } - private async Task Render( + private async Task RenderAsync( Note note, List users, Dictionary> mentions, Dictionary> emoji, Dictionary?> attachments ) @@ -38,7 +38,7 @@ public class NoteRenderer( var res = new PreviewNote { User = users.First(p => p.Id == note.User.Id), - Text = await mfm.Render(note.Text, note.User.Host, mentions[note.Id], emoji[note.Id], "span"), + Text = await mfm.RenderAsync(note.Text, note.User.Host, mentions[note.Id], emoji[note.Id], "span"), Cw = note.Cw, RawText = note.Text, QuoteUrl = note.Renote?.Url ?? note.Renote?.Uri ?? note.Renote?.GetPublicUriOrNull(instance.Value), @@ -51,7 +51,7 @@ public class NoteRenderer( return res; } - private async Task>> GetMentions(List notes) + private async Task>> GetMentionsAsync(List notes) { var mentions = notes.SelectMany(n => n.Mentions).Distinct().ToList(); if (mentions.Count == 0) return notes.ToDictionary>(p => p.Id, _ => []); @@ -69,7 +69,7 @@ public class NoteRenderer( p => users.Where(u => p.Mentions.Contains(u.Key)).Select(u => u.Value).ToList()); } - private async Task>> GetEmoji(List notes) + private async Task>> GetEmojiAsync(List notes) { var ids = notes.SelectMany(n => n.Emojis).Distinct().ToList(); if (ids.Count == 0) return notes.ToDictionary>(p => p.Id, _ => []); @@ -78,13 +78,13 @@ public class NoteRenderer( return notes.ToDictionary(p => p.Id, p => emoji.Where(e => p.Emojis.Contains(e.Id)).ToList()); } - private async Task> GetUsers(List notes) + private async Task> GetUsersAsync(List notes) { if (notes is []) return []; - return await userRenderer.RenderMany(notes.Select(p => p.User).Distinct().ToList()); + return await userRenderer.RenderManyAsync(notes.Select(p => p.User).Distinct().ToList()); } - private async Task?>> GetAttachments(List notes) + private async Task?>> GetAttachmentsAsync(List notes) { if (security.Value.PublicPreview is Enums.PublicPreview.RestrictedNoMedia) return notes.ToDictionary?>(p => p.Id, @@ -106,14 +106,14 @@ public class NoteRenderer( .ToList()); } - public async Task> RenderMany(List notes) + public async Task> RenderManyAsync(List notes) { if (notes is []) return []; var allNotes = notes.SelectMany(p => [p, p.Renote, p.Reply]).NotNull().Distinct().ToList(); - var users = await GetUsers(allNotes); - var mentions = await GetMentions(allNotes); - var emoji = await GetEmoji(allNotes); - var attachments = await GetAttachments(allNotes); - return await notes.Select(p => Render(p, users, mentions, emoji, attachments)).AwaitAllAsync().ToListAsync(); + var users = await GetUsersAsync(allNotes); + var mentions = await GetMentionsAsync(allNotes); + var emoji = await GetEmojiAsync(allNotes); + var attachments = await GetAttachmentsAsync(allNotes); + return await notes.Select(p => RenderAsync(p, users, mentions, emoji, attachments)).AwaitAllAsync().ToListAsync(); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Components/PublicPreview/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Components/PublicPreview/Renderers/UserRenderer.cs index 692df4fa..a4c2ba39 100644 --- a/Iceshrimp.Backend/Components/PublicPreview/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Components/PublicPreview/Renderers/UserRenderer.cs @@ -18,11 +18,11 @@ public class UserRenderer( public async Task RenderOne(User? user) { if (user == null) return null; - var emoji = await GetEmoji([user]); - return await Render(user, emoji); + var emoji = await GetEmojiAsync([user]); + return await RenderAsync(user, emoji); } - private async Task Render(User user, Dictionary> emoji) + private async Task RenderAsync(User user, Dictionary> emoji) { var mentions = user.UserProfile?.Mentions ?? []; @@ -36,8 +36,8 @@ public class UserRenderer( AvatarUrl = user.AvatarUrl ?? user.IdenticonUrlPath, BannerUrl = user.BannerUrl, RawDisplayName = user.DisplayName, - DisplayName = await mfm.Render(user.DisplayName, user.Host, mentions, emoji[user.Id], "span"), - Bio = await mfm.Render(user.UserProfile?.Description, user.Host, mentions, emoji[user.Id], "span"), + DisplayName = await mfm.RenderAsync(user.DisplayName, user.Host, mentions, emoji[user.Id], "span"), + Bio = await mfm.RenderAsync(user.UserProfile?.Description, user.Host, mentions, emoji[user.Id], "span"), MovedToUri = user.MovedToUri }; // @formatter:on @@ -51,7 +51,7 @@ public class UserRenderer( return res; } - private async Task>> GetEmoji(List users) + private async Task>> GetEmojiAsync(List users) { var ids = users.SelectMany(n => n.Emojis).Distinct().ToList(); if (ids.Count == 0) return users.ToDictionary>(p => p.Id, _ => []); @@ -60,9 +60,9 @@ public class UserRenderer( return users.ToDictionary(p => p.Id, p => emoji.Where(e => p.Emojis.Contains(e.Id)).ToList()); } - public async Task> RenderMany(List users) + public async Task> RenderManyAsync(List users) { - var emoji = await GetEmoji(users); - return await users.Select(p => Render(p, emoji)).AwaitAllAsync().ToListAsync(); + var emoji = await GetEmojiAsync(users); + return await users.Select(p => RenderAsync(p, emoji)).AwaitAllAsync().ToListAsync(); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs index e71ad29c..0992b2cc 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs @@ -104,7 +104,7 @@ public class AccountController( IsSensitive = false, MimeType = request.Avatar.ContentType }; - var avatar = await driveSvc.StoreFile(request.Avatar.OpenReadStream(), user, rq); + var avatar = await driveSvc.StoreFileAsync(request.Avatar.OpenReadStream(), user, rq); user.Avatar = avatar; user.AvatarBlurhash = avatar.Blurhash; user.AvatarUrl = avatar.AccessUrl; @@ -118,7 +118,7 @@ public class AccountController( IsSensitive = false, MimeType = request.Banner.ContentType }; - var banner = await driveSvc.StoreFile(request.Banner.OpenReadStream(), user, rq); + var banner = await driveSvc.StoreFileAsync(request.Banner.OpenReadStream(), user, rq); user.Banner = banner; user.BannerBlurhash = banner.Blurhash; user.BannerUrl = banner.AccessUrl; @@ -144,7 +144,7 @@ public class AccountController( db.Update(user); await db.SaveChangesAsync(); - await driveSvc.RemoveFile(id); + await driveSvc.RemoveFileAsync(id); } return await VerifyUserCredentials(); @@ -166,7 +166,7 @@ public class AccountController( db.Update(user); await db.SaveChangesAsync(); - await driveSvc.RemoveFile(id); + await driveSvc.RemoveFileAsync(id); } return await VerifyUserCredentials(); @@ -187,7 +187,7 @@ public class AccountController( if (config.Value.PublicPreview <= Enums.PublicPreview.Restricted && user.IsRemoteUser && localUser == null) throw GracefulException.Forbidden("Public preview is disabled on this instance"); - return await userRenderer.RenderAsync(await userResolver.GetUpdatedUser(user), localUser); + return await userRenderer.RenderAsync(await userResolver.GetUpdatedUserAsync(user), localUser); } [HttpPost("{id}/follow")] @@ -631,7 +631,7 @@ public class AccountController( var localUser = HttpContext.GetUser(); var user = await userResolver.ResolveOrNullAsync(acct, flags) ?? throw GracefulException.RecordNotFound(); - user = await userResolver.GetUpdatedUser(user); + user = await userResolver.GetUpdatedUserAsync(user); return await userRenderer.RenderAsync(user, localUser); } diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs index e7a93ef2..29900b75 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs @@ -32,7 +32,7 @@ public class AuthController(DatabaseContext db, MetaService meta) : ControllerBa return new VerifyAppCredentialsResponse { - App = token.App, VapidKey = await meta.Get(MetaEntity.VapidPublicKey) + App = token.App, VapidKey = await meta.GetAsync(MetaEntity.VapidPublicKey) }; } @@ -77,7 +77,7 @@ public class AuthController(DatabaseContext db, MetaService meta) : ControllerBa await db.AddAsync(app); await db.SaveChangesAsync(); - return new RegisterAppResponse { App = app, VapidKey = await meta.Get(MetaEntity.VapidPublicKey) }; + return new RegisterAppResponse { App = app, VapidKey = await meta.GetAsync(MetaEntity.VapidPublicKey) }; } [HttpPost("/oauth/token")] diff --git a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs index 0bd375c2..79aea088 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs @@ -33,10 +33,10 @@ public class InstanceController(DatabaseContext db, MetaService meta) : Controll var instanceCount = await db.Instances.LongCountAsync(); var (instanceName, instanceDescription, adminContact) = - await meta.GetMany(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); + await meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); // can't merge with above call since they're all nullable and this is not. - var vapidKey = await meta.Get(MetaEntity.VapidPublicKey); + var vapidKey = await meta.GetAsync(MetaEntity.VapidPublicKey); return new InstanceInfoV1Response(config.Value, instanceName, instanceDescription, adminContact) { @@ -55,7 +55,7 @@ public class InstanceController(DatabaseContext db, MetaService meta) : Controll p.LastActiveDate > cutoff); var (instanceName, instanceDescription, adminContact) = - await meta.GetMany(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); + await meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); return new InstanceInfoV2Response(config.Value, instanceName, instanceDescription, adminContact) { @@ -88,7 +88,7 @@ public class InstanceController(DatabaseContext db, MetaService meta) : Controll [ProducesResults(HttpStatusCode.OK)] public async Task GetExtendedDescription() { - var description = await meta.Get(MetaEntity.InstanceDescription); + var description = await meta.GetAsync(MetaEntity.InstanceDescription); return new InstanceExtendedDescription(description); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs b/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs index 36823afd..0b5e27c2 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs @@ -39,7 +39,7 @@ public class MediaController(DriveService driveSvc, DatabaseContext db) : Contro Comment = request.Description, MimeType = request.File.ContentType }; - var file = await driveSvc.StoreFile(request.File.OpenReadStream(), user, rq); + var file = await driveSvc.StoreFileAsync(request.File.OpenReadStream(), user, rq); return RenderAttachment(file); } diff --git a/Iceshrimp.Backend/Controllers/Mastodon/PollController.cs b/Iceshrimp.Backend/Controllers/Mastodon/PollController.cs index b6af2112..cae6a5a1 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/PollController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/PollController.cs @@ -115,7 +115,7 @@ public class PollController( await db.SaveChangesAsync(); foreach (var vote in votes) - await pollSvc.RegisterPollVote(vote, poll, note, votes.IndexOf(vote) == 0); + await pollSvc.RegisterPollVoteAsync(vote, poll, note, votes.IndexOf(vote) == 0); await db.ReloadEntityAsync(poll); return await pollRenderer.RenderAsync(poll, user); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/PushController.cs b/Iceshrimp.Backend/Controllers/Mastodon/PushController.cs index 2f2d0059..1003e5b6 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/PushController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/PushController.cs @@ -150,7 +150,7 @@ public class PushController(DatabaseContext db, MetaService meta) : ControllerBa { Id = sub.Id, Endpoint = sub.Endpoint, - ServerKey = await meta.Get(MetaEntity.VapidPublicKey), + ServerKey = await meta.GetAsync(MetaEntity.VapidPublicKey), Policy = GetPolicyString(sub.Policy), Alerts = new Alerts { diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs index fe64f73e..7fec982d 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NoteRenderer.cs @@ -71,18 +71,18 @@ public class NoteRenderer( var renoted = data?.Renotes?.Contains(note.Id) ?? await db.Notes.AnyAsync(p => p.Renote == note && p.User == user && p.IsPureRenote); - var noteEmoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmoji([note]); + var noteEmoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmojiAsync([note]); var mentions = data?.Mentions == null - ? await GetMentions([note]) + ? await GetMentionsAsync([note]) : [..data.Mentions.Where(p => note.Mentions.Contains(p.Id))]; var attachments = data?.Attachments == null - ? await GetAttachments([note]) + ? await GetAttachmentsAsync([note]) : [..data.Attachments.Where(p => note.FileIds.Contains(p.Id))]; var reactions = data?.Reactions == null - ? await GetReactions([note], user) + ? await GetReactionsAsync([note], user) : [..data.Reactions.Where(p => p.NoteId == note.Id)]; var mentionedUsers = mentions.Select(p => new Note.MentionedUser @@ -110,10 +110,10 @@ public class NoteRenderer( await userRenderer.RenderAsync(note.User, user); var poll = note.HasPoll - ? (data?.Polls ?? await GetPolls([note], user)).FirstOrDefault(p => p.Id == note.Id) + ? (data?.Polls ?? await GetPollsAsync([note], user)).FirstOrDefault(p => p.Id == note.Id) : null; - var filters = data?.Filters ?? await GetFilters(user, filterContext); + var filters = data?.Filters ?? await GetFiltersAsync(user, filterContext); List filterResult; if (filters.Count > 0 && filterContext == null) @@ -178,8 +178,8 @@ public class NoteRenderer( var edits = await db.NoteEdits.Where(p => p.Note == note).OrderBy(p => p.Id).ToListAsync(); edits.Add(RenderEdit(note)); - var attachments = await GetAttachments(note.FileIds.Concat(edits.SelectMany(p => p.FileIds))); - var mentions = await GetMentions([note]); + var attachments = await GetAttachmentsAsync(note.FileIds.Concat(edits.SelectMany(p => p.FileIds))); + var mentions = await GetMentionsAsync([note]); var mentionedUsers = mentions.Select(p => new Note.MentionedUser { Host = p.Host ?? config.Value.AccountDomain, @@ -240,7 +240,7 @@ public class NoteRenderer( return res; } - private async Task> GetMentions(List notes) + private async Task> GetMentionsAsync(List notes) { if (notes.Count == 0) return []; var ids = notes.SelectMany(n => n.Mentions).Distinct(); @@ -250,7 +250,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetAttachments(List notes) + private async Task> GetAttachmentsAsync(List notes) { if (notes.Count == 0) return []; var ids = notes.SelectMany(n => n.FileIds).Distinct(); @@ -270,7 +270,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetAttachments(IEnumerable fileIds) + private async Task> GetAttachmentsAsync(IEnumerable fileIds) { var ids = fileIds.Distinct().ToList(); if (ids.Count == 0) return []; @@ -290,13 +290,13 @@ public class NoteRenderer( .ToListAsync(); } - internal async Task> GetAccounts(List users, User? localUser) + internal async Task> GetAccountsAsync(List users, User? localUser) { if (users.Count == 0) return []; return (await userRenderer.RenderManyAsync(users.DistinctBy(p => p.Id), localUser)).ToList(); } - private async Task> GetLikedNotes(List notes, User? user) + private async Task> GetLikedNotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -305,7 +305,7 @@ public class NoteRenderer( .ToListAsync(); } - public async Task> GetReactions(List notes, User? user) + public async Task> GetReactionsAsync(List notes, User? user) { if (notes.Count == 0) return []; var counts = notes.ToDictionary(p => p.Id, p => p.Reactions); @@ -333,7 +333,7 @@ public class NoteRenderer( foreach (var item in res.Where(item => item.Name.StartsWith(':'))) { - var hit = await emojiSvc.ResolveEmoji(item.Name); + var hit = await emojiSvc.ResolveEmojiAsync(item.Name); if (hit == null) continue; item.Url = hit.PublicUrl; item.StaticUrl = hit.PublicUrl; @@ -343,7 +343,7 @@ public class NoteRenderer( return res; } - private async Task> GetBookmarkedNotes(List notes, User? user) + private async Task> GetBookmarkedNotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -352,7 +352,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetMutedNotes(List notes, User? user) + private async Task> GetMutedNotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -362,7 +362,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetPinnedNotes(List notes, User? user) + private async Task> GetPinnedNotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -371,7 +371,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetRenotes(List notes, User? user) + private async Task> GetRenotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -383,7 +383,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetPolls(List notes, User? user) + private async Task> GetPollsAsync(List notes, User? user) { if (notes.Count == 0) return []; var polls = await db.Polls.Where(p => notes.Contains(p.Note)) @@ -392,7 +392,7 @@ public class NoteRenderer( return await pollRenderer.RenderManyAsync(polls, user).ToListAsync(); } - private async Task> GetEmoji(IEnumerable notes) + private async Task> GetEmojiAsync(IEnumerable notes) { var ids = notes.SelectMany(p => p.Emojis).ToList(); if (ids.Count == 0) return []; @@ -411,7 +411,7 @@ public class NoteRenderer( .ToListAsync(); } - private async Task> GetFilters(User? user, Filter.FilterContext? filterContext) + private async Task> GetFiltersAsync(User? user, Filter.FilterContext? filterContext) { return filterContext == null ? await db.Filters.Where(p => p.User == user).ToListAsync() @@ -433,18 +433,18 @@ public class NoteRenderer( var data = new NoteRendererDto { - Accounts = accounts ?? await GetAccounts(allNotes.Select(p => p.User).ToList(), user), - Mentions = await GetMentions(allNotes), - Attachments = await GetAttachments(allNotes), - Polls = await GetPolls(allNotes, user), - LikedNotes = await GetLikedNotes(allNotes, user), - BookmarkedNotes = await GetBookmarkedNotes(allNotes, user), - MutedNotes = await GetMutedNotes(allNotes, user), - PinnedNotes = await GetPinnedNotes(allNotes, user), - Renotes = await GetRenotes(allNotes, user), - Emoji = await GetEmoji(allNotes), - Reactions = await GetReactions(allNotes, user), - Filters = await GetFilters(user, filterContext) + Accounts = accounts ?? await GetAccountsAsync(allNotes.Select(p => p.User).ToList(), user), + Mentions = await GetMentionsAsync(allNotes), + Attachments = await GetAttachmentsAsync(allNotes), + Polls = await GetPollsAsync(allNotes, user), + LikedNotes = await GetLikedNotesAsync(allNotes, user), + BookmarkedNotes = await GetBookmarkedNotesAsync(allNotes, user), + MutedNotes = await GetMutedNotesAsync(allNotes, user), + PinnedNotes = await GetPinnedNotesAsync(allNotes, user), + Renotes = await GetRenotesAsync(allNotes, user), + Emoji = await GetEmojiAsync(allNotes), + Reactions = await GetReactionsAsync(allNotes, user), + Filters = await GetFiltersAsync(user, filterContext) }; return await noteList.Select(p => RenderAsync(p, user, filterContext, data)).AwaitAllAsync(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs index 494b3fdc..49e79c2f 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/NotificationRenderer.cs @@ -68,7 +68,7 @@ public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer, var notificationList = notifications.ToList(); if (notificationList.Count == 0) return []; - var accounts = await noteRenderer.GetAccounts(notificationList.Where(p => p.Notifier != null) + var accounts = await noteRenderer.GetAccountsAsync(notificationList.Where(p => p.Notifier != null) .Select(p => p.Notifier) .Concat(notificationList.Select(p => p.Notifiee)) .Concat(notificationList @@ -107,7 +107,7 @@ public class NotificationRenderer(DatabaseContext db, NoteRenderer noteRenderer, Url = e.PublicUrl }) .ToArrayAsync() - .ContinueWithResult(res => res.DistinctBy(e => e.Name) + .ContinueWithResultAsync(res => res.DistinctBy(e => e.Name) .ToDictionary(e => e.Name, e => e.Url)); return await notificationList diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/PollRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/PollRenderer.cs index 2a2fce89..fe233296 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/PollRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/PollRenderer.cs @@ -10,9 +10,9 @@ public class PollRenderer(DatabaseContext db) : IScopedService { public async Task RenderAsync(Poll poll, User? user, PollRendererDto? data = null) { - var voted = (data?.Voted ?? await GetVoted([poll], user)).Contains(poll.NoteId); + var voted = (data?.Voted ?? await GetVotedAsync([poll], user)).Contains(poll.NoteId); - var ownVotes = (data?.OwnVotes ?? await GetOwnVotes([poll], user)).Where(p => p.Key == poll.NoteId) + var ownVotes = (data?.OwnVotes ?? await GetOwnVotesAsync([poll], user)).Where(p => p.Key == poll.NoteId) .Select(p => p.Value) .DefaultIfEmpty([]) .First(); @@ -38,7 +38,7 @@ public class PollRenderer(DatabaseContext db) : IScopedService return res; } - private async Task> GetVoted(IEnumerable polls, User? user) + private async Task> GetVotedAsync(IEnumerable polls, User? user) { if (user == null) return []; return await db.PollVotes.Where(p => polls.Select(i => i.NoteId).Any(i => i == p.NoteId) && p.User == user) @@ -47,7 +47,7 @@ public class PollRenderer(DatabaseContext db) : IScopedService .ToListAsync(); } - private async Task> GetOwnVotes(IEnumerable polls, User? user) + private async Task> GetOwnVotesAsync(IEnumerable polls, User? user) { if (user == null) return []; return await db.PollVotes @@ -62,7 +62,7 @@ public class PollRenderer(DatabaseContext db) : IScopedService var data = new PollRendererDto { - OwnVotes = await GetOwnVotes(pollList, user), Voted = await GetVoted(pollList, user) + OwnVotes = await GetOwnVotesAsync(pollList, user), Voted = await GetVotedAsync(pollList, user) }; return await pollList.Select(p => RenderAsync(p, user, data)).AwaitAllAsync(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs index ee9129b2..249d6d5c 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Renderers/UserRenderer.cs @@ -26,7 +26,7 @@ public class UserRenderer( if (user.IsRemoteUser) acct += $"@{user.Host}"; - var profileEmoji = emoji?.Where(p => user.Emojis.Contains(p.Id)).ToList() ?? await GetEmoji([user]); + var profileEmoji = emoji?.Where(p => user.Emojis.Contains(p.Id)).ToList() ?? await GetEmojiAsync([user]); var mentions = profile?.Mentions ?? []; var fields = profile != null ? await profile.Fields @@ -97,7 +97,7 @@ public class UserRenderer( return res; } - private async Task> GetEmoji(IEnumerable users) + private async Task> GetEmojiAsync(IEnumerable users) { var ids = users.SelectMany(p => p.Emojis).ToList(); if (ids.Count == 0) return []; @@ -125,7 +125,7 @@ public class UserRenderer( { var userList = users.ToList(); if (userList.Count == 0) return []; - var emoji = await GetEmoji(userList); + var emoji = await GetEmojiAsync(userList); return await userList.Select(p => RenderAsync(p, localUser, emoji)).AwaitAllAsync(); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs index 511f1c4d..0a11d5be 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs @@ -91,7 +91,7 @@ public class SearchController( return result switch { - not null => [await userRenderer.RenderAsync(await userResolver.GetUpdatedUser(result), user)], + not null => [await userRenderer.RenderAsync(await userResolver.GetUpdatedUserAsync(result), user)], _ => [] }; } @@ -120,7 +120,7 @@ public class SearchController( var result = await userResolver.ResolveOrNullAsync(GetQuery(username, host), ResolveFlags.Acct); return result switch { - not null => [await userRenderer.RenderAsync(await userResolver.GetUpdatedUser(result), user)], + not null => [await userRenderer.RenderAsync(await userResolver.GetUpdatedUserAsync(result), user)], _ => [] }; } diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs index cd448f17..42bf3460 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs @@ -18,7 +18,7 @@ public class DirectChannel(WebSocketConnection connection) : IChannel public bool IsSubscribed { get; private set; } public bool IsAggregate => false; - public async Task Subscribe(StreamingRequestMessage _) + public async Task SubscribeAsync(StreamingRequestMessage _) { if (IsSubscribed) return; IsSubscribed = true; @@ -30,7 +30,7 @@ public class DirectChannel(WebSocketConnection connection) : IChannel connection.EventService.NoteUpdated += OnNoteUpdated; } - public Task Unsubscribe(StreamingRequestMessage _) + public Task UnsubscribeAsync(StreamingRequestMessage _) { if (!IsSubscribed) return Task.CompletedTask; IsSubscribed = false; @@ -73,7 +73,7 @@ public class DirectChannel(WebSocketConnection connection) : IChannel return rendered; } - private async Task RenderConversation( + private async Task RenderConversationAsync( Note note, NoteWithVisibilities wrapped, AsyncServiceScope scope ) { @@ -107,13 +107,13 @@ public class DirectChannel(WebSocketConnection connection) : IChannel if (note.CreatedAt < DateTime.UtcNow - TimeSpan.FromMinutes(5)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (await connection.IsMutedThread(note, scope)) return; + if (await connection.IsMutedThreadAsync(note, scope)) return; var message = new StreamingUpdateMessage { Stream = [Name], Event = "conversation", - Payload = JsonSerializer.Serialize(await RenderConversation(note, wrapped, scope)) + Payload = JsonSerializer.Serialize(await RenderConversationAsync(note, wrapped, scope)) }; await connection.SendMessageAsync(JsonSerializer.Serialize(message)); @@ -137,7 +137,7 @@ public class DirectChannel(WebSocketConnection connection) : IChannel { Stream = [Name], Event = "conversation", - Payload = JsonSerializer.Serialize(await RenderConversation(note, wrapped, scope)) + Payload = JsonSerializer.Serialize(await RenderConversationAsync(note, wrapped, scope)) }; await connection.SendMessageAsync(JsonSerializer.Serialize(message)); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/HashtagChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/HashtagChannel.cs index 0e2096c2..4cde53b9 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/HashtagChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/HashtagChannel.cs @@ -20,7 +20,7 @@ public class HashtagChannel(WebSocketConnection connection, bool local) : IChann public bool IsSubscribed => _tags.Count != 0; public bool IsAggregate => true; - public async Task Subscribe(StreamingRequestMessage msg) + public async Task SubscribeAsync(StreamingRequestMessage msg) { if (msg.Tag == null) { @@ -38,7 +38,7 @@ public class HashtagChannel(WebSocketConnection connection, bool local) : IChann _tags.AddIfMissing(msg.Tag); } - public async Task Unsubscribe(StreamingRequestMessage msg) + public async Task UnsubscribeAsync(StreamingRequestMessage msg) { if (msg.Tag == null) { @@ -106,7 +106,7 @@ public class HashtagChannel(WebSocketConnection connection, bool local) : IChann if (wrapped == null) return; if (connection.IsFiltered(note)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (await connection.IsMutedThread(note, scope)) return; + if (await connection.IsMutedThreadAsync(note, scope)) return; var renderer = scope.ServiceProvider.GetRequiredService(); var data = new NoteRenderer.NoteRendererDto { Filters = connection.Filters.ToList() }; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/ListChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/ListChannel.cs index e267fd58..9bee9145 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/ListChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/ListChannel.cs @@ -25,7 +25,7 @@ public class ListChannel(WebSocketConnection connection) : IChannel public bool IsSubscribed => _lists.Count != 0; public bool IsAggregate => true; - public async Task Subscribe(StreamingRequestMessage msg) + public async Task SubscribeAsync(StreamingRequestMessage msg) { if (msg.List == null) { @@ -60,7 +60,7 @@ public class ListChannel(WebSocketConnection connection) : IChannel } } - public async Task Unsubscribe(StreamingRequestMessage msg) + public async Task UnsubscribeAsync(StreamingRequestMessage msg) { if (msg.List == null) { @@ -129,7 +129,7 @@ public class ListChannel(WebSocketConnection connection) : IChannel if (wrapped == null) return; if (connection.IsFiltered(note)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (await connection.IsMutedThread(note, scope)) return; + if (await connection.IsMutedThreadAsync(note, scope)) return; var renderer = scope.ServiceProvider.GetRequiredService(); var data = new NoteRenderer.NoteRendererDto { Filters = connection.Filters.ToList() }; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/PublicChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/PublicChannel.cs index e03f3451..d01345b5 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/PublicChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/PublicChannel.cs @@ -21,7 +21,7 @@ public class PublicChannel( public bool IsSubscribed { get; private set; } public bool IsAggregate => false; - public Task Subscribe(StreamingRequestMessage _) + public Task SubscribeAsync(StreamingRequestMessage _) { if (IsSubscribed) return Task.CompletedTask; IsSubscribed = true; @@ -32,7 +32,7 @@ public class PublicChannel( return Task.CompletedTask; } - public Task Unsubscribe(StreamingRequestMessage _) + public Task UnsubscribeAsync(StreamingRequestMessage _) { if (!IsSubscribed) return Task.CompletedTask; IsSubscribed = false; @@ -89,7 +89,7 @@ public class PublicChannel( if (wrapped == null) return; if (connection.IsFiltered(note)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (await connection.IsMutedThread(note, scope)) return; + if (await connection.IsMutedThreadAsync(note, scope)) return; var renderer = scope.ServiceProvider.GetRequiredService(); var data = new NoteRenderer.NoteRendererDto { Filters = connection.Filters.ToList() }; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs index 1fbae971..742347d1 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/UserChannel.cs @@ -17,7 +17,7 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly) public bool IsSubscribed { get; private set; } public bool IsAggregate => false; - public async Task Subscribe(StreamingRequestMessage _) + public async Task SubscribeAsync(StreamingRequestMessage _) { if (IsSubscribed) return; IsSubscribed = true; @@ -35,7 +35,7 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly) connection.EventService.Notification += OnNotification; } - public Task Unsubscribe(StreamingRequestMessage _) + public Task UnsubscribeAsync(StreamingRequestMessage _) { if (!IsSubscribed) return Task.CompletedTask; IsSubscribed = false; @@ -102,7 +102,7 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly) if (connection.IsFiltered(note)) return; if (note.CreatedAt < DateTime.UtcNow - TimeSpan.FromMinutes(5)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (await connection.IsMutedThread(note, scope)) return; + if (await connection.IsMutedThreadAsync(note, scope)) return; var renderer = scope.ServiceProvider.GetRequiredService(); var intermediate = await renderer.RenderAsync(note, connection.Token.User); @@ -175,7 +175,7 @@ public class UserChannel(WebSocketConnection connection, bool notificationsOnly) if (IsFiltered(notification)) return; await using var scope = connection.ScopeFactory.CreateAsyncScope(); - if (notification.Note != null && await connection.IsMutedThread(notification.Note, scope, true)) + if (notification.Note != null && await connection.IsMutedThreadAsync(notification.Note, scope, true)) return; var renderer = scope.ServiceProvider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs index 9378e7e0..b49cb78a 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/WebSocketConnection.cs @@ -83,10 +83,10 @@ public sealed class WebSocketConnection( EventService.FilterUpdated += OnFilterUpdated; EventService.ListMembersUpdated += OnListMembersUpdated; - _ = InitializeRelationships(); + _ = InitializeRelationshipsAsync(); } - private async Task InitializeRelationships() + private async Task InitializeRelationshipsAsync() { await using var db = Scope.ServiceProvider.GetRequiredService(); Following.AddRange(await db.Followings.Where(p => p.Follower == Token.User) @@ -120,7 +120,7 @@ public sealed class WebSocketConnection( .Select(p => p.UserId) .Distinct() .ToArrayAsync() - .ContinueWithResult(p => p.ToHashSet()); + .ContinueWithResultAsync(p => p.ToHashSet()); } public async Task HandleSocketMessageAsync(string payload) @@ -163,14 +163,14 @@ public sealed class WebSocketConnection( if (channel.Scopes.Except(MastodonOauthHelpers.ExpandScopes(Token.Scopes)).Any()) await CloseAsync(WebSocketCloseStatus.PolicyViolation); else - await channel.Subscribe(message); + await channel.SubscribeAsync(message); break; } case "unsubscribe": { var channel = _channels.FirstOrDefault(p => p.Name == message.Stream && (p.IsSubscribed || p.IsAggregate)); - if (channel != null) await channel.Unsubscribe(message); + if (channel != null) await channel.UnsubscribeAsync(message); break; } default: @@ -350,7 +350,7 @@ public sealed class WebSocketConnection( .Where(p => p.UserList.UserId == Token.User.Id && p.UserList.HideFromHomeTl) .Select(p => p.UserId) .ToArrayAsync() - .ContinueWithResult(p => p.ToHashSet()); + .ContinueWithResultAsync(p => p.ToHashSet()); } catch (Exception e) { @@ -375,7 +375,7 @@ public sealed class WebSocketConnection( (IsFiltered(note.Renote.Renote.User) || IsFilteredMentions(note.Renote.Renote.Mentions))); - public async Task IsMutedThread(Note note, AsyncServiceScope scope, bool isNotification = false) + public async Task IsMutedThreadAsync(Note note, AsyncServiceScope scope, bool isNotification = false) { if (!isNotification && note.Reply == null) return false; if (!isNotification && note.User.Id == Token.UserId) return false; @@ -396,7 +396,7 @@ public interface IChannel public List Scopes { get; } public bool IsSubscribed { get; } public bool IsAggregate { get; } - public Task Subscribe(StreamingRequestMessage message); - public Task Unsubscribe(StreamingRequestMessage message); + public Task SubscribeAsync(StreamingRequestMessage message); + public Task UnsubscribeAsync(StreamingRequestMessage message); public void Dispose(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs index 8291ac32..72eaa297 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs @@ -32,7 +32,7 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, C public async Task> GetHomeTimeline(MastodonPaginationQuery query) { var user = HttpContext.GetUserOrFail(); - var heuristic = await QueryableTimelineExtensions.GetHeuristic(user, db, cache); + var heuristic = await QueryableTimelineExtensions.GetHeuristicAsync(user, db, cache); return await db.Notes .IncludeCommonProperties() .FilterByFollowingAndOwn(user, db, heuristic) diff --git a/Iceshrimp.Backend/Controllers/Pleroma/StatusController.cs b/Iceshrimp.Backend/Controllers/Pleroma/StatusController.cs index d9a8faa0..4c9b70e5 100644 --- a/Iceshrimp.Backend/Controllers/Pleroma/StatusController.cs +++ b/Iceshrimp.Backend/Controllers/Pleroma/StatusController.cs @@ -66,7 +66,7 @@ public class StatusController( if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null) throw GracefulException.Forbidden("Public preview is disabled on this instance"); - var res = await noteRenderer.GetReactions([note], user); + var res = await noteRenderer.GetReactionsAsync([note], user); foreach (var item in res) { @@ -98,7 +98,7 @@ public class StatusController( if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null) throw GracefulException.Forbidden("Public preview is disabled on this instance"); - var res = (await noteRenderer.GetReactions([note], user)).Where(r => r.Name.Split("@").First() == + var res = (await noteRenderer.GetReactionsAsync([note], user)).Where(r => r.Name.Split("@").First() == Regex.Unescape(reaction)) .ToArray(); diff --git a/Iceshrimp.Backend/Controllers/Web/AdminController.cs b/Iceshrimp.Backend/Controllers/Web/AdminController.cs index cd54af28..cb33590e 100644 --- a/Iceshrimp.Backend/Controllers/Web/AdminController.cs +++ b/Iceshrimp.Backend/Controllers/Web/AdminController.cs @@ -227,7 +227,7 @@ public class AdminController( { var jobs = db.Jobs .Where(p => p.Queue == queue && p.Status == Job.JobStatus.Failed) - .AsChunkedAsyncEnumerable(10, p => p.Id); + .AsChunkedAsyncEnumerableAsync(10, p => p.Id); await foreach (var job in jobs) await queueSvc.RetryJobAsync(job); @@ -240,7 +240,7 @@ public class AdminController( var jobs = db.Jobs .Where(p => p.Queue == queue && p.Status == Job.JobStatus.Failed) .Where(p => p.Id >= from && p.Id <= to) - .AsChunkedAsyncEnumerable(10, p => p.Id); + .AsChunkedAsyncEnumerableAsync(10, p => p.Id); await foreach (var job in jobs) await queueSvc.RetryJobAsync(job); @@ -263,7 +263,7 @@ public class AdminController( { return await db.Relays .ToArrayAsync() - .ContinueWithResult(res => res.Select(p => new RelaySchemas.RelayResponse + .ContinueWithResultAsync(res => res.Select(p => new RelaySchemas.RelayResponse { Id = p.Id, Inbox = p.Inbox, @@ -276,7 +276,7 @@ public class AdminController( [ProducesResults(HttpStatusCode.OK)] public async Task SubscribeToRelay(RelaySchemas.RelayRequest rq) { - await relaySvc.SubscribeToRelay(rq.Inbox); + await relaySvc.SubscribeToRelayAsync(rq.Inbox); } [HttpDelete("relays/{id}")] @@ -286,7 +286,7 @@ public class AdminController( { var relay = await db.Relays.FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound("Relay not found"); - await relaySvc.UnsubscribeFromRelay(relay); + await relaySvc.UnsubscribeFromRelayAsync(relay); } [HttpPost("drive/prune-expired-media")] @@ -294,12 +294,12 @@ public class AdminController( public async Task PruneExpiredMedia([FromServices] IServiceScopeFactory factory) { await using var scope = factory.CreateAsyncScope(); - await new MediaCleanupTask().Invoke(scope.ServiceProvider); + await new MediaCleanupTask().InvokeAsync(scope.ServiceProvider); } [HttpGet("policy")] [ProducesResults(HttpStatusCode.OK)] - public async Task> GetAvailablePolicies() => await policySvc.GetAvailablePolicies(); + public async Task> GetAvailablePolicies() => await policySvc.GetAvailablePoliciesAsync(); [HttpGet("policy/{name}")] [ProducesResults(HttpStatusCode.OK)] @@ -307,7 +307,7 @@ public class AdminController( public async Task GetPolicyConfiguration(string name) { var raw = await db.PolicyConfiguration.Where(p => p.Name == name).Select(p => p.Data).FirstOrDefaultAsync(); - return await policySvc.GetConfiguration(name, raw) ?? throw GracefulException.NotFound("Policy not found"); + return await policySvc.GetConfigurationAsync(name, raw) ?? throw GracefulException.NotFound("Policy not found"); } [HttpPut("policy/{name}")] @@ -317,7 +317,7 @@ public class AdminController( string name, [SwaggerBodyExample("{\n \"enabled\": true\n}")] JsonDocument body ) { - var type = await policySvc.GetConfigurationType(name) ?? throw GracefulException.NotFound("Policy not found"); + var type = await policySvc.GetConfigurationTypeAsync(name) ?? throw GracefulException.NotFound("Policy not found"); var data = body.Deserialize(type, JsonSerialization.Options) as IPolicyConfiguration; if (data?.GetType() != type) throw GracefulException.BadRequest("Invalid policy config"); var serialized = JsonSerializer.Serialize(data, type, JsonSerialization.Options); @@ -327,7 +327,7 @@ public class AdminController( .On(p => new { p.Name }) .RunAsync(); - await policySvc.Update(); + await policySvc.UpdateAsync(); } [UseNewtonsoftJson] diff --git a/Iceshrimp.Backend/Controllers/Web/DriveController.cs b/Iceshrimp.Backend/Controllers/Web/DriveController.cs index d23f9f6d..a3da5db8 100644 --- a/Iceshrimp.Backend/Controllers/Web/DriveController.cs +++ b/Iceshrimp.Backend/Controllers/Web/DriveController.cs @@ -97,7 +97,7 @@ public class DriveController( MimeType = file.ContentType, IsSensitive = false }; - var res = await driveSvc.StoreFile(file.OpenReadStream(), user, request); + var res = await driveSvc.StoreFileAsync(file.OpenReadStream(), user, request); return await GetFileById(res.Id); } diff --git a/Iceshrimp.Backend/Controllers/Web/EmojiController.cs b/Iceshrimp.Backend/Controllers/Web/EmojiController.cs index 1a331463..f002d9df 100644 --- a/Iceshrimp.Backend/Controllers/Web/EmojiController.cs +++ b/Iceshrimp.Backend/Controllers/Web/EmojiController.cs @@ -70,7 +70,7 @@ public class EmojiController( [ProducesErrors(HttpStatusCode.Conflict)] public async Task UploadEmoji(IFormFile file) { - var emoji = await emojiSvc.CreateEmojiFromStream(file.OpenReadStream(), file.FileName, file.ContentType); + var emoji = await emojiSvc.CreateEmojiFromStreamAsync(file.OpenReadStream(), file.FileName, file.ContentType); return new EmojiResponse { @@ -97,7 +97,7 @@ public class EmojiController( var emojo = await db.Emojis.FirstOrDefaultAsync(e => e.Name == name && e.Host == host); if (emojo == null) throw GracefulException.NotFound("Emoji not found"); - var cloned = await emojiSvc.CloneEmoji(emojo); + var cloned = await emojiSvc.CloneEmojiAsync(emojo); return new EmojiResponse { Id = cloned.Id, @@ -116,8 +116,8 @@ public class EmojiController( [ProducesResults(HttpStatusCode.Accepted)] public async Task ImportEmoji(IFormFile file) { - var zip = await emojiImportSvc.Parse(file.OpenReadStream()); - await emojiImportSvc.Import(zip); // TODO: run in background. this will take a while + var zip = await emojiImportSvc.ParseAsync(file.OpenReadStream()); + await emojiImportSvc.ImportAsync(zip); // TODO: run in background. this will take a while return Accepted(); } @@ -128,7 +128,7 @@ public class EmojiController( [ProducesErrors(HttpStatusCode.NotFound)] public async Task UpdateEmoji(string id, UpdateEmojiRequest request) { - var emoji = await emojiSvc.UpdateLocalEmoji(id, request.Name, request.Aliases, request.Category, + var emoji = await emojiSvc.UpdateLocalEmojiAsync(id, request.Name, request.Aliases, request.Category, request.License, request.Sensitive) ?? throw GracefulException.NotFound("Emoji not found"); @@ -151,6 +151,6 @@ public class EmojiController( [ProducesErrors(HttpStatusCode.NotFound)] public async Task DeleteEmoji(string id) { - await emojiSvc.DeleteEmoji(id); + await emojiSvc.DeleteEmojiAsync(id); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Web/FollowRequestController.cs b/Iceshrimp.Backend/Controllers/Web/FollowRequestController.cs index 8d8bf441..55ded400 100644 --- a/Iceshrimp.Backend/Controllers/Web/FollowRequestController.cs +++ b/Iceshrimp.Backend/Controllers/Web/FollowRequestController.cs @@ -39,7 +39,7 @@ public class FollowRequestController( .Select(p => new { p.Id, p.Follower }) .ToListAsync(); - var users = await userRenderer.RenderMany(requests.Select(p => p.Follower)); + var users = await userRenderer.RenderManyAsync(requests.Select(p => p.Follower)); return requests.Select(p => new FollowRequestResponse { Id = p.Id, User = users.First(u => u.Id == p.Follower.Id) diff --git a/Iceshrimp.Backend/Controllers/Web/InstanceController.cs b/Iceshrimp.Backend/Controllers/Web/InstanceController.cs index 22b93b77..95a4d459 100644 --- a/Iceshrimp.Backend/Controllers/Web/InstanceController.cs +++ b/Iceshrimp.Backend/Controllers/Web/InstanceController.cs @@ -26,13 +26,13 @@ public class InstanceController(DatabaseContext db, UserRenderer userRenderer) : var admins = db.Users .Where(p => p.IsAdmin == true) .OrderBy(p => p.UsernameLower); - var adminList = await userRenderer.RenderMany(admins) + var adminList = await userRenderer.RenderManyAsync(admins) .ToListAsync(); var moderators = db.Users .Where(p => p.IsAdmin == false && p.IsModerator == true) .OrderBy(p => p.UsernameLower); - var moderatorList = await userRenderer.RenderMany(moderators) + var moderatorList = await userRenderer.RenderManyAsync(moderators) .ToListAsync(); return new StaffResponse { Admins = adminList, Moderators = moderatorList }; diff --git a/Iceshrimp.Backend/Controllers/Web/MigrationController.cs b/Iceshrimp.Backend/Controllers/Web/MigrationController.cs index 9f5401eb..ec8928f0 100644 --- a/Iceshrimp.Backend/Controllers/Web/MigrationController.cs +++ b/Iceshrimp.Backend/Controllers/Web/MigrationController.cs @@ -71,7 +71,7 @@ public class MigrationController( aliasUri ??= await db.Users.IncludeCommonProperties() .Where(p => p.Id == rq.UserId) .FirstOrDefaultAsync() - .ContinueWithResult(p => p is null ? null : p.Uri ?? p.GetPublicUri(config.Value)); + .ContinueWithResultAsync(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/MiscController.cs b/Iceshrimp.Backend/Controllers/Web/MiscController.cs index add16198..634c9cef 100644 --- a/Iceshrimp.Backend/Controllers/Web/MiscController.cs +++ b/Iceshrimp.Backend/Controllers/Web/MiscController.cs @@ -61,6 +61,6 @@ public class MiscController(DatabaseContext db, NoteRenderer noteRenderer, BiteS .PrecomputeVisibilities(user) .ToListAsync(); - return await noteRenderer.RenderMany(notes.EnforceRenoteReplyVisibility(), user); + return await noteRenderer.RenderManyAsync(notes.EnforceRenoteReplyVisibility(), user); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Web/NoteController.cs b/Iceshrimp.Backend/Controllers/Web/NoteController.cs index f6e6620e..2399f4a5 100644 --- a/Iceshrimp.Backend/Controllers/Web/NoteController.cs +++ b/Iceshrimp.Backend/Controllers/Web/NoteController.cs @@ -96,7 +96,7 @@ public class NoteController( .ToListAsync(); var notes = hits.EnforceRenoteReplyVisibility(); - var res = await noteRenderer.RenderMany(notes, user, Filter.FilterContext.Threads).ToListAsync(); + var res = await noteRenderer.RenderManyAsync(notes, user, Filter.FilterContext.Threads).ToListAsync(); // Strip redundant reply data foreach (var item in res.Where(p => p.Reply != null && res.Any(i => i.Id == p.Reply.Id))) @@ -131,7 +131,7 @@ public class NoteController( .ToListAsync(); var notes = hits.EnforceRenoteReplyVisibility(); - var res = await noteRenderer.RenderMany(notes, user, Filter.FilterContext.Threads).ToListAsync(); + var res = await noteRenderer.RenderManyAsync(notes, user, Filter.FilterContext.Threads).ToListAsync(); // Strip redundant reply data foreach (var item in res.Where(p => p.Reply != null && res.Any(i => i.Id == p.Reply.Id))) @@ -163,7 +163,7 @@ public class NoteController( .Select(p => p.User) .ToListAsync(); - return await userRenderer.RenderMany(users); + return await userRenderer.RenderManyAsync(users); } [HttpPost("{id}/bite")] @@ -249,7 +249,7 @@ public class NoteController( .Wrap(p => p.User) .ToListAsync(); - var res = await userRenderer.RenderMany(users.Select(p => p.Entity)); + var res = await userRenderer.RenderManyAsync(users.Select(p => p.Entity)); return HttpContext.CreatePaginationWrapper(pq, users, res); } @@ -315,7 +315,7 @@ public class NoteController( .Wrap(p => p.User) .ToListAsync(); - var res = await userRenderer.RenderMany(users.Select(p => p.Entity)); + var res = await userRenderer.RenderManyAsync(users.Select(p => p.Entity)); return HttpContext.CreatePaginationWrapper(pq, users, res); } @@ -343,7 +343,7 @@ public class NoteController( .Paginate(pq, ControllerContext) .ToListAsync(); - var res = await noteRenderer.RenderMany(renotes.EnforceRenoteReplyVisibility(), user, + var res = await noteRenderer.RenderManyAsync(renotes.EnforceRenoteReplyVisibility(), user, Filter.FilterContext.Threads); return HttpContext.CreatePaginationWrapper(pq, renotes, res); } diff --git a/Iceshrimp.Backend/Controllers/Web/NotificationController.cs b/Iceshrimp.Backend/Controllers/Web/NotificationController.cs index cfaf971e..24361f9a 100644 --- a/Iceshrimp.Backend/Controllers/Web/NotificationController.cs +++ b/Iceshrimp.Backend/Controllers/Web/NotificationController.cs @@ -36,7 +36,7 @@ public class NotificationController(DatabaseContext db, NotificationRenderer not .PrecomputeNoteVisibilities(user) .ToListAsync(); - return await notificationRenderer.RenderMany(notifications.EnforceRenoteReplyVisibility(p => p.Note), user); + return await notificationRenderer.RenderManyAsync(notifications.EnforceRenoteReplyVisibility(p => p.Note), user); } [HttpPost("{id}/read")] diff --git a/Iceshrimp.Backend/Controllers/Web/Renderers/NoteRenderer.cs b/Iceshrimp.Backend/Controllers/Web/Renderers/NoteRenderer.cs index a4007d5c..fbd31fe6 100644 --- a/Iceshrimp.Backend/Controllers/Web/Renderers/NoteRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Web/Renderers/NoteRenderer.cs @@ -21,15 +21,15 @@ public class NoteRenderer( Note note, User? user, Filter.FilterContext? filterContext = null, NoteRendererDto? data = null ) { - var res = await RenderBaseInternal(note, user, data); + var res = await RenderBaseInternalAsync(note, user, data); var renote = note is { Renote: not null, IsPureRenote: true } - ? await RenderRenote(note.Renote, user, data) + ? await RenderRenoteAsync(note.Renote, user, data) : null; - var quote = note is { Renote: not null, IsQuote: true } ? await RenderBase(note.Renote, user, data) : null; - var reply = note.Reply != null ? await RenderBase(note.Reply, user, data) : null; + var quote = note is { Renote: not null, IsQuote: true } ? await RenderBaseAsync(note.Renote, user, data) : null; + var reply = note.Reply != null ? await RenderBaseAsync(note.Reply, user, data) : null; - var filters = data?.Filters ?? await GetFilters(user, filterContext); + var filters = data?.Filters ?? await GetFiltersAsync(user, filterContext); var filtered = FilterHelper.IsFiltered([note, note.Reply, note.Renote, note.Renote?.Renote], filters); if (filtered.HasValue) @@ -54,10 +54,10 @@ public class NoteRenderer( return res; } - private async Task RenderRenote(Note note, User? user, NoteRendererDto? data = null) + private async Task RenderRenoteAsync(Note note, User? user, NoteRendererDto? data = null) { - var res = await RenderBaseInternal(note, user, data); - var quote = note.Renote is { IsPureRenote: false } ? await RenderBase(note.Renote, user, data) : null; + var res = await RenderBaseInternalAsync(note, user, data); + var quote = note.Renote is { IsPureRenote: false } ? await RenderBaseAsync(note.Renote, user, data) : null; res.Quote = quote; res.QuoteId = note.RenoteId; @@ -66,17 +66,17 @@ public class NoteRenderer( return res; } - private async Task RenderBase(Note note, User? localUser, NoteRendererDto? data = null) - => await RenderBaseInternal(note, localUser, data); + private async Task RenderBaseAsync(Note note, User? localUser, NoteRendererDto? data = null) + => await RenderBaseInternalAsync(note, localUser, data); - private async Task RenderBaseInternal(Note note, User? user, NoteRendererDto? data = null) + private async Task RenderBaseInternalAsync(Note note, User? user, NoteRendererDto? data = null) { - var noteUser = (data?.Users ?? await GetUsers([note])).First(p => p.Id == note.User.Id); - var attachments = (data?.Attachments ?? await GetAttachments([note])).Where(p => note.FileIds.Contains(p.Id)); - var reactions = (data?.Reactions ?? await GetReactions([note], user)).Where(p => p.NoteId == note.Id); + var noteUser = (data?.Users ?? await GetUsersAsync([note])).First(p => p.Id == note.User.Id); + var attachments = (data?.Attachments ?? await GetAttachmentsAsync([note])).Where(p => note.FileIds.Contains(p.Id)); + var reactions = (data?.Reactions ?? await GetReactionsAsync([note], user)).Where(p => p.NoteId == note.Id); var liked = data?.LikedNotes?.Contains(note.Id) ?? await db.NoteLikes.AnyAsync(p => p.Note == note && p.User == user); - var emoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmoji([note]); + var emoji = data?.Emoji?.Where(p => note.Emojis.Contains(p.Id)).ToList() ?? await GetEmojiAsync([note]); return new NoteResponse { @@ -98,14 +98,14 @@ public class NoteRenderer( }; } - private async Task> GetUsers(List notesList) + private async Task> GetUsersAsync(List notesList) { if (notesList.Count == 0) return []; var users = notesList.Select(p => p.User).DistinctBy(p => p.Id); - return await userRenderer.RenderMany(users).ToListAsync(); + return await userRenderer.RenderManyAsync(users).ToListAsync(); } - private async Task> GetAttachments(List notesList) + private async Task> GetAttachmentsAsync(List notesList) { if (notesList.Count == 0) return []; var ids = notesList.SelectMany(p => p.FileIds).Distinct(); @@ -123,7 +123,7 @@ public class NoteRenderer( .ToList(); } - private async Task> GetReactions(List notes, User? user) + private async Task> GetReactionsAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -146,7 +146,7 @@ public class NoteRenderer( foreach (var item in res.Where(item => item.Name.StartsWith(':'))) { - var hit = await emojiSvc.ResolveEmoji(item.Name); + var hit = await emojiSvc.ResolveEmojiAsync(item.Name); if (hit == null) continue; item.Url = hit.PublicUrl; item.Sensitive = hit.Sensitive; @@ -155,7 +155,7 @@ public class NoteRenderer( return res; } - private async Task> GetLikedNotes(List notes, User? user) + private async Task> GetLikedNotesAsync(List notes, User? user) { if (user == null) return []; if (notes.Count == 0) return []; @@ -172,13 +172,13 @@ public class NoteRenderer( .ToList(); } - private async Task> GetFilters(User? user, Filter.FilterContext? filterContext) + private async Task> GetFiltersAsync(User? user, Filter.FilterContext? filterContext) { if (filterContext == null) return []; return await db.Filters.Where(p => p.User == user && p.Contexts.Contains(filterContext.Value)).ToListAsync(); } - private async Task> GetEmoji(IEnumerable notes) + private async Task> GetEmojiAsync(IEnumerable notes) { var ids = notes.SelectMany(p => p.Emojis).ToList(); if (ids.Count == 0) return []; @@ -199,7 +199,7 @@ public class NoteRenderer( .ToListAsync(); } - public async Task> RenderMany( + public async Task> RenderManyAsync( IEnumerable notes, User? user, Filter.FilterContext? filterContext = null ) { @@ -208,12 +208,12 @@ public class NoteRenderer( var allNotes = GetAllNotes(notesList); var data = new NoteRendererDto { - Users = await GetUsers(allNotes), - Attachments = await GetAttachments(allNotes), - Reactions = await GetReactions(allNotes, user), - Filters = await GetFilters(user, filterContext), - LikedNotes = await GetLikedNotes(allNotes, user), - Emoji = await GetEmoji(allNotes) + Users = await GetUsersAsync(allNotes), + Attachments = await GetAttachmentsAsync(allNotes), + Reactions = await GetReactionsAsync(allNotes, user), + Filters = await GetFiltersAsync(user, filterContext), + LikedNotes = await GetLikedNotesAsync(allNotes, user), + Emoji = await GetEmojiAsync(allNotes) }; return await notesList.Select(p => RenderOne(p, user, filterContext, data)).AwaitAllAsync(); diff --git a/Iceshrimp.Backend/Controllers/Web/Renderers/NotificationRenderer.cs b/Iceshrimp.Backend/Controllers/Web/Renderers/NotificationRenderer.cs index c24dde26..e0465fae 100644 --- a/Iceshrimp.Backend/Controllers/Web/Renderers/NotificationRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Web/Renderers/NotificationRenderer.cs @@ -42,8 +42,8 @@ public class NotificationRenderer(UserRenderer userRenderer, NoteRenderer noteRe { var data = new NotificationRendererDto { - Users = await GetUsers([notification]), - Notes = await GetNotes([notification], localUser), + Users = await GetUsersAsync([notification]), + Notes = await GetNotesAsync([notification], localUser), Bites = GetBites([notification]) }; @@ -71,16 +71,16 @@ public class NotificationRenderer(UserRenderer userRenderer, NoteRenderer noteRe _ => throw new ArgumentOutOfRangeException(nameof(type), type, null) }; - private async Task> GetUsers(IEnumerable notifications) + private async Task> GetUsersAsync(IEnumerable notifications) { var users = notifications.Select(p => p.Notifier).OfType().DistinctBy(p => p.Id); - return await userRenderer.RenderMany(users).ToListAsync(); + return await userRenderer.RenderManyAsync(users).ToListAsync(); } - private async Task> GetNotes(IEnumerable notifications, User user) + private async Task> GetNotesAsync(IEnumerable notifications, User user) { var notes = notifications.Select(p => p.Note).OfType().DistinctBy(p => p.Id); - return await noteRenderer.RenderMany(notes, user, Filter.FilterContext.Notifications).ToListAsync(); + return await noteRenderer.RenderManyAsync(notes, user, Filter.FilterContext.Notifications).ToListAsync(); } private static List GetBites(IEnumerable notifications) @@ -89,13 +89,13 @@ public class NotificationRenderer(UserRenderer userRenderer, NoteRenderer noteRe return bites.Select(p => new BiteResponse { Id = p.Id, BiteBack = p.TargetBiteId != null }).ToList(); } - public async Task> RenderMany(IEnumerable notifications, User user) + public async Task> RenderManyAsync(IEnumerable notifications, User user) { var notificationsList = notifications.ToList(); var data = new NotificationRendererDto { - Users = await GetUsers(notificationsList), - Notes = await GetNotes(notificationsList, user), + Users = await GetUsersAsync(notificationsList), + Notes = await GetNotesAsync(notificationsList, user), Bites = GetBites(notificationsList) }; diff --git a/Iceshrimp.Backend/Controllers/Web/Renderers/UserProfileRenderer.cs b/Iceshrimp.Backend/Controllers/Web/Renderers/UserProfileRenderer.cs index 1f9b3b21..08802e1c 100644 --- a/Iceshrimp.Backend/Controllers/Web/Renderers/UserProfileRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Web/Renderers/UserProfileRenderer.cs @@ -10,7 +10,7 @@ public class UserProfileRenderer(DatabaseContext db) : IScopedService { public async Task RenderOne(User user, User? localUser, UserRendererDto? data = null) { - (data?.Relations ?? await GetRelations([user], localUser)).TryGetValue(user.Id, out var relations); + (data?.Relations ?? await GetRelationsAsync([user], localUser)).TryGetValue(user.Id, out var relations); relations ??= new RelationData { UserId = user.Id, @@ -68,7 +68,7 @@ public class UserProfileRenderer(DatabaseContext db) : IScopedService }; } - private async Task> GetRelations(IEnumerable users, User? localUser) + private async Task> GetRelationsAsync(IEnumerable users, User? localUser) { var ids = users.Select(p => p.Id).ToList(); if (ids.Count == 0) return []; @@ -90,10 +90,10 @@ public class UserProfileRenderer(DatabaseContext db) : IScopedService .ToDictionaryAsync(p => p.UserId, p => p); } - public async Task> RenderMany(IEnumerable users, User? localUser) + public async Task> RenderManyAsync(IEnumerable users, User? localUser) { var userList = users.ToList(); - var data = new UserRendererDto { Relations = await GetRelations(userList, localUser) }; + var data = new UserRendererDto { Relations = await GetRelationsAsync(userList, localUser) }; return await userList.Select(p => RenderOne(p, localUser, data)).AwaitAllAsync(); } diff --git a/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs b/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs index b74a99f2..7dd18840 100644 --- a/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs +++ b/Iceshrimp.Backend/Controllers/Web/Renderers/UserRenderer.cs @@ -40,31 +40,31 @@ public class UserRenderer(IOptions config, DatabaseConte public async Task RenderOne(User user) { - var instanceData = await GetInstanceData([user]); - var emojis = await GetEmojis([user]); + var instanceData = await GetInstanceDataAsync([user]); + var emojis = await GetEmojisAsync([user]); var data = new UserRendererDto { Emojis = emojis, InstanceData = instanceData }; return Render(user, data); } - private async Task> GetInstanceData(IEnumerable users) + private async Task> GetInstanceDataAsync(IEnumerable users) { var hosts = users.Select(p => p.Host).Where(p => p != null).Distinct().Cast(); return await db.Instances.Where(p => hosts.Contains(p.Host)).ToListAsync(); } - public async Task> RenderMany(IEnumerable users) + public async Task> RenderManyAsync(IEnumerable users) { var userList = users.ToList(); var data = new UserRendererDto { - InstanceData = await GetInstanceData(userList), Emojis = await GetEmojis(userList) + InstanceData = await GetInstanceDataAsync(userList), Emojis = await GetEmojisAsync(userList) }; return userList.Select(p => Render(p, data)); } - private async Task>> GetEmojis(ICollection users) + private async Task>> GetEmojisAsync(ICollection users) { var ids = users.SelectMany(p => p.Emojis).ToList(); if (ids.Count == 0) return users.ToDictionary>(p => p.Id, _ => []); diff --git a/Iceshrimp.Backend/Controllers/Web/SearchController.cs b/Iceshrimp.Backend/Controllers/Web/SearchController.cs index f63b43c6..031fcacc 100644 --- a/Iceshrimp.Backend/Controllers/Web/SearchController.cs +++ b/Iceshrimp.Backend/Controllers/Web/SearchController.cs @@ -51,7 +51,7 @@ public class SearchController( .PrecomputeVisibilities(user) .ToListAsync(); - return await noteRenderer.RenderMany(notes.EnforceRenoteReplyVisibility(), user); + return await noteRenderer.RenderManyAsync(notes.EnforceRenoteReplyVisibility(), user); } [HttpGet("users")] @@ -71,7 +71,7 @@ public class SearchController( .OrderByDescending(p => p.NotesCount) .ToListAsync(); - return await userRenderer.RenderMany(users); + return await userRenderer.RenderManyAsync(users); } [HttpGet("lookup")] diff --git a/Iceshrimp.Backend/Controllers/Web/TimelineController.cs b/Iceshrimp.Backend/Controllers/Web/TimelineController.cs index 81782b35..7d0e25ab 100644 --- a/Iceshrimp.Backend/Controllers/Web/TimelineController.cs +++ b/Iceshrimp.Backend/Controllers/Web/TimelineController.cs @@ -29,7 +29,7 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, C public async Task> GetHomeTimeline(PaginationQuery pq) { var user = HttpContext.GetUserOrFail(); - var heuristic = await QueryableTimelineExtensions.GetHeuristic(user, db, cache); + var heuristic = await QueryableTimelineExtensions.GetHeuristicAsync(user, db, cache); var notes = await db.Notes.IncludeCommonProperties() .FilterByFollowingAndOwn(user, db, heuristic) .EnsureVisibleFor(user) @@ -39,6 +39,6 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, C .PrecomputeVisibilities(user) .ToListAsync(); - return await noteRenderer.RenderMany(notes.EnforceRenoteReplyVisibility(), user, Filter.FilterContext.Home); + return await noteRenderer.RenderManyAsync(notes.EnforceRenoteReplyVisibility(), user, Filter.FilterContext.Home); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/Web/UserController.cs b/Iceshrimp.Backend/Controllers/Web/UserController.cs index f38361ab..17c79592 100644 --- a/Iceshrimp.Backend/Controllers/Web/UserController.cs +++ b/Iceshrimp.Backend/Controllers/Web/UserController.cs @@ -43,7 +43,7 @@ public class UserController( .FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound("User not found"); - return await userRenderer.RenderOne(await userResolver.GetUpdatedUser(user)); + return await userRenderer.RenderOne(await userResolver.GetUpdatedUserAsync(user)); } [HttpGet("lookup")] @@ -61,7 +61,7 @@ public class UserController( .FirstOrDefaultAsync(p => p.UsernameLower == username && p.Host == host) ?? throw GracefulException.NotFound("User not found"); - return await userRenderer.RenderOne(await userResolver.GetUpdatedUser(user)); + return await userRenderer.RenderOne(await userResolver.GetUpdatedUserAsync(user)); } [HttpGet("{id}/profile")] @@ -74,7 +74,7 @@ public class UserController( .FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound("User not found"); - return await userProfileRenderer.RenderOne(await userResolver.GetUpdatedUser(user), localUser); + return await userProfileRenderer.RenderOne(await userResolver.GetUpdatedUserAsync(user), localUser); } [HttpGet("{id}/notes")] @@ -95,9 +95,9 @@ public class UserController( .Paginate(pq, ControllerContext) .PrecomputeVisibilities(localUser) .ToListAsync() - .ContinueWithResult(res => res.EnforceRenoteReplyVisibility()); + .ContinueWithResultAsync(res => res.EnforceRenoteReplyVisibility()); - return await noteRenderer.RenderMany(notes, localUser, Filter.FilterContext.Accounts); + return await noteRenderer.RenderManyAsync(notes, localUser, Filter.FilterContext.Accounts); } [HttpPost("{id}/bite")] diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index 15f3d3c4..c9ae04b0 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -255,13 +255,13 @@ public class DatabaseContext(DbContextOptions options) RETURNING "jobs".*; """); - public Task GetJobRunningCount(string queue, CancellationToken token) => + public Task GetJobRunningCountAsync(string queue, CancellationToken token) => Jobs.CountAsync(p => p.Queue == queue && p.Status == Job.JobStatus.Running, token); - public Task GetJobQueuedCount(string queue, CancellationToken token) => + public Task GetJobQueuedCountAsync(string queue, CancellationToken token) => Jobs.CountAsync(p => p.Queue == queue && p.Status == Job.JobStatus.Queued, token); - public async Task IsDatabaseEmpty() + public async Task IsDatabaseEmptyAsync() => !await Database.SqlQuery($""" select s.nspname from pg_class c join pg_namespace s on s.oid = c.relnamespace diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index 6910390f..dee10e1d 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -28,7 +28,7 @@ public static class QueryableExtensions /// The result set as an IAsyncEnumerable. Makes one DB roundtrip at the start of each chunk. /// Successive items in the chunk are yielded instantaneously. /// - public static async IAsyncEnumerable AsChunkedAsyncEnumerable(this IQueryable query, int chunkSize) + public static async IAsyncEnumerable AsChunkedAsyncEnumerableAsync(this IQueryable query, int chunkSize) { var offset = 0; while (true) @@ -41,13 +41,13 @@ public static class QueryableExtensions } } - /// + /// /// /// This overload requires you to pass a predicate to the identifier. /// .OrderBy() is appended to the query. /// Set the parameter to append things to the query after pagination, for cases where query translation would fail otherwise. /// - public static async IAsyncEnumerable AsChunkedAsyncEnumerable( + public static async IAsyncEnumerable AsChunkedAsyncEnumerableAsync( this IQueryable query, int chunkSize, Expression> idPredicate, Func, IQueryable>? hook = null ) @@ -70,8 +70,8 @@ public static class QueryableExtensions } } - /// - public static async IAsyncEnumerable AsChunkedAsyncEnumerable( + /// + public static async IAsyncEnumerable AsChunkedAsyncEnumerableAsync( this IQueryable query, int chunkSize, Expression> idPredicate, Func, IQueryable>? hook = null ) @@ -94,8 +94,8 @@ public static class QueryableExtensions } } - /// - public static async IAsyncEnumerable AsChunkedAsyncEnumerable( + /// + public static async IAsyncEnumerable AsChunkedAsyncEnumerableAsync( this IQueryable query, int chunkSize, Expression> idPredicate, Func, IQueryable>? hook = null ) diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableTimelineExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableTimelineExtensions.cs index 2c1ad73c..bd153f1e 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableTimelineExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableTimelineExtensions.cs @@ -29,17 +29,17 @@ public static class QueryableTimelineExtensions .Concat(new[] { user.Id }) .Contains(note.UserId)); - public static async Task ResetHeuristic(User user, CacheService cache) + public static async Task ResetHeuristicAsync(User user, CacheService cache) { await cache.ClearAsync($"{Prefix}:{user.Id}"); } - public static async Task GetHeuristic(User user, DatabaseContext db, CacheService cache) + public static async Task GetHeuristicAsync(User user, DatabaseContext db, CacheService cache) { - return await cache.FetchValueAsync($"{Prefix}:{user.Id}", TimeSpan.FromHours(24), FetchHeuristic); + return await cache.FetchValueAsync($"{Prefix}:{user.Id}", TimeSpan.FromHours(24), FetchHeuristicAsync); [SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall")] - async Task FetchHeuristic() + async Task FetchHeuristicAsync() { var latestNote = await db.Notes.OrderByDescending(p => p.Id) .Select(p => new { p.CreatedAt }) diff --git a/Iceshrimp.Backend/Core/Extensions/ServiceExtensions.cs b/Iceshrimp.Backend/Core/Extensions/ServiceExtensions.cs index 98929b6d..85f346fd 100644 --- a/Iceshrimp.Backend/Core/Extensions/ServiceExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/ServiceExtensions.cs @@ -432,9 +432,9 @@ file sealed class EntityFrameworkCoreXmlRepositoryAsync : IXmlReposito public IReadOnlyCollection GetAllElements() { - return GetAllElementsCore().ToBlockingEnumerable().ToList().AsReadOnly(); + return GetAllElementsCoreAsync().ToBlockingEnumerable().ToList().AsReadOnly(); - async IAsyncEnumerable GetAllElementsCore() + async IAsyncEnumerable GetAllElementsCoreAsync() { using var scope = _services.CreateScope(); var @enum = scope.ServiceProvider.GetRequiredService() diff --git a/Iceshrimp.Backend/Core/Extensions/StreamExtensions.cs b/Iceshrimp.Backend/Core/Extensions/StreamExtensions.cs index e9551068..97a48b84 100644 --- a/Iceshrimp.Backend/Core/Extensions/StreamExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/StreamExtensions.cs @@ -13,7 +13,7 @@ public static class StreamExtensions { int bytesRead; var totalBytesRead = 0L; - while ((maxLength == null || totalBytesRead <= maxLength) && (bytesRead = await DoRead()) != 0) + while ((maxLength == null || totalBytesRead <= maxLength) && (bytesRead = await DoReadAsync()) != 0) { totalBytesRead += bytesRead; await destination.WriteAsync(new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken); @@ -26,6 +26,6 @@ public static class StreamExtensions return; - ValueTask DoRead() => source.ReadAsync(new Memory(buffer), cancellationToken); + ValueTask DoReadAsync() => source.ReadAsync(new Memory(buffer), cancellationToken); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs b/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs index 6645f1b0..45bae27d 100644 --- a/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/TaskExtensions.cs @@ -58,37 +58,37 @@ public static class TaskExtensions return (await task).ToList(); } - public static async Task ContinueWithResult(this Task task, Action continuation) + public static async Task ContinueWithResultAsync(this Task task, Action continuation) { await task; continuation(); } - public static async Task ContinueWithResult(this Task task, Func continuation) + public static async Task ContinueWithResultAsync(this Task task, Func continuation) { await task; return continuation(); } - public static async Task ContinueWithResult(this Task task, Action continuation) + public static async Task ContinueWithResultAsync(this Task task, Action continuation) { continuation(await task); } - public static async Task ContinueWithResult( + public static async Task ContinueWithResultAsync( this Task task, Func continuation ) { return continuation(await task); } - public static async Task ContinueWithResult(this Task task, Func continuation) + public static async Task ContinueWithResultAsync(this Task task, Func continuation) { await task; await continuation(); } - public static async Task ContinueWithResult( + public static async Task ContinueWithResultAsync( this Task task, Func> continuation ) { @@ -96,12 +96,12 @@ public static class TaskExtensions return await continuation(); } - public static async Task ContinueWithResult(this Task task, Func continuation) + public static async Task ContinueWithResultAsync(this Task task, Func continuation) { await continuation(await task); } - public static async Task ContinueWithResult( + public static async Task ContinueWithResultAsync( this Task task, Func> continuation ) { diff --git a/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs b/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs index 6b73b646..f1e21ece 100644 --- a/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs @@ -82,7 +82,7 @@ public static class WebApplicationExtensions app.MapFallbackToPage("/@{user}@{host}", page); } - public static async Task Initialize(this WebApplication app, string[] args) + public static async Task InitializeAsync(this WebApplication app, string[] args) { var instanceConfig = app.Configuration.GetSection("Instance").Get() ?? throw new Exception("Failed to read Instance config section"); @@ -135,7 +135,7 @@ public static class WebApplicationExtensions { app.Logger.LogInformation("Initializing migration assistant..."); var initialMigration = typeof(Initial).GetCustomAttribute()?.Id; - if (pendingMigration != initialMigration || await db.IsDatabaseEmpty()) + if (pendingMigration != initialMigration || await db.IsDatabaseEmptyAsync()) { app.Logger.LogCritical("Database does not appear to be an iceshrimp-js database."); Environment.Exit(1); @@ -171,7 +171,7 @@ public static class WebApplicationExtensions if (pendingMigration != null) { var initialMigration = typeof(Initial).GetCustomAttribute()?.Id; - if (pendingMigration == initialMigration && !await db.IsDatabaseEmpty()) + if (pendingMigration == initialMigration && !await db.IsDatabaseEmptyAsync()) { app.Logger.LogCritical("Initial migration is pending but database is not empty."); app.Logger.LogCritical("If you are trying to migrate from iceshrimp-js, please follow the instructions on https://iceshrimp.net/help/migrate."); @@ -212,19 +212,19 @@ public static class WebApplicationExtensions { app.Logger.LogInformation("Migrating files to object storage, this will take a while..."); db.Database.SetCommandTimeout(0); - await provider.GetRequiredService().MigrateLocalFiles(args.Contains("--purge")); + await provider.GetRequiredService().MigrateLocalFilesAsync(args.Contains("--purge")); Environment.Exit(0); } if (args.Contains("--fixup-media")) { - await provider.GetRequiredService().FixupMedia(args.Contains("--dry-run")); + await provider.GetRequiredService().FixupMediaAsync(args.Contains("--dry-run")); Environment.Exit(0); } if (args.Contains("--cleanup-storage")) { - await provider.GetRequiredService().CleanupStorage(args.Contains("--dry-run")); + await provider.GetRequiredService().CleanupStorageAsync(args.Contains("--dry-run")); Environment.Exit(0); } @@ -271,14 +271,14 @@ public static class WebApplicationExtensions app.Logger.LogInformation("Initializing VAPID keys..."); var meta = provider.GetRequiredService(); - await meta.EnsureSet([MetaEntity.VapidPublicKey, MetaEntity.VapidPrivateKey], () => + await meta.EnsureSetAsync([MetaEntity.VapidPublicKey, MetaEntity.VapidPrivateKey], () => { var keypair = VapidHelper.GenerateVapidKeys(); return [keypair.PublicKey, keypair.PrivateKey]; }); app.Logger.LogInformation("Warming up meta cache..."); - await meta.WarmupCache(); + await meta.WarmupCacheAsync(); // Initialize image processing provider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs index 44b0ef1f..f562e304 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs @@ -49,7 +49,7 @@ public class ActivityFetcherService( private async Task> FetchActivityAsync(string url, User actor, UserKeypair keypair) { logger.LogDebug("Fetching activity {url} as user {id}", url, actor.Id); - var (activity, finalUri) = await FetchActivityInternalWrapper(url, actor, keypair); + var (activity, finalUri) = await FetchActivityInternalWrapperAsync(url, actor, keypair); if (activity?.Id == null) return []; var activityUri = new Uri(activity.Id); @@ -63,7 +63,7 @@ public class ActivityFetcherService( throw GracefulException.UnprocessableEntity("Activity identifier doesn't match final host"); logger.LogDebug("Fetching activity {url} as user {id} (attempt 2)", activityIdUri.AbsoluteUri, actor.Id); - (activity, finalUri) = await FetchActivityInternalWrapper(activityIdUri.AbsoluteUri, actor, keypair); + (activity, finalUri) = await FetchActivityInternalWrapperAsync(activityIdUri.AbsoluteUri, actor, keypair); if (activity?.Id == null) return []; activityUri = new Uri(activity.Id); @@ -79,13 +79,13 @@ public class ActivityFetcherService( /// This abstracts FetchActivityInternal to keep stack traces short in case of HTTP timeouts. /// /// - private async Task<(ASObject? obj, Uri finalUri)> FetchActivityInternalWrapper( + private async Task<(ASObject? obj, Uri finalUri)> FetchActivityInternalWrapperAsync( string url, User actor, UserKeypair keypair, int recurse = 3 ) { try { - return await FetchActivityInternal(url, actor, keypair, recurse); + return await FetchActivityInternalAsync(url, actor, keypair, recurse); } catch (TaskCanceledException e) when (e.Message.Contains("HttpClient.Timeout")) { @@ -93,7 +93,7 @@ public class ActivityFetcherService( } } - private async Task<(ASObject? obj, Uri finalUri)> FetchActivityInternal( + private async Task<(ASObject? obj, Uri finalUri)> FetchActivityInternalAsync( string url, User actor, UserKeypair keypair, int recurse = 3 ) { @@ -115,7 +115,7 @@ public class ActivityFetcherService( var location = response.Headers.Location; if (location == null) throw new Exception("Redirection requested but no location header found"); if (recurse <= 0) throw new Exception("Redirection requested but recurse counter is at zero"); - return await FetchActivityInternal(location.ToString(), actor, keypair, --recurse); + return await FetchActivityInternalAsync(location.ToString(), actor, keypair, --recurse); } var finalUri = response.RequestMessage?.RequestUri ?? diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityHandlerService.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityHandlerService.cs index ad61b8b5..495bc2ec 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityHandlerService.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityHandlerService.cs @@ -72,20 +72,20 @@ public class ActivityHandlerService( var task = activity switch { - ASAccept accept => HandleAccept(accept, resolvedActor), - ASAnnounce announce => HandleAnnounce(announce, resolvedActor), - ASBite bite => HandleBite(bite, resolvedActor, inboxUser), - ASBlock block => HandleBlock(block, resolvedActor), - ASCreate create => HandleCreate(create, resolvedActor, inboxUser), - ASDelete delete => HandleDelete(delete, resolvedActor), - ASEmojiReact react => HandleReact(react, resolvedActor), - ASFollow follow => HandleFollow(follow, resolvedActor), - ASLike like => HandleLike(like, resolvedActor), - ASMove move => HandleMove(move, resolvedActor), - ASReject reject => HandleReject(reject, resolvedActor), - ASUndo undo => HandleUndo(undo, resolvedActor), - ASUnfollow unfollow => HandleUnfollow(unfollow, resolvedActor), - ASUpdate update => HandleUpdate(update, resolvedActor), + ASAccept accept => HandleAcceptAsync(accept, resolvedActor), + ASAnnounce announce => HandleAnnounceAsync(announce, resolvedActor), + ASBite bite => HandleBiteAsync(bite, resolvedActor, inboxUser), + ASBlock block => HandleBlockAsync(block, resolvedActor), + ASCreate create => HandleCreateAsync(create, resolvedActor, inboxUser), + ASDelete delete => HandleDeleteAsync(delete, resolvedActor), + ASEmojiReact react => HandleReactAsync(react, resolvedActor), + ASFollow follow => HandleFollowAsync(follow, resolvedActor), + ASLike like => HandleLikeAsync(like, resolvedActor), + ASMove move => HandleMoveAsync(move, resolvedActor), + ASReject reject => HandleRejectAsync(reject, resolvedActor), + ASUndo undo => HandleUndoAsync(undo, resolvedActor), + ASUnfollow unfollow => HandleUnfollowAsync(unfollow, resolvedActor), + ASUpdate update => HandleUpdateAsync(update, resolvedActor), // Separated for readability _ => throw GracefulException.UnprocessableEntity($"Activity type {activity.Type} is unknown") @@ -96,31 +96,31 @@ public class ActivityHandlerService( private void UpdateInstanceMetadataInBackground(string host, string webDomain) { - _ = followupTaskSvc.ExecuteTask("UpdateInstanceMetadata", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateInstanceMetadata", async provider => { var instanceSvc = provider.GetRequiredService(); await instanceSvc.UpdateInstanceStatusAsync(host, webDomain); }); } - private async Task HandleCreate(ASCreate activity, User actor, User? inboxUser) + private async Task HandleCreateAsync(ASCreate activity, User actor, User? inboxUser) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Create activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, actor.Uri) as ASNote ?? + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, actor.Uri) as ASNote ?? throw GracefulException.UnprocessableEntity("Failed to resolve create object"); using (await NoteService.GetNoteProcessLockAsync(activity.Object.Id)) await noteSvc.ProcessNoteAsync(activity.Object, actor, inboxUser); } - private async Task HandleDelete(ASDelete activity, User resolvedActor) + private async Task HandleDeleteAsync(ASDelete activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Delete activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); switch (activity.Object) { @@ -155,12 +155,12 @@ public class ActivityHandlerService( } } - private async Task HandleFollow(ASFollow activity, User resolvedActor) + private async Task HandleFollowAsync(ASFollow activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Follow activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASActor obj) throw GracefulException.UnprocessableEntity("Follow activity object is invalid"); @@ -171,31 +171,31 @@ public class ActivityHandlerService( await userSvc.FollowUserAsync(resolvedActor, followee, activity.Id); } - private async Task HandleUnfollow(ASUnfollow activity, User resolvedActor) + private async Task HandleUnfollowAsync(ASUnfollow activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Unfollow activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASActor obj) throw GracefulException.UnprocessableEntity("Unfollow activity object is invalid"); await UnfollowAsync(obj, resolvedActor); } - private async Task HandleAccept(ASAccept activity, User actor) + private async Task HandleAcceptAsync(ASAccept activity, User actor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Accept activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, actor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, actor.Uri); if (activity.Object is not ASFollow obj) throw GracefulException.UnprocessableEntity("Accept activity object is invalid"); var relayPrefix = $"https://{config.Value.WebDomain}/activities/follow-relay/"; if (obj.Id.StartsWith(relayPrefix)) { - await relaySvc.HandleAccept(actor, obj.Id[relayPrefix.Length..]); + await relaySvc.HandleAcceptAsync(actor, obj.Id[relayPrefix.Length..]); return; } @@ -228,21 +228,21 @@ public class ActivityHandlerService( await userSvc.AcceptFollowRequestAsync(request); } - private async Task HandleReject(ASReject activity, User resolvedActor) + private async Task HandleRejectAsync(ASReject activity, User resolvedActor) { if (activity.Actor == null) throw GracefulException.UnprocessableEntity("Reject activity actor was null"); if (activity.Object == null) throw GracefulException.UnprocessableEntity("Reject activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASFollow follow) throw GracefulException.UnprocessableEntity("Reject activity object is invalid"); var relayPrefix = $"https://{config.Value.WebDomain}/activities/follow-relay/"; if (follow.Id.StartsWith(relayPrefix)) { - await relaySvc.HandleReject(resolvedActor, follow.Id[relayPrefix.Length..]); + await relaySvc.HandleRejectAsync(resolvedActor, follow.Id[relayPrefix.Length..]); return; } @@ -281,12 +281,12 @@ public class ActivityHandlerService( .ExecuteDeleteAsync(); } - private async Task HandleUndo(ASUndo activity, User resolvedActor) + private async Task HandleUndoAsync(ASUndo activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Undo activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); switch (activity.Object) { @@ -318,14 +318,14 @@ public class ActivityHandlerService( } } - private async Task HandleLike(ASLike activity, User resolvedActor) + private async Task HandleLikeAsync(ASLike activity, User resolvedActor) { if (resolvedActor.Host == null) throw GracefulException.UnprocessableEntity("Cannot process like for local actor"); if (activity.Object == null) throw GracefulException.UnprocessableEntity("Like activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASNote note) { @@ -344,14 +344,14 @@ public class ActivityHandlerService( } } - private async Task HandleUpdate(ASUpdate activity, User resolvedActor) + private async Task HandleUpdateAsync(ASUpdate activity, User resolvedActor) { if (activity.Actor == null) throw GracefulException.UnprocessableEntity("Cannot process update for null actor"); if (activity.Object == null) throw GracefulException.UnprocessableEntity("Update activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); switch (activity.Object) { @@ -370,9 +370,9 @@ public class ActivityHandlerService( } } - private async Task HandleBite(ASBite activity, User resolvedActor, User? inboxUser) + private async Task HandleBiteAsync(ASBite activity, User resolvedActor, User? inboxUser) { - var target = await objectResolver.ResolveObject(activity.Target, resolvedActor.Uri); + var target = await objectResolver.ResolveObjectAsync(activity.Target, resolvedActor.Uri); var dbBite = target switch { ASActor targetActor => new Bite @@ -431,15 +431,15 @@ public class ActivityHandlerService( await db.AddAsync(dbBite); await db.SaveChangesAsync(); - await notificationSvc.GenerateBiteNotification(dbBite); + await notificationSvc.GenerateBiteNotificationAsync(dbBite); } - private async Task HandleAnnounce(ASAnnounce activity, User resolvedActor) + private async Task HandleAnnounceAsync(ASAnnounce activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("Announce activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASNote note) { logger.LogDebug("Announce activity object is unknown, skipping"); @@ -471,14 +471,14 @@ public class ActivityHandlerService( }); } - private async Task HandleReact(ASEmojiReact activity, User resolvedActor) + private async Task HandleReactAsync(ASEmojiReact activity, User resolvedActor) { if (resolvedActor.Host == null) throw GracefulException.UnprocessableEntity("Cannot process EmojiReact for local actor"); if (activity.Object == null) throw GracefulException.UnprocessableEntity("EmojiReact activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASNote note) { logger.LogDebug("EmojiReact activity object is unknown, skipping"); @@ -489,12 +489,12 @@ public class ActivityHandlerService( await noteSvc.ReactToNoteAsync(note, resolvedActor, activity.Content); } - private async Task HandleBlock(ASBlock activity, User resolvedActor) + private async Task HandleBlockAsync(ASBlock activity, User resolvedActor) { if (activity.Object == null) throw GracefulException.UnprocessableEntity("EmojiReact activity object was null"); - activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri); + activity.Object = await objectResolver.ResolveObjectAsync(activity.Object, resolvedActor.Uri); if (activity.Object is not ASActor blockee) { logger.LogDebug("Block activity object is unknown, skipping"); @@ -509,7 +509,7 @@ public class ActivityHandlerService( await userSvc.BlockUserAsync(resolvedActor, resolvedBlockee); } - private async Task HandleMove(ASMove activity, User resolvedActor) + private async Task HandleMoveAsync(ASMove activity, User resolvedActor) { if (activity.Target.Id is null) throw GracefulException.UnprocessableEntity("Move target must have an ID"); var target = await userResolver.ResolveAsync(activity.Target.Id, EnforceUriFlags); @@ -548,7 +548,7 @@ public class ActivityHandlerService( db.RemoveRange(followings); await db.SaveChangesAsync(); - _ = followupTaskSvc.ExecuteTask("DecrementInstanceIncomingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("DecrementInstanceIncomingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs index 65871333..c46eedf3 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs @@ -17,7 +17,7 @@ public class ObjectResolver( IOptions config ) : IScopedService { - public async Task ResolveObject( + public async Task ResolveObjectAsync( ASObjectBase baseObj, string? actorUri = null, int recurse = 5, bool force = false, User? user = null ) { @@ -25,8 +25,8 @@ public class ObjectResolver( if (baseObj is ASActivity { Object.IsUnresolved: true } activity && recurse > 0) { - activity.Object = await ResolveObject(activity.Object, actorUri, --recurse, force); - return await ResolveObject(activity, actorUri, recurse); + activity.Object = await ResolveObjectAsync(activity.Object, actorUri, --recurse, force); + return await ResolveObjectAsync(activity, actorUri, recurse); } if (baseObj is ASObject { IsUnresolved: false } obj && !force) @@ -90,12 +90,12 @@ public class ObjectResolver( } } - public async IAsyncEnumerable IterateCollection(ASCollection? collection, User? user = null, int pageLimit = 10) + public async IAsyncEnumerable IterateCollectionAsync(ASCollection? collection, User? user = null, int pageLimit = 10) { if (collection == null) yield break; if (collection.IsUnresolved) - collection = await ResolveObject(collection, force: true, user: user) as ASCollection; + collection = await ResolveObjectAsync(collection, force: true, user: user) as ASCollection; if (collection == null) yield break; @@ -110,7 +110,7 @@ public class ObjectResolver( while (page != null) { if (page.IsUnresolved) - page = await ResolveObject(page, force: true, user: user) as ASCollectionPage; + page = await ResolveObjectAsync(page, force: true, user: user) as ASCollectionPage; if (page == null) break; diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs index 774c9072..585b5b24 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/UserResolver.cs @@ -345,7 +345,7 @@ public class UserResolver( return null; } - public async Task GetUpdatedUser(User user) + public async Task GetUpdatedUserAsync(User user) { if (!user.NeedsUpdate) return user; @@ -358,7 +358,7 @@ public class UserResolver( try { - var task = followupTaskSvc.ExecuteTask("UpdateUserAsync", async provider => + var task = followupTaskSvc.ExecuteTaskAsync("UpdateUserAsync", async provider => { // Get a fresh UserService instance in a new scope var bgUserSvc = provider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Core/Helpers/PluginLoader.cs b/Iceshrimp.Backend/Core/Helpers/PluginLoader.cs index 73eba54f..661802cb 100644 --- a/Iceshrimp.Backend/Core/Helpers/PluginLoader.cs +++ b/Iceshrimp.Backend/Core/Helpers/PluginLoader.cs @@ -22,7 +22,7 @@ public abstract class PluginLoader private static IEnumerable Plugins => Loaded.Select(p => p.instance); public static IEnumerable Assemblies => Loaded.Select(p => p.assembly); - public static async Task LoadPlugins() + public static async Task LoadPluginsAsync() { if (!Directory.Exists(DllPath)) return; var dlls = Directory.EnumerateFiles(DllPath, "*.dll").ToList(); @@ -33,7 +33,7 @@ public abstract class PluginLoader .Cast() .ToImmutableList(); - await Plugins.Select(i => i.Initialize()).AwaitAllNoConcurrencyAsync(); + await Plugins.Select(i => i.InitializeAsync()).AwaitAllNoConcurrencyAsync(); } public static void RunBuilderHooks(WebApplicationBuilder builder) @@ -74,7 +74,7 @@ public interface IPlugin public string Name { get; } public string Version { get; } - public Task Initialize() => Task.CompletedTask; + public Task InitializeAsync() => Task.CompletedTask; public WebApplicationBuilder BuilderHook(WebApplicationBuilder builder) => builder; public WebApplication AppHook(WebApplication app) => app; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs b/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs index 17b9adc6..db1dbc4d 100644 --- a/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs +++ b/Iceshrimp.Backend/Core/Middleware/AuthenticationMiddleware.cs @@ -26,7 +26,7 @@ public class AuthenticationMiddleware( var isBlazorSsr = endpoint?.Metadata.GetMetadata() != null; if (isBlazorSsr) { - await AuthenticateBlazorSsr(ctx, attribute); + await AuthenticateBlazorSsrAsync(ctx, attribute); await next(ctx); return; } @@ -113,7 +113,7 @@ public class AuthenticationMiddleware( await next(ctx); } - private async Task AuthenticateBlazorSsr(HttpContext ctx, AuthenticateAttribute attribute) + private async Task AuthenticateBlazorSsrAsync(HttpContext ctx, AuthenticateAttribute attribute) { if (!ctx.Request.Cookies.TryGetValue("admin_session", out var token)) return; diff --git a/Iceshrimp.Backend/Core/Middleware/ErrorHandlerMiddleware.cs b/Iceshrimp.Backend/Core/Middleware/ErrorHandlerMiddleware.cs index e2d51abb..109b816d 100644 --- a/Iceshrimp.Backend/Core/Middleware/ErrorHandlerMiddleware.cs +++ b/Iceshrimp.Backend/Core/Middleware/ErrorHandlerMiddleware.cs @@ -105,7 +105,7 @@ public class ErrorHandlerMiddleware( RequestId = ctx.TraceIdentifier }; - await WriteResponse(error); + await WriteResponseAsync(error); } var level = ce.SuppressLog ? LogLevel.Trace : LogLevel.Debug; @@ -131,11 +131,11 @@ public class ErrorHandlerMiddleware( RequestId = ctx.TraceIdentifier }; - await WriteResponse(error); + await WriteResponseAsync(error); logger.LogError("Request encountered an unexpected error: {exception}", e); } - async Task WriteResponse(ErrorResponse payload) + async Task WriteResponseAsync(ErrorResponse payload) { var accept = ctx.Request.Headers.Accept.NotNull().SelectMany(p => p.Split(',')).ToImmutableArray(); var resType = ResponseType.Json; diff --git a/Iceshrimp.Backend/Core/Queues/BackfillQueue.cs b/Iceshrimp.Backend/Core/Queues/BackfillQueue.cs index 99c6cbcc..e115d093 100644 --- a/Iceshrimp.Backend/Core/Queues/BackfillQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/BackfillQueue.cs @@ -83,7 +83,7 @@ public class BackfillQueue(int parallelism) .Where(n => n.Id == current.Id) .ExecuteUpdateAsync(p => p.SetProperty(n => n.RepliesFetchedAt, DateTime.UtcNow), token); - await foreach (var asNote in objectResolver.IterateCollection(new ASCollection(current.RepliesCollection), user: user) + await foreach (var asNote in objectResolver.IterateCollectionAsync(new ASCollection(current.RepliesCollection), user: user) .Take(MaxRepliesPerNote) .Where(p => p.Id != null) .WithCancellation(token)) diff --git a/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs b/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs index 1433658b..3130571a 100644 --- a/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/BackgroundTaskQueue.cs @@ -26,30 +26,30 @@ public class BackgroundTaskQueue(int parallelism) switch (jobData) { case DriveFileDeleteJobData { Expire: true } driveFileDeleteJob: - await ProcessDriveFileExpire(driveFileDeleteJob, scope, token); + await ProcessDriveFileExpireAsync(driveFileDeleteJob, scope, token); break; case DriveFileDeleteJobData driveFileDeleteJob: - await ProcessDriveFileDelete(driveFileDeleteJob, scope, token); + await ProcessDriveFileDeleteAsync(driveFileDeleteJob, scope, token); break; case PollExpiryJobData pollExpiryJob: - await ProcessPollExpiry(pollExpiryJob, scope, token); + await ProcessPollExpiryAsync(pollExpiryJob, scope, token); break; case MuteExpiryJobData muteExpiryJob: - await ProcessMuteExpiry(muteExpiryJob, scope, token); + await ProcessMuteExpiryAsync(muteExpiryJob, scope, token); break; case FilterExpiryJobData filterExpiryJob: - await ProcessFilterExpiry(filterExpiryJob, scope, token); + await ProcessFilterExpiryAsync(filterExpiryJob, scope, token); break; case UserDeleteJobData userDeleteJob: - await ProcessUserDelete(userDeleteJob, scope, token); + await ProcessUserDeleteAsync(userDeleteJob, scope, token); break; case UserPurgeJobData userPurgeJob: - await ProcessUserPurge(userPurgeJob, scope, token); + await ProcessUserPurgeAsync(userPurgeJob, scope, token); break; } } - private static async Task ProcessDriveFileDelete( + private static async Task ProcessDriveFileDeleteAsync( DriveFileDeleteJobData jobData, IServiceProvider scope, CancellationToken token @@ -101,7 +101,7 @@ public class BackgroundTaskQueue(int parallelism) } } - private static async Task ProcessDriveFileExpire( + private static async Task ProcessDriveFileExpireAsync( DriveFileDeleteJobData jobData, IServiceProvider scope, CancellationToken token @@ -114,13 +114,13 @@ public class BackgroundTaskQueue(int parallelism) var file = await db.DriveFiles.FirstOrDefaultAsync(p => p.Id == jobData.DriveFileId, token); if (file == null) return; - await drive.ExpireFile(file, token); + await drive.ExpireFileAsync(file, token); } [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataQuery", Justification = "IncludeCommonProperties()")] [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataUsage", Justification = "Same as above")] - private static async Task ProcessPollExpiry( + private static async Task ProcessPollExpiryAsync( PollExpiryJobData jobData, IServiceProvider scope, CancellationToken token @@ -135,7 +135,7 @@ public class BackgroundTaskQueue(int parallelism) if (note == null) return; var notificationSvc = scope.GetRequiredService(); - await notificationSvc.GeneratePollEndedNotifications(note); + await notificationSvc.GeneratePollEndedNotificationsAsync(note); if (note.User.IsLocalUser) { var voters = await db.PollVotes.Where(p => p.Note == note && p.User.IsRemoteUser) @@ -156,7 +156,7 @@ public class BackgroundTaskQueue(int parallelism) } } - private static async Task ProcessMuteExpiry( + private static async Task ProcessMuteExpiryAsync( MuteExpiryJobData jobData, IServiceProvider scope, CancellationToken token @@ -176,7 +176,7 @@ public class BackgroundTaskQueue(int parallelism) eventSvc.RaiseUserUnmuted(null, muting.Muter, muting.Mutee); } - private static async Task ProcessFilterExpiry( + private static async Task ProcessFilterExpiryAsync( FilterExpiryJobData jobData, IServiceProvider scope, CancellationToken token @@ -192,7 +192,7 @@ public class BackgroundTaskQueue(int parallelism) await db.SaveChangesAsync(token); } - private static async Task ProcessUserDelete( + private static async Task ProcessUserDeleteAsync( UserDeleteJobData jobData, IServiceProvider scope, CancellationToken token @@ -236,7 +236,7 @@ public class BackgroundTaskQueue(int parallelism) if (user.IsRemoteUser) { - await followupTaskSvc.ExecuteTask("UpdateInstanceUserCounter", async provider => + await followupTaskSvc.ExecuteTaskAsync("UpdateInstanceUserCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -250,7 +250,7 @@ public class BackgroundTaskQueue(int parallelism) logger.LogDebug("User {id} deleted successfully", jobData.UserId); } - private static async Task ProcessUserPurge( + private static async Task ProcessUserPurgeAsync( UserPurgeJobData jobData, IServiceProvider scope, CancellationToken token @@ -272,7 +272,7 @@ public class BackgroundTaskQueue(int parallelism) var fileIdQ = db.DriveFiles.Where(p => p.User == user).Select(p => p.Id); var fileIdCnt = await fileIdQ.CountAsync(token); - var fileIds = fileIdQ.AsChunkedAsyncEnumerable(50, p => p); + var fileIds = fileIdQ.AsChunkedAsyncEnumerableAsync(50, p => p); logger.LogDebug("Removing {count} files for user {id}", fileIdCnt, user.Id); await foreach (var id in fileIds) { @@ -284,7 +284,7 @@ public class BackgroundTaskQueue(int parallelism) var noteQ = db.Notes.Where(p => p.User == user).Select(p => p.Id); var noteCnt = await noteQ.CountAsync(token); - var noteIds = noteQ.AsChunkedAsyncEnumerable(50, p => p); + var noteIds = noteQ.AsChunkedAsyncEnumerableAsync(50, p => p); logger.LogDebug("Removing {count} notes for user {id}", noteCnt, user.Id); await foreach (var id in noteIds) { diff --git a/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs b/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs index 4e35d55a..5e839c33 100644 --- a/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/DeliverQueue.cs @@ -50,16 +50,16 @@ public class DeliverQueue(int parallelism) } catch { - _ = followup.ExecuteTask("UpdateInstanceMetadata", async provider => + _ = followup.ExecuteTaskAsync("UpdateInstanceMetadata", async provider => { var instanceSvc = provider.GetRequiredService(); - await instanceSvc.MarkInstanceAsUnresponsive(jobData.RecipientHost, new Uri(jobData.InboxUrl).Host); + await instanceSvc.MarkInstanceAsUnresponsiveAsync(jobData.RecipientHost, new Uri(jobData.InboxUrl).Host); }); throw; } - _ = followup.ExecuteTask("UpdateInstanceMetadata", async provider => + _ = followup.ExecuteTaskAsync("UpdateInstanceMetadata", async provider => { var instanceSvc = provider.GetRequiredService(); await instanceSvc.UpdateInstanceStatusAsync(jobData.RecipientHost, new Uri(jobData.InboxUrl).Host, diff --git a/Iceshrimp.Backend/Core/Services/BiteService.cs b/Iceshrimp.Backend/Core/Services/BiteService.cs index 0060ca85..8f37fc0b 100644 --- a/Iceshrimp.Backend/Core/Services/BiteService.cs +++ b/Iceshrimp.Backend/Core/Services/BiteService.cs @@ -36,7 +36,7 @@ public class BiteService( await deliverSvc.DeliverToAsync(activity, user, target.User); } - await notificationSvc.GenerateBiteNotification(bite); + await notificationSvc.GenerateBiteNotificationAsync(bite); } public async Task BiteAsync(User user, Note target) @@ -60,7 +60,7 @@ public class BiteService( await deliverSvc.DeliverToAsync(activity, user, target.User); } - await notificationSvc.GenerateBiteNotification(bite); + await notificationSvc.GenerateBiteNotificationAsync(bite); } public async Task BiteAsync(User user, User target) @@ -83,6 +83,6 @@ public class BiteService( await deliverSvc.DeliverToAsync(activity, user, target); } - await notificationSvc.GenerateBiteNotification(bite); + await notificationSvc.GenerateBiteNotificationAsync(bite); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Services/CronService.cs b/Iceshrimp.Backend/Core/Services/CronService.cs index 9d445bbe..053ea130 100644 --- a/Iceshrimp.Backend/Core/Services/CronService.cs +++ b/Iceshrimp.Backend/Core/Services/CronService.cs @@ -29,7 +29,7 @@ public class CronService(IServiceScopeFactory serviceScopeFactory) : BackgroundS try { await using var scope = serviceScopeFactory.CreateAsyncScope(); - await task.Invoke(scope.ServiceProvider); + await task.InvokeAsync(scope.ServiceProvider); } catch { @@ -46,7 +46,7 @@ public interface ICronTask { public TimeSpan Trigger { get; } public CronTaskType Type { get; } - public Task Invoke(IServiceProvider provider); + public Task InvokeAsync(IServiceProvider provider); } public enum CronTaskType diff --git a/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs b/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs index 2cde99d6..5d551eaf 100644 --- a/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs +++ b/Iceshrimp.Backend/Core/Services/CustomHttpClient.cs @@ -14,7 +14,7 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ private static readonly HttpMessageHandler InnerHandler = new SocketsHttpHandler { AutomaticDecompression = DecompressionMethods.All, - ConnectCallback = FastFallbackHandler.ConnectCallback, + ConnectCallback = FastFallbackHandler.ConnectCallbackAsync, PooledConnectionIdleTimeout = TimeSpan.FromMinutes(5), PooledConnectionLifetime = TimeSpan.FromMinutes(60) }; @@ -53,9 +53,9 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ private bool AllowLocalIPv4 => Security?.CurrentValue.AllowLocalIPv4 ?? false; private bool AllowLocalIPv6 => Security?.CurrentValue.AllowLocalIPv6 ?? false; - public async ValueTask ConnectCallback(SocketsHttpConnectionContext context, CancellationToken token) + public async ValueTask ConnectCallbackAsync(SocketsHttpConnectionContext context, CancellationToken token) { - var sortedRecords = await GetSortedAddresses(context.DnsEndPoint.Host, token); + var sortedRecords = await GetSortedAddressesAsync(context.DnsEndPoint.Host, token); var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(token); var tasks = new List>(); @@ -91,7 +91,7 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ delayCts.CancelAfter(connectionBackoff * i); - var task = AttemptConnection(record, context.DnsEndPoint.Port, linkedToken.Token, delayCts.Token); + var task = AttemptConnectionAsync(record, context.DnsEndPoint.Port, linkedToken.Token, delayCts.Token); tasks.Add(task); var nextDelayCts = CancellationTokenSource.CreateLinkedTokenSource(linkedToken.Token); @@ -126,7 +126,7 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ return stream; } - private static async Task<(NetworkStream? stream, Exception? exception)> AttemptConnection( + private static async Task<(NetworkStream? stream, Exception? exception)> AttemptConnectionAsync( IPAddress address, int port, CancellationToken token, CancellationToken delayToken ) { @@ -152,7 +152,7 @@ public class CustomHttpClient : HttpClient, IService, ISingletonServ } } - private static async Task> GetSortedAddresses(string hostname, CancellationToken token) + private static async Task> GetSortedAddressesAsync(string hostname, CancellationToken token) { // This method abuses DNS ordering and LINQ a bit. We can normally assume that addresses will be provided in // the order the system wants to use. GroupBy will return its groups *in the order they're discovered*. Meaning, diff --git a/Iceshrimp.Backend/Core/Services/DriveService.cs b/Iceshrimp.Backend/Core/Services/DriveService.cs index b8171bf1..f95d8941 100644 --- a/Iceshrimp.Backend/Core/Services/DriveService.cs +++ b/Iceshrimp.Backend/Core/Services/DriveService.cs @@ -29,7 +29,7 @@ public class DriveService( ImageProcessor imageProcessor ) : IScopedService { - public async Task StoreFile( + public async Task StoreFileAsync( string? uri, User user, bool sensitive, string? description = null, string? mimeType = null, bool logExisting = true, bool forceStore = false, bool skipImageProcessing = false ) @@ -120,7 +120,7 @@ public class DriveService( var stream = await GetSafeStreamOrNullAsync(input, maxLength, res.Content.Headers.ContentLength); try { - return await StoreFile(stream, user, request, skipImageProcessing); + return await StoreFileAsync(stream, user, request, skipImageProcessing); } catch (Exception e) { @@ -160,7 +160,7 @@ public class DriveService( } } - public async Task StoreFile( + public async Task StoreFileAsync( Stream input, User user, DriveFileCreationRequest request, bool skipImageProcessing = false ) { @@ -283,9 +283,9 @@ public class DriveService( blurhash = res.Blurhash; var processed = await res.RequestedFormats - .Select(p => ProcessAndStoreFileVersion(p.Key, p.Value, request.Filename)) + .Select(p => ProcessAndStoreFileVersionAsync(p.Key, p.Value, request.Filename)) .AwaitAllNoConcurrencyAsync() - .ContinueWithResult(p => p.ToImmutableArray()); + .ContinueWithResultAsync(p => p.ToImmutableArray()); original = processed.FirstOrDefault(p => p?.format.Key == KeyEnum.Original) ?? throw new Exception("Image processing didn't result in an original version"); @@ -359,11 +359,11 @@ public class DriveService( ) { var accessKey = GenerateAccessKey(extension: Path.GetExtension(request.Filename).TrimStart('.')).TrimStart('-'); - var url = await StoreFileVersion(input, accessKey, request.Filename, request.MimeType); + var url = await StoreFileVersionAsync(input, accessKey, request.Filename, request.MimeType); return (Stub, accessKey, url); } - private async Task ProcessAndStoreFileVersion( + private async Task ProcessAndStoreFileVersionAsync( ImageVersion version, Func>? encode, string fileName ) { @@ -387,7 +387,7 @@ public class DriveService( } fileName = GenerateDerivedFileName(fileName, version.Format.Extension); - var url = await StoreFileVersion(stream, accessKey, fileName, version.Format.MimeType); + var url = await StoreFileVersionAsync(stream, accessKey, fileName, version.Format.MimeType); return (version, accessKey, url); } finally @@ -397,17 +397,17 @@ public class DriveService( } } - private Task StoreFileVersion(Stream stream, string accessKey, string fileName, string mimeType) + private Task StoreFileVersionAsync(Stream stream, string accessKey, string fileName, string mimeType) { return storageConfig.Value.Provider switch { - Enums.FileStorage.Local => StoreFileVersionLocalStorage(stream, accessKey), - Enums.FileStorage.ObjectStorage => StoreFileVersionObjectStorage(stream, accessKey, fileName, mimeType), + Enums.FileStorage.Local => StoreFileVersionLocalStorageAsync(stream, accessKey), + Enums.FileStorage.ObjectStorage => StoreFileVersionObjectStorageAsync(stream, accessKey, fileName, mimeType), _ => throw new ArgumentOutOfRangeException() }; } - private async Task StoreFileVersionLocalStorage(Stream stream, string filename) + private async Task StoreFileVersionLocalStorageAsync(Stream stream, string filename) { var pathBase = storageConfig.Value.Local?.Path ?? throw new Exception("Local storage path cannot be null"); @@ -419,7 +419,7 @@ public class DriveService( return $"https://{instanceConfig.Value.WebDomain}/files/{filename}"; } - private async Task StoreFileVersionObjectStorage( + private async Task StoreFileVersionObjectStorageAsync( Stream stream, string accessKey, string filename, string mimeType ) { @@ -428,18 +428,18 @@ public class DriveService( return storageSvc.GetFilePublicUrl(accessKey).AbsoluteUri; } - public async Task RemoveFile(DriveFile file) + public async Task RemoveFileAsync(DriveFile file) { - await RemoveFile(file.Id); + await RemoveFileAsync(file.Id); } - public async Task RemoveFile(string fileId) + public async Task RemoveFileAsync(string fileId) { var job = new DriveFileDeleteJobData { DriveFileId = fileId, Expire = false }; await queueSvc.BackgroundTaskQueue.EnqueueAsync(job); } - public async Task ExpireFile(DriveFile file, CancellationToken token = default) + public async Task ExpireFileAsync(DriveFile file, CancellationToken token = default) { if (file is not { UserHost: not null, Uri: not null, IsLink: false }) return; @@ -489,10 +489,10 @@ public class DriveService( } } - public async Task> GetAllFileNamesFromObjectStorage() + public async Task> GetAllFileNamesFromObjectStorageAsync() { return storageConfig.Value.ObjectStorage?.Bucket != null - ? await storageSvc.EnumerateFilesAsync().ToArrayAsync().AsTask().ContinueWithResult(p => p.ToHashSet()) + ? await storageSvc.EnumerateFilesAsync().ToArrayAsync().AsTask().ContinueWithResultAsync(p => p.ToHashSet()) : []; } diff --git a/Iceshrimp.Backend/Core/Services/EmojiImportService.cs b/Iceshrimp.Backend/Core/Services/EmojiImportService.cs index 82906182..1dc10c1e 100644 --- a/Iceshrimp.Backend/Core/Services/EmojiImportService.cs +++ b/Iceshrimp.Backend/Core/Services/EmojiImportService.cs @@ -35,7 +35,7 @@ public class EmojiImportService( { public static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web); - public async Task Parse(Stream zipStream) + public async Task ParseAsync(Stream zipStream) { var archive = new ZipArchive(zipStream, ZipArchiveMode.Read); @@ -62,7 +62,7 @@ public class EmojiImportService( } } - public async Task Import(EmojiZip zip) + public async Task ImportAsync(EmojiZip zip) { using var archive = zip.Archive; var contentTypeProvider = new FileExtensionContentTypeProvider(); @@ -91,7 +91,7 @@ public class EmojiImportService( try { - await emojiSvc.CreateEmojiFromStream( + await emojiSvc.CreateEmojiFromStreamAsync( buffer, name, mimeType, diff --git a/Iceshrimp.Backend/Core/Services/EmojiService.cs b/Iceshrimp.Backend/Core/Services/EmojiService.cs index 9c77b1c9..534e842c 100644 --- a/Iceshrimp.Backend/Core/Services/EmojiService.cs +++ b/Iceshrimp.Backend/Core/Services/EmojiService.cs @@ -26,7 +26,7 @@ public partial class EmojiService( o.PoolInitialFill = 5; }); - public async Task CreateEmojiFromStream( + public async Task CreateEmojiFromStreamAsync( Stream input, string fileName, string mimeType, List? aliases = null, string? category = null ) @@ -43,7 +43,7 @@ public partial class EmojiService( MimeType = mimeType, IsSensitive = false }; - var driveFile = await driveSvc.StoreFile(input, user, request, true); + var driveFile = await driveSvc.StoreFileAsync(input, user, request, true); var id = IdHelpers.GenerateSnowflakeId(); var emoji = new Emoji @@ -67,10 +67,10 @@ public partial class EmojiService( return emoji; } - public async Task CloneEmoji(Emoji existing) + public async Task CloneEmojiAsync(Emoji existing) { var user = await sysUserSvc.GetInstanceActorAsync(); - var driveFile = await driveSvc.StoreFile(existing.OriginalUrl, user, false, forceStore: true, + var driveFile = await driveSvc.StoreFileAsync(existing.OriginalUrl, user, false, forceStore: true, skipImageProcessing: false) ?? throw new Exception("Error storing emoji file"); @@ -93,13 +93,13 @@ public partial class EmojiService( return emoji; } - public async Task DeleteEmoji(string id) + public async Task DeleteEmojiAsync(string id) { var emoji = await db.Emojis.FirstOrDefaultAsync(p => p.Host == null && p.Id == id); if (emoji == null) throw GracefulException.NotFound("Emoji not found"); var driveFile = await db.DriveFiles.FirstOrDefaultAsync(p => p.Url == emoji.OriginalUrl); - if (driveFile != null) await driveSvc.RemoveFile(driveFile.Id); + if (driveFile != null) await driveSvc.RemoveFileAsync(driveFile.Id); db.Remove(emoji); await db.SaveChangesAsync(); @@ -150,7 +150,7 @@ public partial class EmojiService( private const string MisskeyHeart = "\u2764"; private const string EmojiVersionSelector = "\ufe0f"; - public async Task ResolveEmojiName(string name, string? host) + public async Task ResolveEmojiNameAsync(string name, string? host) { if (name == MisskeyHeart) return name + EmojiVersionSelector; @@ -177,7 +177,7 @@ public partial class EmojiService( return hit.Host == null ? $":{hit.Name}:" : $":{hit.Name}@{hit.Host}:"; } - public async Task ResolveEmoji(string fqn) + public async Task ResolveEmojiAsync(string fqn) { if (!fqn.StartsWith(':')) return null; var split = fqn.Trim(':').Split('@'); @@ -187,7 +187,7 @@ public partial class EmojiService( return await db.Emojis.FirstOrDefaultAsync(p => p.Host == host && p.Name == name); } - public async Task> ResolveEmoji(IEnumerable nodes) + public async Task> ResolveEmojiAsync(IEnumerable nodes) { var list = new List(); ResolveChildren(nodes, ref list); @@ -206,7 +206,7 @@ public partial class EmojiService( } } - public async Task UpdateLocalEmoji( + public async Task UpdateLocalEmojiAsync( string id, string? name, List? aliases, string? category, string? license, bool? sensitive ) { diff --git a/Iceshrimp.Backend/Core/Services/FollowupTaskService.cs b/Iceshrimp.Backend/Core/Services/FollowupTaskService.cs index 24987a56..f0d78592 100644 --- a/Iceshrimp.Backend/Core/Services/FollowupTaskService.cs +++ b/Iceshrimp.Backend/Core/Services/FollowupTaskService.cs @@ -9,7 +9,7 @@ public class FollowupTaskService( { public AsyncLocal IsBackgroundWorker { get; } = new(); - public Task ExecuteTask(string taskName, Func work) + public Task ExecuteTaskAsync(string taskName, Func work) { return Task.Run(async () => { diff --git a/Iceshrimp.Backend/Core/Services/ImportExportService.cs b/Iceshrimp.Backend/Core/Services/ImportExportService.cs index b197df04..829b369f 100644 --- a/Iceshrimp.Backend/Core/Services/ImportExportService.cs +++ b/Iceshrimp.Backend/Core/Services/ImportExportService.cs @@ -48,6 +48,6 @@ public class ImportExportService( } } - await QueryableTimelineExtensions.ResetHeuristic(user, cacheSvc); + await QueryableTimelineExtensions.ResetHeuristicAsync(user, cacheSvc); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Services/InstanceService.cs b/Iceshrimp.Backend/Core/Services/InstanceService.cs index ef123627..fdd5a4f6 100644 --- a/Iceshrimp.Backend/Core/Services/InstanceService.cs +++ b/Iceshrimp.Backend/Core/Services/InstanceService.cs @@ -142,7 +142,7 @@ public class InstanceService( await db.SaveChangesAsync(); } - public async Task MarkInstanceAsUnresponsive(string host, string webDomain) + public async Task MarkInstanceAsUnresponsiveAsync(string host, string webDomain) { var instance = await GetUpdatedInstanceMetadataAsync(host, webDomain); instance.LatestRequestSentAt = DateTime.UtcNow; diff --git a/Iceshrimp.Backend/Core/Services/MetaService.cs b/Iceshrimp.Backend/Core/Services/MetaService.cs index e480b640..64ffd3e9 100644 --- a/Iceshrimp.Backend/Core/Services/MetaService.cs +++ b/Iceshrimp.Backend/Core/Services/MetaService.cs @@ -7,29 +7,29 @@ namespace Iceshrimp.Backend.Core.Services; public class MetaService([FromKeyedServices("cache")] DatabaseContext db) : IScopedService { - public async Task Get(Meta meta) => meta.ConvertGet(await Fetch(meta.Key)); + public async Task GetAsync(Meta meta) => meta.ConvertGet(await FetchAsync(meta.Key)); - public async Task GetMany(params Meta[] entities) + public async Task GetManyAsync(params Meta[] entities) { - var res = await FetchMany(entities.Select(p => p.Key)); + var res = await FetchManyAsync(entities.Select(p => p.Key)); return entities.Select(p => p.ConvertGet(res.GetValueOrDefault(p.Key, null))).ToArray(); } - public async Task EnsureSet(Meta meta, T value) => await EnsureSet(meta, () => value); + public async Task EnsureSetAsync(Meta meta, T value) => await EnsureSetAsync(meta, () => value); - public async Task EnsureSet(Meta meta, Func value) + public async Task EnsureSetAsync(Meta meta, Func value) { - if (await Fetch(meta.Key) != null) return; - await Set(meta, value()); + if (await FetchAsync(meta.Key) != null) return; + await SetAsync(meta, value()); } - public async Task EnsureSet(Meta meta, Func> value) + public async Task EnsureSetAsync(Meta meta, Func> value) { - if (await Fetch(meta.Key) != null) return; - await Set(meta, await value()); + if (await FetchAsync(meta.Key) != null) return; + await SetAsync(meta, await value()); } - public async Task EnsureSet(IReadOnlyList> metas, Func> values) + public async Task EnsureSetAsync(IReadOnlyList> metas, Func> values) { if (await db.MetaStore.CountAsync(p => metas.Select(m => m.Key).Contains(p.Key)) == metas.Count) return; @@ -39,22 +39,22 @@ public class MetaService([FromKeyedServices("cache")] DatabaseContext db) : ISco throw new Exception("Metas count doesn't match values count"); for (var i = 0; i < metas.Count; i++) - await Set(metas[i], resolvedValues[i]); + await SetAsync(metas[i], resolvedValues[i]); } - public async Task Set(Meta meta, T value) => await Set(meta.Key, meta.ConvertSet(value)); + public async Task SetAsync(Meta meta, T value) => await SetAsync(meta.Key, meta.ConvertSet(value)); // Ensures the table is in memory (we could use pg_prewarm for this but that extension requires superuser privileges to install) - public async Task WarmupCache() => await db.MetaStore.ToListAsync(); + public async Task WarmupCacheAsync() => await db.MetaStore.ToListAsync(); - private async Task Fetch(string key) => + private async Task FetchAsync(string key) => await db.MetaStore.Where(p => p.Key == key).Select(p => p.Value).FirstOrDefaultAsync(); - private async Task> FetchMany(IEnumerable keys) => + private async Task> FetchManyAsync(IEnumerable keys) => await db.MetaStore.Where(p => keys.Contains(p.Key)) .ToDictionaryAsync(p => p.Key, p => p.Value); - private async Task Set(string key, string? value) + private async Task SetAsync(string key, string? value) { var entity = await db.MetaStore.FirstOrDefaultAsync(p => p.Key == key); if (entity != null) diff --git a/Iceshrimp.Backend/Core/Services/NoteService.cs b/Iceshrimp.Backend/Core/Services/NoteService.cs index df13161f..5e856f46 100644 --- a/Iceshrimp.Backend/Core/Services/NoteService.cs +++ b/Iceshrimp.Backend/Core/Services/NoteService.cs @@ -101,7 +101,7 @@ public class NoteService( { logger.LogDebug("Creating note for user {id}", data.User.Id); - await policySvc.Initialize(); + await policySvc.InitializeAsync(); // @formatter:off if (data.User.IsRemoteUser && policySvc.ShouldReject(data, out var policy)) @@ -215,7 +215,7 @@ public class NoteService( if (data.Emoji == null && data.User.IsLocalUser && nodes != null) { - data.Emoji = (await emojiSvc.ResolveEmoji(nodes)).Select(p => p.Id).ToList(); + data.Emoji = (await emojiSvc.ResolveEmojiAsync(nodes)).Select(p => p.Id).ToList(); } List visibleUserIds = []; @@ -295,7 +295,7 @@ public class NoteService( await db.AddAsync(data.Poll); note.HasPoll = true; - await EnqueuePollExpiryTask(data.Poll); + await EnqueuePollExpiryTaskAsync(data.Poll); } logger.LogDebug("Inserting created note {noteId} for user {userId} into the database", note.Id, data.User.Id); @@ -304,15 +304,15 @@ public class NoteService( await db.AddAsync(note); await db.SaveChangesAsync(); eventSvc.RaiseNotePublished(this, note); - await notificationSvc.GenerateMentionNotifications(note, mentionedLocalUserIds); - await notificationSvc.GenerateReplyNotifications(note, mentionedLocalUserIds); - await notificationSvc.GenerateRenoteNotification(note); + await notificationSvc.GenerateMentionNotificationsAsync(note, mentionedLocalUserIds); + await notificationSvc.GenerateReplyNotificationsAsync(note, mentionedLocalUserIds); + await notificationSvc.GenerateRenoteNotificationAsync(note); logger.LogDebug("Note {id} created successfully", note.Id); if (data.Uri != null || data.Url != null) { - _ = followupTaskSvc.ExecuteTask("ResolvePendingReplyRenoteTargets", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("ResolvePendingReplyRenoteTargets", async provider => { var bgDb = provider.GetRequiredService(); var count = 0; @@ -372,7 +372,7 @@ public class NoteService( if (data.User.IsRemoteUser) { - _ = followupTaskSvc.ExecuteTask("UpdateInstanceNoteCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateInstanceNoteCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -510,7 +510,7 @@ public class NoteService( if (note.User.IsLocalUser && nodes != null) { - data.Emoji = (await emojiSvc.ResolveEmoji(nodes)).Select(p => p.Id).ToList(); + data.Emoji = (await emojiSvc.ResolveEmojiAsync(nodes)).Select(p => p.Id).ToList(); } if (data.Emoji != null && !note.Emojis.IsEquivalent(data.Emoji)) @@ -576,7 +576,7 @@ public class NoteService( if (note.Poll.ExpiresAt != poll.ExpiresAt) { note.Poll.ExpiresAt = poll.ExpiresAt; - await EnqueuePollExpiryTask(note.Poll); + await EnqueuePollExpiryTaskAsync(note.Poll); } if (!note.Poll.Choices.SequenceEqual(poll.Choices) || note.Poll.Multiple != poll.Multiple) @@ -617,7 +617,7 @@ public class NoteService( poll.Votes = poll.Choices.Select(_ => 0).ToList(); await db.AddAsync(poll); - await EnqueuePollExpiryTask(poll); + await EnqueuePollExpiryTaskAsync(poll); } note.HasPoll = true; @@ -654,8 +654,8 @@ public class NoteService( if (!isEdit) return note; - await notificationSvc.GenerateMentionNotifications(note, mentionedLocalUserIds); - await notificationSvc.GenerateEditNotifications(note); + await notificationSvc.GenerateMentionNotificationsAsync(note, mentionedLocalUserIds); + await notificationSvc.GenerateEditNotificationsAsync(note); if (note.LocalOnly || note.User.IsRemoteUser) return note; @@ -680,7 +680,7 @@ public class NoteService( { if (note.User.Uri != null) { - _ = followupTaskSvc.ExecuteTask("UpdateInstanceNoteCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateInstanceNoteCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -842,7 +842,7 @@ public class NoteService( }; await db.AddAsync(vote); await db.SaveChangesAsync(); - await pollSvc.RegisterPollVote(vote, poll, reply); + await pollSvc.RegisterPollVoteAsync(vote, poll, reply); return null; } @@ -1062,7 +1062,7 @@ public class NoteService( tags = tags.Distinct().ToList(); - _ = followupTaskSvc.ExecuteTask("UpdateHashtagsTable", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateHashtagsTable", async provider => { var bgDb = provider.GetRequiredService(); var existing = await bgDb.Hashtags.Where(p => tags.Contains(p.Name)).Select(p => p.Name).ToListAsync(); @@ -1119,7 +1119,7 @@ public class NoteService( var result = await attachments .OfType() .Take(10) - .Select(p => driveSvc.StoreFile(p.Url?.Id, user, p.Sensitive ?? sensitive, p.Description, + .Select(p => driveSvc.StoreFileAsync(p.Url?.Id, user, p.Sensitive ?? sensitive, p.Description, p.MediaType, logExisting)) .AwaitAllNoConcurrencyAsync(); @@ -1289,7 +1289,7 @@ public class NoteService( } eventSvc.RaiseNoteLiked(this, note, user); - await notificationSvc.GenerateLikeNotification(note, user); + await notificationSvc.GenerateLikeNotificationAsync(note, user); return true; } @@ -1445,12 +1445,12 @@ public class NoteService( var collection = actor.Featured; if (collection == null) return; if (collection.IsUnresolved) - collection = await objectResolver.ResolveObject(collection, force: true) as ASOrderedCollection; + collection = await objectResolver.ResolveObjectAsync(collection, force: true) as ASOrderedCollection; if (collection is not { Items: not null }) return; // ReSharper disable once EntityFramework.UnsupportedServerSideFunctionCall var followingUser = await db.Users.FirstOrDefaultAsync(p => p.IsFollowing(user)); - var notes = await objectResolver.IterateCollection(collection) + var notes = await objectResolver.IterateCollectionAsync(collection) .Take(10) .Where(p => p.Id != null) .Select(p => ResolveNoteAsync(p.Id!, null, followingUser, true)) @@ -1480,7 +1480,7 @@ public class NoteService( await db.SaveChangesAsync(); } - private async Task EnqueuePollExpiryTask(Poll poll) + private async Task EnqueuePollExpiryTaskAsync(Poll poll) { // Skip polls without expiry date if (!poll.ExpiresAt.HasValue) return; @@ -1496,7 +1496,7 @@ public class NoteService( if (note.IsPureRenote) throw GracefulException.BadRequest("Cannot react to a pure renote"); - name = await emojiSvc.ResolveEmojiName(name, user.Host); + name = await emojiSvc.ResolveEmojiNameAsync(name, user.Host); if (await db.NoteReactions.AnyAsync(p => p.Note == note && p.User == user && p.Reaction == name)) return (name, false); @@ -1515,7 +1515,7 @@ public class NoteService( await db.AddAsync(reaction); await db.SaveChangesAsync(); eventSvc.RaiseNoteReacted(this, reaction); - await notificationSvc.GenerateReactionNotification(reaction); + await notificationSvc.GenerateReactionNotificationAsync(reaction); // @formatter:off await db.Database.ExecuteSqlAsync($"""UPDATE "note" SET "reactions" = jsonb_set("reactions", ARRAY[{name}], (COALESCE("reactions"->>{name}, '0')::int + 1)::text::jsonb) WHERE "id" = {note.Id}"""); @@ -1523,7 +1523,7 @@ public class NoteService( if (user.IsLocalUser) { - var emoji = await emojiSvc.ResolveEmoji(reaction.Reaction); + var emoji = await emojiSvc.ResolveEmojiAsync(reaction.Reaction); var activity = activityRenderer.RenderReact(reaction, emoji); await deliverSvc.DeliverToConditionalAsync(activity, user, note); } @@ -1542,7 +1542,7 @@ public class NoteService( public async Task<(string name, bool success)> RemoveReactionFromNoteAsync(Note note, User user, string name) { - name = await emojiSvc.ResolveEmojiName(name, user.Host); + name = await emojiSvc.ResolveEmojiNameAsync(name, user.Host); var reaction = await db.NoteReactions.FirstOrDefaultAsync(p => p.Note == note && p.User == user && p.Reaction == name); @@ -1558,7 +1558,7 @@ public class NoteService( if (user.IsLocalUser) { var actor = userRenderer.RenderLite(user); - var emoji = await emojiSvc.ResolveEmoji(reaction.Reaction); + var emoji = await emojiSvc.ResolveEmojiAsync(reaction.Reaction); var activity = activityRenderer.RenderUndo(actor, activityRenderer.RenderReact(reaction, emoji)); await deliverSvc.DeliverToConditionalAsync(activity, user, note); } diff --git a/Iceshrimp.Backend/Core/Services/NotificationService.cs b/Iceshrimp.Backend/Core/Services/NotificationService.cs index ae39b164..35cd2e77 100644 --- a/Iceshrimp.Backend/Core/Services/NotificationService.cs +++ b/Iceshrimp.Backend/Core/Services/NotificationService.cs @@ -12,7 +12,7 @@ public class NotificationService( EventService eventSvc ) : IScopedService { - public async Task GenerateMentionNotifications(Note note, IReadOnlyCollection mentionedLocalUserIds) + public async Task GenerateMentionNotificationsAsync(Note note, IReadOnlyCollection mentionedLocalUserIds) { if (mentionedLocalUserIds.Count == 0) return; @@ -40,7 +40,7 @@ public class NotificationService( eventSvc.RaiseNotifications(this, notifications); } - public async Task GenerateReplyNotifications(Note note, IReadOnlyCollection mentionedLocalUserIds) + public async Task GenerateReplyNotificationsAsync(Note note, IReadOnlyCollection mentionedLocalUserIds) { var users = mentionedLocalUserIds .Concat(note.VisibleUserIds) @@ -84,7 +84,7 @@ public class NotificationService( [SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall", Justification = "Projectable functions are very much translatable")] - public async Task GenerateEditNotifications(Note note) + public async Task GenerateEditNotificationsAsync(Note note) { var notifications = await db.Users .Where(p => p.IsLocalUser && p != note.User && p.HasInteractedWith(note)) @@ -107,7 +107,7 @@ public class NotificationService( eventSvc.RaiseNotifications(this, notifications); } - public async Task GenerateLikeNotification(Note note, User user) + public async Task GenerateLikeNotificationAsync(Note note, User user) { if (note.UserHost != null) return; if (note.User == user) return; @@ -127,7 +127,7 @@ public class NotificationService( eventSvc.RaiseNotification(this, notification); } - public async Task GenerateReactionNotification(NoteReaction reaction) + public async Task GenerateReactionNotificationAsync(NoteReaction reaction) { if (reaction.Note.User.IsRemoteUser) return; if (reaction.Note.User == reaction.User) return; @@ -148,7 +148,7 @@ public class NotificationService( eventSvc.RaiseNotification(this, notification); } - public async Task GenerateFollowNotification(User follower, User followee) + public async Task GenerateFollowNotificationAsync(User follower, User followee) { if (followee.IsRemoteUser) return; @@ -167,7 +167,7 @@ public class NotificationService( eventSvc.RaiseUserFollowed(this, follower, followee); } - public async Task GenerateFollowRequestReceivedNotification(FollowRequest followRequest) + public async Task GenerateFollowRequestReceivedNotificationAsync(FollowRequest followRequest) { if (followRequest.FolloweeHost != null) return; @@ -186,7 +186,7 @@ public class NotificationService( eventSvc.RaiseNotification(this, notification); } - public async Task GenerateFollowRequestAcceptedNotification(FollowRequest followRequest) + public async Task GenerateFollowRequestAcceptedNotificationAsync(FollowRequest followRequest) { if (followRequest.FollowerHost != null) return; if (!followRequest.Followee.IsLocked) return; @@ -206,7 +206,7 @@ public class NotificationService( eventSvc.RaiseUserFollowed(this, followRequest.Follower, followRequest.Followee); } - public async Task GenerateBiteNotification(Bite bite) + public async Task GenerateBiteNotificationAsync(Bite bite) { var notification = new Notification { @@ -225,7 +225,7 @@ public class NotificationService( eventSvc.RaiseNotification(this, notification); } - public async Task GeneratePollEndedNotifications(Note note) + public async Task GeneratePollEndedNotificationsAsync(Note note) { var notifications = await db.PollVotes .Where(p => p.Note == note) @@ -264,7 +264,7 @@ public class NotificationService( } [SuppressMessage("ReSharper", "EntityFramework.UnsupportedServerSideFunctionCall", Justification = "Projectables")] - public async Task GenerateRenoteNotification(Note note) + public async Task GenerateRenoteNotificationAsync(Note note) { if (note.Renote is not { UserHost: null }) return; if (note.RenoteUserId == note.UserId) return; diff --git a/Iceshrimp.Backend/Core/Services/PluginStore.cs b/Iceshrimp.Backend/Core/Services/PluginStore.cs index 4f3c9c19..19b30968 100644 --- a/Iceshrimp.Backend/Core/Services/PluginStore.cs +++ b/Iceshrimp.Backend/Core/Services/PluginStore.cs @@ -28,24 +28,24 @@ public class PluginStore(DatabaseContext db) where TPlugin : IPl private readonly IPlugin _plugin = new TPlugin(); /// - public async Task GetData() + public async Task GetDataAsync() { - return (await GetOrCreateData()).data; + return (await GetOrCreateDataAsync()).data; } /// - public async Task GetData(Expression> predicate) + public async Task GetDataAsync(Expression> predicate) { - var (_, data) = await GetOrCreateData(); + var (_, data) = await GetOrCreateDataAsync(); return predicate.Compile().Invoke(data); } /// - public async Task UpdateData(Action updateAction) + public async Task UpdateDataAsync(Action updateAction) { using (await PluginStoreHelpers.KeyedLocker.LockAsync(_plugin.Id)) { - var (entry, data) = await GetOrCreateData(); + var (entry, data) = await GetOrCreateDataAsync(); updateAction(data); UpdateEntryIfModified(entry, data); await db.SaveChangesAsync(); @@ -60,7 +60,7 @@ public class PluginStore(DatabaseContext db) where TPlugin : IPl } /// - private async Task<(PluginStoreEntry entry, TData data)> GetOrCreateData() + private async Task<(PluginStoreEntry entry, TData data)> GetOrCreateDataAsync() { TData data; var entry = await db.PluginStore.FirstOrDefaultAsync(p => p.Id == _plugin.Id); diff --git a/Iceshrimp.Backend/Core/Services/PolicyService.cs b/Iceshrimp.Backend/Core/Services/PolicyService.cs index d2b77fe8..63db3b2c 100644 --- a/Iceshrimp.Backend/Core/Services/PolicyService.cs +++ b/Iceshrimp.Backend/Core/Services/PolicyService.cs @@ -21,7 +21,7 @@ public class PolicyService(IServiceScopeFactory scopeFactory) : ISingletonServic private Type[] _policyTypes = []; private Type[] _policyConfigurationTypes = []; - public async Task Initialize() + public async Task InitializeAsync() { if (_initialized) return; _initialized = true; @@ -35,12 +35,12 @@ public class PolicyService(IServiceScopeFactory scopeFactory) : ISingletonServic _policyTypes.Contains(t))) .ToArray(); - await Update(); + await UpdateAsync(); } - public async Task Update() + public async Task UpdateAsync() { - if (!_initialized) await Initialize(); + if (!_initialized) await InitializeAsync(); await using var scope = scopeFactory.CreateAsyncScope(); var db = scope.ServiceProvider.GetRequiredService(); @@ -95,9 +95,9 @@ public class PolicyService(IServiceScopeFactory scopeFactory) : ISingletonServic foreach (var hook in hooks) hook.Apply(note, actor); } - public async Task GetConfigurationType(string name) + public async Task GetConfigurationTypeAsync(string name) { - await Initialize(); + await InitializeAsync(); var type = _policyTypes.FirstOrDefault(p => p.Name == name); return _policyConfigurationTypes .FirstOrDefault(p => p.GetInterfaces() @@ -106,17 +106,17 @@ public class PolicyService(IServiceScopeFactory scopeFactory) : ISingletonServic type); } - public async Task GetConfiguration(string name, string? data) + public async Task GetConfigurationAsync(string name, string? data) { - var type = await GetConfigurationType(name); + var type = await GetConfigurationTypeAsync(name); if (type == null) return null; if (data == null) return (IPolicyConfiguration?)Activator.CreateInstance(type); return (IPolicyConfiguration?)JsonSerializer.Deserialize(data, type, JsonSerialization.Options); } - public async Task> GetAvailablePolicies() + public async Task> GetAvailablePoliciesAsync() { - await Initialize(); + await InitializeAsync(); return _policyTypes.Select(p => p.Name).ToList(); } } diff --git a/Iceshrimp.Backend/Core/Services/PollService.cs b/Iceshrimp.Backend/Core/Services/PollService.cs index 2127b5e1..97d54384 100644 --- a/Iceshrimp.Backend/Core/Services/PollService.cs +++ b/Iceshrimp.Backend/Core/Services/PollService.cs @@ -12,7 +12,7 @@ public class PollService( ActivityPub.ActivityDeliverService deliverSvc ) : IScopedService { - public async Task RegisterPollVote(PollVote pollVote, Poll poll, Note note, bool updateVotersCount = true) + public async Task RegisterPollVoteAsync(PollVote pollVote, Poll poll, Note note, bool updateVotersCount = true) { await db.Database .ExecuteSqlAsync($"""UPDATE "poll" SET "votes"[{pollVote.Choice + 1}] = "votes"[{pollVote.Choice + 1}] + 1 WHERE "noteId" = {note.Id}"""); diff --git a/Iceshrimp.Backend/Core/Services/PushService.cs b/Iceshrimp.Backend/Core/Services/PushService.cs index ff95cfb2..aac1375e 100644 --- a/Iceshrimp.Backend/Core/Services/PushService.cs +++ b/Iceshrimp.Backend/Core/Services/PushService.cs @@ -26,12 +26,12 @@ public class PushService( { protected override Task ExecuteAsync(CancellationToken stoppingToken) { - eventSvc.Notification += MastodonPushHandler; + eventSvc.Notification += MastodonPushHandlerAsync; //TODO: eventSvc.Notification += WebPushHandler; return Task.CompletedTask; } - private async void MastodonPushHandler(object? _, Notification notification) + private async void MastodonPushHandlerAsync(object? _, Notification notification) { try { @@ -103,7 +103,7 @@ public class PushService( body = body.Truncate(137).TrimEnd() + "..."; var meta = scope.ServiceProvider.GetRequiredService(); - var (priv, pub) = await meta.GetMany(MetaEntity.VapidPrivateKey, MetaEntity.VapidPublicKey); + var (priv, pub) = await meta.GetManyAsync(MetaEntity.VapidPrivateKey, MetaEntity.VapidPublicKey); var client = new WebPushClient(httpClient); client.SetVapidDetails(new VapidDetails($"https://{config.Value.WebDomain}", pub, priv)); diff --git a/Iceshrimp.Backend/Core/Services/QueueService.cs b/Iceshrimp.Backend/Core/Services/QueueService.cs index d323e815..cc4b9cac 100644 --- a/Iceshrimp.Backend/Core/Services/QueueService.cs +++ b/Iceshrimp.Backend/Core/Services/QueueService.cs @@ -53,19 +53,19 @@ public class QueueService( logger.LogInformation("Queue shutdown complete."); }); - _ = Task.Run(ExecuteHealthchecksWorker, token); - await Task.Run(ExecuteBackgroundWorkers, tokenSource.Token); + _ = Task.Run(ExecuteHealthchecksWorkerAsync, token); + await Task.Run(ExecuteBackgroundWorkersAsync, tokenSource.Token); return; - async Task? ExecuteBackgroundWorkers() + async Task? ExecuteBackgroundWorkersAsync() { var tasks = _queues.Select(queue => queue.ExecuteAsync(scopeFactory, tokenSource.Token, queueToken)); await Task.WhenAll(tasks); await tokenSource.CancelAsync(); } - async Task ExecuteHealthchecksWorker() + async Task ExecuteHealthchecksWorkerAsync() { var first = true; while (!token.IsCancellationRequested) @@ -261,7 +261,7 @@ public abstract class PostgresJobQueue( await using var scope = GetScope(); await using var db = GetDbContext(scope); - var queuedCount = await db.GetJobQueuedCount(name, token); + var queuedCount = await db.GetJobQueuedCountAsync(name, token); var actualParallelism = Math.Min(_semaphore.CurrentCount, queuedCount); if (actualParallelism == 0) @@ -351,7 +351,7 @@ public abstract class PostgresJobQueue( } var tokenSource = new CancellationTokenSource(); - await ScheduleDelayedEvent(tokenSource.Token); + await ScheduleDelayedEventAsync(tokenSource.Token); await _delayedChannel.WaitAsync(token); await tokenSource.CancelAsync(); } @@ -367,7 +367,7 @@ public abstract class PostgresJobQueue( } } - private async Task ScheduleDelayedEvent(CancellationToken token) + private async Task ScheduleDelayedEventAsync(CancellationToken token) { await using var scope = GetScope(); await using var db = GetDbContext(scope); diff --git a/Iceshrimp.Backend/Core/Services/RelayService.cs b/Iceshrimp.Backend/Core/Services/RelayService.cs index 3609dcd0..acae09b9 100644 --- a/Iceshrimp.Backend/Core/Services/RelayService.cs +++ b/Iceshrimp.Backend/Core/Services/RelayService.cs @@ -15,7 +15,7 @@ public class RelayService( ActivityPub.UserRenderer userRenderer ) : IScopedService { - public async Task SubscribeToRelay(string uri) + public async Task SubscribeToRelayAsync(string uri) { uri = new Uri(uri).AbsoluteUri; if (await db.Relays.AnyAsync(p => p.Inbox == uri)) return; @@ -35,7 +35,7 @@ public class RelayService( await deliverSvc.DeliverToAsync(activity, actor, uri); } - public async Task UnsubscribeFromRelay(Relay relay) + public async Task UnsubscribeFromRelayAsync(Relay relay) { var actor = await systemUserSvc.GetRelayActorAsync(); var follow = activityRenderer.RenderFollow(actor, relay); @@ -46,7 +46,7 @@ public class RelayService( await db.SaveChangesAsync(); } - public async Task HandleAccept(User actor, string id) + public async Task HandleAcceptAsync(User actor, string id) { // @formatter:off if (await db.Relays.FirstOrDefaultAsync(p => p.Id == id) is not { } relay) @@ -60,7 +60,7 @@ public class RelayService( await db.SaveChangesAsync(); } - public async Task HandleReject(User actor, string id) + public async Task HandleRejectAsync(User actor, string id) { // @formatter:off if (db.Relays.FirstOrDefault(p => p.Id == id) is not { } relay) diff --git a/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs b/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs index fa900da9..9315e826 100644 --- a/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs +++ b/Iceshrimp.Backend/Core/Services/StorageMaintenanceService.cs @@ -18,7 +18,7 @@ public class StorageMaintenanceService( ILogger logger ) : IScopedService { - public async Task MigrateLocalFiles(bool purge) + public async Task MigrateLocalFilesAsync(bool purge) { var pathBase = options.Value.Local?.Path; var pathsToDelete = new ConcurrentBag(); @@ -46,7 +46,7 @@ public class StorageMaintenanceService( if (hits.Count == 0) break; - await Parallel.ForEachAsync(hits, new ParallelOptions { MaxDegreeOfParallelism = 8 }, TryMigrateFile); + await Parallel.ForEachAsync(hits, new ParallelOptions { MaxDegreeOfParallelism = 8 }, TryMigrateFileAsync); await db.SaveChangesAsync(); foreach (var path in pathsToDelete) File.Delete(path); @@ -62,16 +62,16 @@ public class StorageMaintenanceService( else if (!purge) logger.LogInformation("Done. Some files could not be migrated successfully. You may retry this process or clean them up by adding --purge to the CLI arguments."); else - await PurgeFiles(); + await PurgeFilesAsync(); return; [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] - async ValueTask TryMigrateFile(IEnumerable files, CancellationToken token) + async ValueTask TryMigrateFileAsync(IEnumerable files, CancellationToken token) { try { - await MigrateFile(files).WaitAsync(token); + await MigrateFileAsync(files).WaitAsync(token); } catch (Exception e) { @@ -84,7 +84,7 @@ public class StorageMaintenanceService( } [SuppressMessage("ReSharper", "PossibleMultipleEnumeration")] - async Task MigrateFile(IEnumerable files) + async Task MigrateFileAsync(IEnumerable files) { var file = files.FirstOrDefault(); if (file == null) return; @@ -135,7 +135,7 @@ public class StorageMaintenanceService( foreach (var item in deletionQueue) pathsToDelete.Add(item); } - async Task PurgeFiles() + async Task PurgeFilesAsync() { logger.LogInformation("Done. Purging {count} failed files...", failed.Count); foreach (var chunk in failed.Chunk(100)) @@ -144,7 +144,7 @@ public class StorageMaintenanceService( } } - public async Task FixupMedia(bool dryRun) + public async Task FixupMediaAsync(bool dryRun) { var query = db.DriveFiles.Where(p => !p.IsLink && p.Uri != null && p.CreatedAt < DateTime.UtcNow); var total = await query.CountAsync(); @@ -153,9 +153,9 @@ public class StorageMaintenanceService( logger.LogInformation("Validating all files, this may take a long time..."); var localFiles = driveSvc.GetAllFileNamesFromLocalStorage(); - var objStorageFiles = await driveSvc.GetAllFileNamesFromObjectStorage(); + var objStorageFiles = await driveSvc.GetAllFileNamesFromObjectStorageAsync(); - await foreach (var file in query.AsChunkedAsyncEnumerable(50, p => p.Id)) + await foreach (var file in query.AsChunkedAsyncEnumerableAsync(50, p => p.Id)) { if (++progress % 500 == 0) logger.LogInformation("Validating files... ({idx}/{total})", progress, total); @@ -178,7 +178,7 @@ public class StorageMaintenanceService( continue; } - await driveSvc.ExpireFile(file); + await driveSvc.ExpireFileAsync(file); await db.Users.Where(p => p.AvatarId == file.Id) .ExecuteUpdateAsync(p => p.SetProperty(u => u.AvatarUrl, file.Uri)); await db.Users.Where(p => p.BannerId == file.Id) @@ -236,7 +236,7 @@ public class StorageMaintenanceService( } } - public async Task CleanupStorage(bool dryRun) + public async Task CleanupStorageAsync(bool dryRun) { var filenames = await db.DriveFiles .Where(p => !p.IsLink) @@ -247,7 +247,7 @@ public class StorageMaintenanceService( p.PublicAccessKey }) .ToArrayAsync() - .ContinueWithResult(res => res.SelectMany(p => new List + .ContinueWithResultAsync(res => res.SelectMany(p => new List { p.AccessKey, p.ThumbnailAccessKey, diff --git a/Iceshrimp.Backend/Core/Services/StreamingService.cs b/Iceshrimp.Backend/Core/Services/StreamingService.cs index 358f1915..c857b898 100644 --- a/Iceshrimp.Backend/Core/Services/StreamingService.cs +++ b/Iceshrimp.Backend/Core/Services/StreamingService.cs @@ -60,14 +60,14 @@ public sealed class StreamingService : ISingletonService conn?.Dispose(); } - public Task Subscribe(string userId, string connectionId, StreamingTimeline timeline) + public Task SubscribeAsync(string userId, string connectionId, StreamingTimeline timeline) { _connections.TryGetValue(userId, out var conn); conn?.Subscribe(connectionId, timeline); return Task.CompletedTask; } - public Task Unsubscribe(string userId, string connectionId, StreamingTimeline timeline) + public Task UnsubscribeAsync(string userId, string connectionId, StreamingTimeline timeline) { _connections.TryGetValue(userId, out var conn); conn?.Unsubscribe(connectionId, timeline); diff --git a/Iceshrimp.Backend/Core/Services/UserProfileMentionsResolver.cs b/Iceshrimp.Backend/Core/Services/UserProfileMentionsResolver.cs index 85b61513..e58aedc2 100644 --- a/Iceshrimp.Backend/Core/Services/UserProfileMentionsResolver.cs +++ b/Iceshrimp.Backend/Core/Services/UserProfileMentionsResolver.cs @@ -19,7 +19,7 @@ public class UserProfileMentionsResolver( IOptions config ) : IScopedService { - public async Task ResolveMentions(ASActor actor, string? host) + public async Task ResolveMentionsAsync(ASActor actor, string? host) { var fields = actor.Attachments?.OfType() .Where(p => p is { Name: not null, Value: not null }) @@ -72,7 +72,7 @@ public class UserProfileMentionsResolver( return (mentions, splitDomainMapping); } - public async Task> ResolveMentions(UserProfile.Field[]? fields, string? bio, string? host) + public async Task> ResolveMentionsAsync(UserProfile.Field[]? fields, string? bio, string? host) { if (fields is not { Length: > 0 } && bio == null) return []; var input = (fields ?? []) diff --git a/Iceshrimp.Backend/Core/Services/UserService.cs b/Iceshrimp.Backend/Core/Services/UserService.cs index 1a7158ea..227e3f0c 100644 --- a/Iceshrimp.Backend/Core/Services/UserService.cs +++ b/Iceshrimp.Backend/Core/Services/UserService.cs @@ -211,11 +211,11 @@ public class UserService( { await db.AddRangeAsync(user, profile, publicKey); await db.SaveChangesAsync(); - var processPendingDeletes = await ResolveAvatarAndBanner(user, actor); + var processPendingDeletes = await ResolveAvatarAndBannerAsync(user, actor); await processPendingDeletes(); - user = await UpdateProfileMentions(user, actor); + user = await UpdateProfileMentionsAsync(user, actor); UpdateUserPinnedNotesInBackground(actor, user); - _ = followupTaskSvc.ExecuteTask("UpdateInstanceUserCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateInstanceUserCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -317,7 +317,7 @@ public class UserService( //TODO: update acct host via webfinger here - var processPendingDeletes = await ResolveAvatarAndBanner(user, actor); + var processPendingDeletes = await ResolveAvatarAndBannerAsync(user, actor); user.UserProfile.Description = actor.MkSummary ?? await MfmConverter.FromHtmlAsync(actor.Summary); //user.UserProfile.Birthday = TODO; @@ -334,7 +334,7 @@ public class UserService( db.Update(user); await db.SaveChangesAsync(); await processPendingDeletes(); - user = await UpdateProfileMentions(user, actor, true); + user = await UpdateProfileMentionsAsync(user, actor, true); UpdateUserPinnedNotesInBackground(actor, user, true); return user; } @@ -351,38 +351,38 @@ public class UserService( if (user.UserProfile.Description != null) { var nodes = MfmParser.Parse(user.UserProfile.Description); - user.Emojis.AddRange((await emojiSvc.ResolveEmoji(nodes)).Select(p => p.Id).ToList()); + user.Emojis.AddRange((await emojiSvc.ResolveEmojiAsync(nodes)).Select(p => p.Id).ToList()); } if (user.DisplayName != null) { var nodes = MfmParser.Parse(user.DisplayName); - user.Emojis.AddRange((await emojiSvc.ResolveEmoji(nodes)).Select(p => p.Id).ToList()); + user.Emojis.AddRange((await emojiSvc.ResolveEmojiAsync(nodes)).Select(p => p.Id).ToList()); } if (user.UserProfile.Fields.Length != 0) { var input = user.UserProfile.Fields.Select(p => $"{p.Name} {p.Value}"); var nodes = MfmParser.Parse(string.Join('\n', input)); - user.Emojis.AddRange((await emojiSvc.ResolveEmoji(nodes)).Select(p => p.Id).ToList()); + user.Emojis.AddRange((await emojiSvc.ResolveEmojiAsync(nodes)).Select(p => p.Id).ToList()); } db.Update(user); db.Update(user.UserProfile); await db.SaveChangesAsync(); - user = await UpdateProfileMentions(user, null, wait: true); + user = await UpdateProfileMentionsAsync(user, null, wait: true); var activity = activityRenderer.RenderUpdate(await userRenderer.RenderAsync(user)); await deliverSvc.DeliverToFollowersAsync(activity, user, []); - _ = followupTaskSvc.ExecuteTask("UpdateLocalUserAsync", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateLocalUserAsync", async provider => { var bgDriveSvc = provider.GetRequiredService(); if (prevAvatarId != null && user.Avatar?.Id != prevAvatarId) - await bgDriveSvc.RemoveFile(prevAvatarId); + await bgDriveSvc.RemoveFileAsync(prevAvatarId); if (prevBannerId != null && user.Banner?.Id != prevBannerId) - await bgDriveSvc.RemoveFile(prevBannerId); + await bgDriveSvc.RemoveFileAsync(prevBannerId); }); return user; @@ -445,11 +445,11 @@ public class UserService( return user; } - private async Task> ResolveAvatarAndBanner(User user, ASActor actor) + private async Task> ResolveAvatarAndBannerAsync(User user, ASActor actor) { - var avatar = await driveSvc.StoreFile(actor.Avatar?.Url?.Link, user, actor.Avatar?.Sensitive ?? false, + var avatar = await driveSvc.StoreFileAsync(actor.Avatar?.Url?.Link, user, actor.Avatar?.Sensitive ?? false, logExisting: false); - var banner = await driveSvc.StoreFile(actor.Banner?.Url?.Link, user, actor.Banner?.Sensitive ?? false, + var banner = await driveSvc.StoreFileAsync(actor.Banner?.Url?.Link, user, actor.Banner?.Sensitive ?? false, logExisting: false); var prevAvatarId = user.AvatarId; @@ -469,10 +469,10 @@ public class UserService( return async () => { if (prevAvatarId != null && avatar?.Id != prevAvatarId) - await driveSvc.RemoveFile(prevAvatarId); + await driveSvc.RemoveFileAsync(prevAvatarId); if (prevBannerId != null && banner?.Id != prevBannerId) - await driveSvc.RemoveFile(prevBannerId); + await driveSvc.RemoveFileAsync(prevBannerId); }; } @@ -542,7 +542,7 @@ public class UserService( if (token.LastActiveDate != null && token.LastActiveDate > DateTime.UtcNow - TimeSpan.FromHours(1)) return; - _ = followupTaskSvc.ExecuteTask("UpdateOauthTokenMetadata", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateOauthTokenMetadata", async provider => { var bgDb = provider.GetRequiredService(); await bgDb.OauthTokens.Where(p => p.Id == token.Id) @@ -557,7 +557,7 @@ public class UserService( if (session.LastActiveDate != null && session.LastActiveDate > DateTime.UtcNow - TimeSpan.FromMinutes(5)) return; - _ = followupTaskSvc.ExecuteTask("UpdateSessionMetadata", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateSessionMetadata", async provider => { var bgDb = provider.GetRequiredService(); await bgDb.Sessions.Where(p => p.Id == session.Id) @@ -570,7 +570,7 @@ public class UserService( if (user.LastActiveDate != null && user.LastActiveDate > DateTime.UtcNow - TimeSpan.FromMinutes(5)) return; - _ = followupTaskSvc.ExecuteTask("UpdateUserLastActive", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateUserLastActive", async provider => { var bgDb = provider.GetRequiredService(); await bgDb.Users.Where(p => p.Id == user.Id) @@ -609,7 +609,7 @@ public class UserService( if (request.Follower is { IsRemoteUser: true }) { - _ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -623,7 +623,7 @@ public class UserService( } else if (request.Followee is { IsRemoteUser: true }) { - _ = followupTaskSvc.ExecuteTask("IncrementInstanceOutgoingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceOutgoingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -636,8 +636,8 @@ public class UserService( if (request.Followee.IsRemoteUser && request.Follower.IsLocalUser && request.Followee.FollowersCount == 0) UpdateUserPinnedNotesInBackground(request.Followee); - await notificationSvc.GenerateFollowNotification(request.Follower, request.Followee); - await notificationSvc.GenerateFollowRequestAcceptedNotification(request); + await notificationSvc.GenerateFollowNotificationAsync(request.Follower, request.Followee); + await notificationSvc.GenerateFollowRequestAcceptedNotificationAsync(request); // Clean up notifications await db.Notifications @@ -771,7 +771,7 @@ public class UserService( await db.AddAsync(following); await db.SaveChangesAsync(); - await notificationSvc.GenerateFollowNotification(follower, followee); + await notificationSvc.GenerateFollowNotificationAsync(follower, followee); await db.Users.Where(p => p.Id == follower.Id) .ExecuteUpdateAsync(p => p.SetProperty(i => i.FollowingCount, @@ -782,7 +782,7 @@ public class UserService( if (follower.IsRemoteUser) { - _ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -814,7 +814,7 @@ public class UserService( await db.AddAsync(request); await db.SaveChangesAsync(); - await notificationSvc.GenerateFollowRequestReceivedNotification(request); + await notificationSvc.GenerateFollowRequestReceivedNotificationAsync(request); } } } @@ -840,7 +840,7 @@ public class UserService( await db.AddAsync(following); await db.SaveChangesAsync(); - await notificationSvc.GenerateFollowNotification(follower, followee); + await notificationSvc.GenerateFollowNotificationAsync(follower, followee); await db.Users.Where(p => p.Id == follower.Id) .ExecuteUpdateAsync(p => p.SetProperty(i => i.FollowingCount, i => i.FollowingCount + 1)); @@ -849,7 +849,7 @@ public class UserService( if (follower.IsRemoteUser) { - _ = followupTaskSvc.ExecuteTask("IncrementInstanceIncomingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("IncrementInstanceIncomingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -906,7 +906,7 @@ public class UserService( if (follower.IsRemoteUser) { - _ = followupTaskSvc.ExecuteTask("DecrementInstanceIncomingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("DecrementInstanceIncomingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -958,7 +958,7 @@ public class UserService( if (followee.IsRemoteUser) { - _ = followupTaskSvc.ExecuteTask("DecrementInstanceOutgoingFollowsCounter", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("DecrementInstanceOutgoingFollowsCounter", async provider => { var bgDb = provider.GetRequiredService(); var bgInstanceSvc = provider.GetRequiredService(); @@ -999,7 +999,7 @@ public class UserService( { if (followupTaskSvc.IsBackgroundWorker.Value && !force) return; if (KeyedLocker.IsInUse($"pinnedNotes:{user.Id}")) return; - _ = followupTaskSvc.ExecuteTask("UpdateUserPinnedNotes", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateUserPinnedNotes", async provider => { using (await KeyedLocker.LockAsync($"pinnedNotes:{user.Id}")) { @@ -1019,7 +1019,7 @@ public class UserService( if (!user.IsRemoteUser) return; if (followupTaskSvc.IsBackgroundWorker.Value && !force) return; if (KeyedLocker.IsInUse($"pinnedNotes:{user.Id}")) return; - _ = followupTaskSvc.ExecuteTask("UpdateUserPinnedNotes", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateUserPinnedNotes", async provider => { using (await KeyedLocker.LockAsync($"pinnedNotes:{user.Id}")) { @@ -1037,14 +1037,14 @@ public class UserService( [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataQuery", Justification = "Projectables")] [SuppressMessage("ReSharper", "EntityFramework.NPlusOne.IncompleteDataUsage", Justification = "Same as above")] [SuppressMessage("ReSharper", "SuggestBaseTypeForParameter", Justification = "Method only makes sense for users")] - private async Task UpdateProfileMentions(User user, ASActor? actor, bool force = false, bool wait = false) + private async Task UpdateProfileMentionsAsync(User user, ASActor? actor, bool force = false, bool wait = false) { if (followupTaskSvc.IsBackgroundWorker.Value && !force) return user; if (KeyedLocker.IsInUse($"profileMentions:{user.Id}")) return user; var success = false; - var task = followupTaskSvc.ExecuteTask("UpdateProfileMentionsInBackground", async provider => + var task = followupTaskSvc.ExecuteTaskAsync("UpdateProfileMentionsInBackground", async provider => { using (await KeyedLocker.LockAsync($"profileMentions:{user.Id}")) { @@ -1056,7 +1056,7 @@ public class UserService( if (actor != null) { - var (mentions, splitDomainMapping) = await bgMentionsResolver.ResolveMentions(actor, bgUser.Host); + var (mentions, splitDomainMapping) = await bgMentionsResolver.ResolveMentionsAsync(actor, bgUser.Host); var fields = actor.Attachments != null ? await actor.Attachments .OfType() @@ -1079,7 +1079,7 @@ public class UserService( } else { - bgUser.UserProfile.Mentions = await bgMentionsResolver.ResolveMentions(bgUser.UserProfile.Fields, + bgUser.UserProfile.Mentions = await bgMentionsResolver.ResolveMentionsAsync(bgUser.UserProfile.Fields, bgUser.UserProfile.Description, bgUser.Host); } @@ -1131,7 +1131,7 @@ public class UserService( tags = tags.Distinct().ToList(); - _ = followupTaskSvc.ExecuteTask("UpdateHashtagsTable", async provider => + _ = followupTaskSvc.ExecuteTaskAsync("UpdateHashtagsTable", async provider => { var bgDb = provider.GetRequiredService(); var existing = await bgDb.Hashtags.Where(p => tags.Contains(p.Name)).Select(p => p.Name).ToListAsync(); @@ -1379,7 +1379,7 @@ public class UserService( var followers = db.Followings .Where(p => p.Followee == source && p.Follower.IsLocalUser) .Select(p => p.Follower) - .AsChunkedAsyncEnumerable(50, p => p.Id, hook: p => p.PrecomputeRelationshipData(source)); + .AsChunkedAsyncEnumerableAsync(50, p => p.Id, hook: p => p.PrecomputeRelationshipData(source)); await foreach (var follower in followers) { @@ -1407,7 +1407,7 @@ public class UserService( var following = db.Followings .Where(p => p.Follower == source) .Select(p => p.Follower) - .AsChunkedAsyncEnumerable(50, p => p.Id, hook: p => p.PrecomputeRelationshipData(source)); + .AsChunkedAsyncEnumerableAsync(50, p => p.Id, hook: p => p.PrecomputeRelationshipData(source)); await foreach (var followee in following) { diff --git a/Iceshrimp.Backend/Core/Tasks/CacheCleanupTask.cs b/Iceshrimp.Backend/Core/Tasks/CacheCleanupTask.cs index f6330654..5a87cf0c 100644 --- a/Iceshrimp.Backend/Core/Tasks/CacheCleanupTask.cs +++ b/Iceshrimp.Backend/Core/Tasks/CacheCleanupTask.cs @@ -8,7 +8,7 @@ namespace Iceshrimp.Backend.Core.Tasks; [SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Instantiated at runtime by CronService")] public class CacheCleanupTask : ICronTask { - public async Task Invoke(IServiceProvider provider) + public async Task InvokeAsync(IServiceProvider provider) { var db = provider.GetRequiredService(); await db.CacheStore.Where(p => p.Expiry != null && p.Expiry < DateTime.UtcNow).ExecuteDeleteAsync(); diff --git a/Iceshrimp.Backend/Core/Tasks/FilterExpiryTask.cs b/Iceshrimp.Backend/Core/Tasks/FilterExpiryTask.cs index cffc3c8a..fdc8fb9f 100644 --- a/Iceshrimp.Backend/Core/Tasks/FilterExpiryTask.cs +++ b/Iceshrimp.Backend/Core/Tasks/FilterExpiryTask.cs @@ -8,7 +8,7 @@ namespace Iceshrimp.Backend.Core.Tasks; [SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Instantiated at runtime by CronService")] public class FilterExpiryTask : ICronTask { - public async Task Invoke(IServiceProvider provider) + public async Task InvokeAsync(IServiceProvider provider) { var db = provider.GetRequiredService(); await db.Filters.Where(p => p.Expiry != null && p.Expiry < DateTime.UtcNow - TimeSpan.FromMinutes(5)) diff --git a/Iceshrimp.Backend/Core/Tasks/JobCleanupTask.cs b/Iceshrimp.Backend/Core/Tasks/JobCleanupTask.cs index f0e2886b..6cb0125a 100644 --- a/Iceshrimp.Backend/Core/Tasks/JobCleanupTask.cs +++ b/Iceshrimp.Backend/Core/Tasks/JobCleanupTask.cs @@ -11,7 +11,7 @@ namespace Iceshrimp.Backend.Core.Tasks; [SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Instantiated at runtime by CronService")] public class JobCleanupTask : ICronTask { - public async Task Invoke(IServiceProvider provider) + public async Task InvokeAsync(IServiceProvider provider) { var db = provider.GetRequiredService(); var queue = provider.GetRequiredService(); diff --git a/Iceshrimp.Backend/Core/Tasks/MediaCleanupTask.cs b/Iceshrimp.Backend/Core/Tasks/MediaCleanupTask.cs index 88da2654..67d1a05f 100644 --- a/Iceshrimp.Backend/Core/Tasks/MediaCleanupTask.cs +++ b/Iceshrimp.Backend/Core/Tasks/MediaCleanupTask.cs @@ -12,7 +12,7 @@ namespace Iceshrimp.Backend.Core.Tasks; [SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Instantiated at runtime by CronService")] public class MediaCleanupTask : ICronTask { - public async Task Invoke(IServiceProvider provider) + public async Task InvokeAsync(IServiceProvider provider) { var config = provider.GetRequiredService>().Value; if (config.MediaRetentionTimeSpan == TimeSpan.MaxValue) return; @@ -34,7 +34,7 @@ public class MediaCleanupTask : ICronTask var cnt = await fileIds.CountAsync(); logger.LogInformation("Expiring {count} files...", cnt); - await foreach (var fileId in fileIds.AsChunkedAsyncEnumerable(50, p => p)) + await foreach (var fileId in fileIds.AsChunkedAsyncEnumerableAsync(50, p => p)) { await queueService.BackgroundTaskQueue.EnqueueAsync(new DriveFileDeleteJobData { diff --git a/Iceshrimp.Backend/Core/Tasks/MuteExpiryTask.cs b/Iceshrimp.Backend/Core/Tasks/MuteExpiryTask.cs index 0d165515..7f8d2e50 100644 --- a/Iceshrimp.Backend/Core/Tasks/MuteExpiryTask.cs +++ b/Iceshrimp.Backend/Core/Tasks/MuteExpiryTask.cs @@ -8,7 +8,7 @@ namespace Iceshrimp.Backend.Core.Tasks; [SuppressMessage("ReSharper", "UnusedType.Global", Justification = "Instantiated at runtime by CronService")] public class MuteExpiryTask : ICronTask { - public async Task Invoke(IServiceProvider provider) + public async Task InvokeAsync(IServiceProvider provider) { var db = provider.GetRequiredService(); await db.Mutings.Where(p => p.ExpiresAt != null && p.ExpiresAt < DateTime.UtcNow - TimeSpan.FromMinutes(5)) diff --git a/Iceshrimp.Backend/Pages/Admin/Metadata.razor b/Iceshrimp.Backend/Pages/Admin/Metadata.razor index 5ce4957e..b9c09c04 100644 --- a/Iceshrimp.Backend/Pages/Admin/Metadata.razor +++ b/Iceshrimp.Backend/Pages/Admin/Metadata.razor @@ -54,15 +54,15 @@ protected override async Task OnGet() { (Model.Name, Model.Description, Model.AdminContact) = - await Meta.GetMany(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); + await Meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription, MetaEntity.AdminContactEmail); } async Task OnSubmit() { Model.Canonicalize(); - await Meta.Set(MetaEntity.InstanceName, Model.Name); - await Meta.Set(MetaEntity.InstanceDescription, Model.Description); - await Meta.Set(MetaEntity.AdminContactEmail, Model.AdminContact); + await Meta.SetAsync(MetaEntity.InstanceName, Model.Name); + await Meta.SetAsync(MetaEntity.InstanceDescription, Model.Description); + await Meta.SetAsync(MetaEntity.AdminContactEmail, Model.AdminContact); ReloadPage(); } diff --git a/Iceshrimp.Backend/Pages/Admin/Relays.razor b/Iceshrimp.Backend/Pages/Admin/Relays.razor index f98ce422..eb9736e0 100644 --- a/Iceshrimp.Backend/Pages/Admin/Relays.razor +++ b/Iceshrimp.Backend/Pages/Admin/Relays.razor @@ -80,7 +80,7 @@ if (Model.InboxUri == null) throw GracefulException.BadRequest("Missing host field"); - await RelayService.SubscribeToRelay(Model.InboxUri); + await RelayService.SubscribeToRelayAsync(Model.InboxUri); ReloadPage(); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Pages/Index.cshtml.cs b/Iceshrimp.Backend/Pages/Index.cshtml.cs index e257817a..8b9f807e 100644 --- a/Iceshrimp.Backend/Pages/Index.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Index.cshtml.cs @@ -22,7 +22,7 @@ public class IndexModel(MetaService meta, IOptionsSnapshot @foreach (var job in Model.Jobs) { - await RenderJob(job, true); + await RenderJobAsync(job, true); } @@ -148,7 +148,7 @@ else @foreach (var job in Model.Jobs) { - await RenderJob(job); + await RenderJobAsync(job); } @@ -219,7 +219,7 @@ else } @{ - async Task RenderJob(Job job, bool withQueue = false) + async Task RenderJobAsync(Job job, bool withQueue = false) { var id = job.Id.ToStringLower(); var additional = job.Status switch diff --git a/Iceshrimp.Backend/Pages/Queue.cshtml.cs b/Iceshrimp.Backend/Pages/Queue.cshtml.cs index e692f89d..7802e664 100644 --- a/Iceshrimp.Backend/Pages/Queue.cshtml.cs +++ b/Iceshrimp.Backend/Pages/Queue.cshtml.cs @@ -36,7 +36,7 @@ public class QueueModel(DatabaseContext db, QueueService queueSvc, MetaService m return Redirect("/login"); Request.HttpContext.HideFooter(); - InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName; + InstanceName = await meta.GetAsync(MetaEntity.InstanceName) ?? InstanceName; if (queue == null) { diff --git a/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs b/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs index 425b6c17..d2d7f360 100644 --- a/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs +++ b/Iceshrimp.Backend/Pages/QueueJob.cshtml.cs @@ -29,7 +29,7 @@ public class QueueJobModel(DatabaseContext db, MetaService meta) : PageModel return Redirect("/login"); Request.HttpContext.HideFooter(); - InstanceName = await meta.Get(MetaEntity.InstanceName) ?? InstanceName; + InstanceName = await meta.GetAsync(MetaEntity.InstanceName) ?? InstanceName; Job = await db.Jobs.FirstOrDefaultAsync(p => p.Id == id) ?? throw GracefulException.NotFound($"Job {id} not found"); diff --git a/Iceshrimp.Backend/Pages/Shared/RootComponent.razor b/Iceshrimp.Backend/Pages/Shared/RootComponent.razor index cb187916..091d1559 100644 --- a/Iceshrimp.Backend/Pages/Shared/RootComponent.razor +++ b/Iceshrimp.Backend/Pages/Shared/RootComponent.razor @@ -62,7 +62,7 @@ protected override async Task OnParametersSetAsync() { - _instanceName = await Meta.Get(MetaEntity.InstanceName); + _instanceName = await Meta.GetAsync(MetaEntity.InstanceName); _user = Context.GetUser(); if (Context.GetEndpoint()?.Metadata.GetMetadata() == null) diff --git a/Iceshrimp.Backend/Pages/UserPreview.razor.cs b/Iceshrimp.Backend/Pages/UserPreview.razor.cs index fd36f9e3..75ebd74f 100644 --- a/Iceshrimp.Backend/Pages/UserPreview.razor.cs +++ b/Iceshrimp.Backend/Pages/UserPreview.razor.cs @@ -31,7 +31,7 @@ public partial class UserPreview( if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown) throw new PublicPreviewDisabledException(); - _instanceName = await meta.Get(MetaEntity.InstanceName) ?? _instanceName; + _instanceName = await meta.GetAsync(MetaEntity.InstanceName) ?? _instanceName; //TODO: user banner //TODO: user note view (respect public preview settings - don't show renotes of remote notes if set to restricted or lower) diff --git a/Iceshrimp.Backend/SignalR/Helpers/StreamingConnectionAggregate.cs b/Iceshrimp.Backend/SignalR/Helpers/StreamingConnectionAggregate.cs index 9d6ecc84..2bccd01e 100644 --- a/Iceshrimp.Backend/SignalR/Helpers/StreamingConnectionAggregate.cs +++ b/Iceshrimp.Backend/SignalR/Helpers/StreamingConnectionAggregate.cs @@ -71,12 +71,12 @@ public sealed class StreamingConnectionAggregate : IDisposable if (notification.Notifier != null && IsFiltered(notification.Notifier)) return; await using var scope = GetTempScope(); - if (notification.Note != null && await IsMutedThread(notification.Note, scope, true)) + if (notification.Note != null && await IsMutedThreadAsync(notification.Note, scope, true)) return; var renderer = scope.ServiceProvider.GetRequiredService(); var rendered = await renderer.RenderOne(notification, _user); - await _hub.Clients.User(_userId).Notification(rendered); + await _hub.Clients.User(_userId).NotificationAsync(rendered); } catch (Exception e) { @@ -96,12 +96,12 @@ public sealed class StreamingConnectionAggregate : IDisposable if (data.note.Reply != null) { await using var scope = _scopeFactory.CreateAsyncScope(); - if (await IsMutedThread(data.note, scope)) + if (await IsMutedThreadAsync(data.note, scope)) return; } var rendered = EnforceRenoteReplyVisibility(await data.rendered.Value, wrapped); - await _hub.Clients.Clients(recipients.connectionIds).NotePublished(recipients.timelines, rendered); + await _hub.Clients.Clients(recipients.connectionIds).NotePublishedAsync(recipients.timelines, rendered); } catch (Exception e) { @@ -119,7 +119,7 @@ public sealed class StreamingConnectionAggregate : IDisposable if (connectionIds.Count == 0) return; var rendered = EnforceRenoteReplyVisibility(await data.rendered.Value, wrapped); - await _hub.Clients.Clients(connectionIds).NoteUpdated(rendered); + await _hub.Clients.Clients(connectionIds).NoteUpdatedAsync(rendered); } catch (Exception e) { @@ -136,7 +136,7 @@ public sealed class StreamingConnectionAggregate : IDisposable var (connectionIds, _) = FindRecipients(note); if (connectionIds.Count == 0) return; - await _hub.Clients.Clients(connectionIds).NoteDeleted(note.Id); + await _hub.Clients.Clients(connectionIds).NoteDeletedAsync(note.Id); } catch (Exception e) { @@ -170,7 +170,7 @@ public sealed class StreamingConnectionAggregate : IDisposable return res is not { Note.IsPureRenote: true, Renote: null } ? res : null; } - private async Task IsMutedThread(Note note, AsyncServiceScope scope, bool isNotification = false) + private async Task IsMutedThreadAsync(Note note, AsyncServiceScope scope, bool isNotification = false) { if (!isNotification && note.Reply == null) return false; if (!isNotification && note.User.Id == _userId) return false; @@ -266,7 +266,7 @@ public sealed class StreamingConnectionAggregate : IDisposable _eventService.UserFollowed += OnUserFollow; _eventService.UserUnfollowed += OnUserUnfollow; - await InitializeRelationships(); + await InitializeRelationshipsAsync(); _eventService.Notification += OnNotification; _streamingService.NotePublished += OnNotePublished; @@ -278,7 +278,7 @@ public sealed class StreamingConnectionAggregate : IDisposable _eventService.FilterRemoved += OnFilterRemoved; } - private async Task InitializeRelationships() + private async Task InitializeRelationshipsAsync() { await using var scope = GetTempScope(); await using var db = scope.ServiceProvider.GetRequiredService(); @@ -419,19 +419,19 @@ public sealed class StreamingConnectionAggregate : IDisposable private async void OnFilterAdded(object? _, Filter filter) { if (filter.User.Id != _userId) return; - await _hub.Clients.User(_userId).FilterAdded(FilterRenderer.RenderOne(filter)); + await _hub.Clients.User(_userId).FilterAddedAsync(FilterRenderer.RenderOne(filter)); } private async void OnFilterUpdated(object? _, Filter filter) { if (filter.User.Id != _userId) return; - await _hub.Clients.User(_userId).FilterUpdated(FilterRenderer.RenderOne(filter)); + await _hub.Clients.User(_userId).FilterUpdatedAsync(FilterRenderer.RenderOne(filter)); } private async void OnFilterRemoved(object? _, Filter filter) { if (filter.User.Id != _userId) return; - await _hub.Clients.User(_userId).FilterRemoved(filter.Id); + await _hub.Clients.User(_userId).FilterRemovedAsync(filter.Id); } #endregion diff --git a/Iceshrimp.Backend/SignalR/StreamingHub.cs b/Iceshrimp.Backend/SignalR/StreamingHub.cs index dc74cd37..ad64b9bd 100644 --- a/Iceshrimp.Backend/SignalR/StreamingHub.cs +++ b/Iceshrimp.Backend/SignalR/StreamingHub.cs @@ -8,16 +8,16 @@ namespace Iceshrimp.Backend.SignalR; [Microsoft.AspNetCore.Authorization.Authorize(Policy = "HubAuthorization")] public class StreamingHub(StreamingService streamingService) : Hub, IStreamingHubServer { - public Task Subscribe(StreamingTimeline timeline) + public Task SubscribeAsync(StreamingTimeline timeline) { var userId = Context.UserIdentifier ?? throw new Exception("UserIdentifier must not be null at this stage"); - return streamingService.Subscribe(userId, Context.ConnectionId, timeline); + return streamingService.SubscribeAsync(userId, Context.ConnectionId, timeline); } - public Task Unsubscribe(StreamingTimeline timeline) + public Task UnsubscribeAsync(StreamingTimeline timeline) { var userId = Context.UserIdentifier ?? throw new Exception("UserIdentifier must not be null at this stage"); - return streamingService.Unsubscribe(userId, Context.ConnectionId, timeline); + return streamingService.UnsubscribeAsync(userId, Context.ConnectionId, timeline); } public override async Task OnConnectedAsync() diff --git a/Iceshrimp.Backend/Startup.cs b/Iceshrimp.Backend/Startup.cs index ed9f70d6..8793454c 100644 --- a/Iceshrimp.Backend/Startup.cs +++ b/Iceshrimp.Backend/Startup.cs @@ -12,7 +12,7 @@ var builder = WebApplication.CreateBuilder(options); builder.Configuration.Sources.Clear(); builder.Configuration.AddCustomConfiguration(); -await PluginLoader.LoadPlugins(); +await PluginLoader.LoadPluginsAsync(); builder.Services .AddControllersWithOptions() @@ -47,7 +47,7 @@ builder.WebHost.UseStaticWebAssets(); PluginLoader.RunBuilderHooks(builder); var app = builder.Build(); -var config = await app.Initialize(args); +var config = await app.InitializeAsync(args); // This determines the order of middleware execution in the request pipeline #if DEBUG diff --git a/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs b/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs index decb8b00..4dc24261 100644 --- a/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs +++ b/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs @@ -1,8 +1,12 @@ using System.Text.Json; using System.Text.Json.Serialization; using Microsoft.Build.Framework; +// ReSharper disable UnusedMember.Local +// ReSharper disable CheckNamespace +// ReSharper disable ClassNeverInstantiated.Local +// ReSharper disable ConvertToAutoProperty +// ReSharper disable PropertyCanBeMadeInitOnly.Local -// ReSharper disable once CheckNamespace namespace Iceshrimp.Build.Tasks; public class RewriteStaticAssetManifest : Microsoft.Build.Utilities.Task diff --git a/Iceshrimp.Frontend/Components/Compose.razor b/Iceshrimp.Frontend/Components/Compose.razor index 25f47d86..e2a497b1 100644 --- a/Iceshrimp.Frontend/Components/Compose.razor +++ b/Iceshrimp.Frontend/Components/Compose.razor @@ -246,7 +246,7 @@ try { - await ApiService.Notes.CreateNote(NoteDraft); + await ApiService.Notes.CreateNoteAsync(NoteDraft); } catch (ApiException) { @@ -256,8 +256,8 @@ if (ReplyOrQuote != null) { - var res = await ApiService.Notes.GetNote(ReplyOrQuote.Id); - if (res != null) _ = MessageService.UpdateNote(res); + var res = await ApiService.Notes.GetNoteAsync(ReplyOrQuote.Id); + if (res != null) _ = MessageService.UpdateNoteAsync(res); } SendButton.State = StateButton.StateEnum.Success; @@ -274,7 +274,7 @@ private async Task Upload(InputFileChangeEventArgs e) { - var res = await ApiService.Drive.UploadFile(e.File); + var res = await ApiService.Drive.UploadFileAsync(e.File); Attachments.Add(res); } diff --git a/Iceshrimp.Frontend/Components/EmojiPicker.razor b/Iceshrimp.Frontend/Components/EmojiPicker.razor index c72b48d3..fca59562 100644 --- a/Iceshrimp.Frontend/Components/EmojiPicker.razor +++ b/Iceshrimp.Frontend/Components/EmojiPicker.razor @@ -41,7 +41,7 @@ protected override async Task OnInitializedAsync() { GlobalComponentSvc.EmojiPicker = this; - EmojiList = await EmojiService.GetEmoji(); + EmojiList = await EmojiService.GetEmojiAsync(); _module = (IJSInProcessObjectReference)await Js.InvokeAsync("import", "./Components/EmojiPicker.razor.js"); FilterEmojis(); diff --git a/Iceshrimp.Frontend/Components/FollowButton.razor b/Iceshrimp.Frontend/Components/FollowButton.razor index 11035d35..e5eddbf8 100644 --- a/Iceshrimp.Frontend/Components/FollowButton.razor +++ b/Iceshrimp.Frontend/Components/FollowButton.razor @@ -75,7 +75,7 @@ private async void Unfollow() { - await Api.Users.UnfollowUser(User.Id); + await Api.Users.UnfollowUserAsync(User.Id); UserProfile.Relations -= (int)Relations.Following; ChooseButton(); StateHasChanged(); @@ -83,11 +83,11 @@ private async void Follow() { - await Api.Users.FollowUser(User.Id); + await Api.Users.FollowUserAsync(User.Id); UserProfile.Relations += (int)Relations.Requested; ChooseButton(); StateHasChanged(); - UserProfile = await Api.Users.GetUserProfile(UserProfile.Id) ?? throw new Exception("How did it stop existing"); + UserProfile = await Api.Users.GetUserProfileAsync(UserProfile.Id) ?? throw new Exception("How did it stop existing"); ChooseButton(); StateHasChanged(); } diff --git a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor index 98b66d87..e3d64db3 100644 --- a/Iceshrimp.Frontend/Components/FollowRequestEntry.razor +++ b/Iceshrimp.Frontend/Components/FollowRequestEntry.razor @@ -33,26 +33,26 @@ protected override async Task OnInitializedAsync() { - var profile = await Api.Users.GetUserProfile(FollowRequest.User.Id); + var profile = await Api.Users.GetUserProfileAsync(FollowRequest.User.Id); if (profile != null) _followBack = profile.Relations.HasFlag(Relations.None); } private async void Accept() { - await Api.FollowRequests.AcceptFollowRequest(FollowRequest.Id); + await Api.FollowRequests.AcceptFollowRequestAsync(FollowRequest.Id); await OnDelete.InvokeAsync(FollowRequest.Id); } private async void AcceptAndFollowBack() { - await Api.FollowRequests.AcceptFollowRequest(FollowRequest.Id); - await Api.Users.FollowUser(FollowRequest.User.Id); + await Api.FollowRequests.AcceptFollowRequestAsync(FollowRequest.Id); + await Api.Users.FollowUserAsync(FollowRequest.User.Id); await OnDelete.InvokeAsync(FollowRequest.Id); } private async void Reject() { - await Api.FollowRequests.RejectFollowRequest(FollowRequest.Id); + await Api.FollowRequests.RejectFollowRequestAsync(FollowRequest.Id); await OnDelete.InvokeAsync(FollowRequest.Id); } } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/FollowRequestList.razor b/Iceshrimp.Frontend/Components/FollowRequestList.razor index fa26014e..647d7e8a 100644 --- a/Iceshrimp.Frontend/Components/FollowRequestList.razor +++ b/Iceshrimp.Frontend/Components/FollowRequestList.razor @@ -42,7 +42,7 @@ try { var pq = new PaginationQuery { Limit = 20 }; - FollowRequests = await Api.FollowRequests.GetFollowRequests(pq); + FollowRequests = await Api.FollowRequests.GetFollowRequestsAsync(pq); if (FollowRequests.Count == 0) { _init = LoadState.Emtpy; @@ -84,7 +84,7 @@ private async Task LoadMore() { var pq = new PaginationQuery { MaxId = _minId, Limit = 20 }; - var res = await Api.FollowRequests.GetFollowRequests(pq); + var res = await Api.FollowRequests.GetFollowRequestsAsync(pq); if (res.Count > 0) { FollowRequests.AddRange(res); diff --git a/Iceshrimp.Frontend/Components/MfmText.razor b/Iceshrimp.Frontend/Components/MfmText.razor index 304f6ec4..7787725a 100644 --- a/Iceshrimp.Frontend/Components/MfmText.razor +++ b/Iceshrimp.Frontend/Components/MfmText.razor @@ -12,7 +12,7 @@ { if (Text != null) { - TextBody = await MfmRenderer.RenderString(Text, Emoji, Simple); + TextBody = await MfmRenderer.RenderStringAsync(Text, Emoji, Simple); } } @@ -20,7 +20,7 @@ { if (Text != null) { - TextBody = await MfmRenderer.RenderString(Text, Emoji, Simple); + TextBody = await MfmRenderer.RenderStringAsync(Text, Emoji, Simple); } } } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Components/Note/Note.razor.cs b/Iceshrimp.Frontend/Components/Note/Note.razor.cs index 60afec8b..0269b771 100644 --- a/Iceshrimp.Frontend/Components/Note/Note.razor.cs +++ b/Iceshrimp.Frontend/Components/Note/Note.razor.cs @@ -48,7 +48,7 @@ public partial class Note : IDisposable Broadcast(); try { - await ApiService.Notes.ReactToNote(target.Id, name); + await ApiService.Notes.ReactToNoteAsync(target.Id, name); } catch (ApiException) { @@ -67,7 +67,7 @@ public partial class Note : IDisposable Broadcast(); try { - await ApiService.Notes.RemoveReactionFromNote(target.Id, name); + await ApiService.Notes.RemoveReactionFromNoteAsync(target.Id, name); } catch (ApiException) { @@ -79,7 +79,7 @@ public partial class Note : IDisposable private void Broadcast() { - MessageSvc.UpdateNote(NoteResponse); + MessageSvc.UpdateNoteAsync(NoteResponse); } public async Task ToggleLike() @@ -92,7 +92,7 @@ public partial class Note : IDisposable target.Liked = false; target.Likes--; Broadcast(); - await ApiService.Notes.UnlikeNote(target.Id); + await ApiService.Notes.UnlikeNoteAsync(target.Id); } catch (ApiException) { @@ -108,7 +108,7 @@ public partial class Note : IDisposable target.Liked = true; target.Likes++; Broadcast(); - await ApiService.Notes.LikeNote(target.Id); + await ApiService.Notes.LikeNoteAsync(target.Id); } catch (ApiException) { @@ -143,7 +143,7 @@ public partial class Note : IDisposable Broadcast(); try { - await ApiService.Notes.RenoteNote(target.Id, visibility); + await ApiService.Notes.RenoteNoteAsync(target.Id, visibility); } catch (ApiException) { @@ -162,18 +162,18 @@ public partial class Note : IDisposable public async void Redraft() { - await ApiService.Notes.DeleteNote(NoteResponse.Id); + await ApiService.Notes.DeleteNoteAsync(NoteResponse.Id); ComposeService.ComposeDialog?.OpenDialogRedraft(NoteResponse); } public async void Bite() { - await ApiService.Notes.BiteNote(NoteResponse.Id); + await ApiService.Notes.BiteNoteAsync(NoteResponse.Id); } public async void Mute() { - await ApiService.Notes.MuteNote(NoteResponse.Id); + await ApiService.Notes.MuteNoteAsync(NoteResponse.Id); } private void Rerender() @@ -190,8 +190,8 @@ public partial class Note : IDisposable public async Task Delete() { - await ApiService.Notes.DeleteNote(NoteResponse.Id); - await MessageSvc.DeleteNote(NoteResponse); + await ApiService.Notes.DeleteNoteAsync(NoteResponse.Id); + await MessageSvc.DeleteNoteAsync(NoteResponse); } private void ShowNote() @@ -204,4 +204,4 @@ public partial class Note : IDisposable { _noteChangedHandler.Dispose(); } -} \ No newline at end of file +} diff --git a/Iceshrimp.Frontend/Components/NoteLikeDetails.razor b/Iceshrimp.Frontend/Components/NoteLikeDetails.razor index d4096f8e..315f0573 100644 --- a/Iceshrimp.Frontend/Components/NoteLikeDetails.razor +++ b/Iceshrimp.Frontend/Components/NoteLikeDetails.razor @@ -46,7 +46,7 @@ try { var pq = new PaginationQuery { Limit = 20 }; - var res = await Api.Notes.GetNoteLikes(NoteId, pq); + var res = await Api.Notes.GetNoteLikesAsync(NoteId, pq); if (res is null) { State = State.NotFound; @@ -69,7 +69,7 @@ { if (data.Next is null) return null; var pq = new PaginationQuery { MaxId = data.Next?.Split('=')[1], Limit = 20 }; - var res = await Api.Notes.GetNoteLikes(NoteId, pq); + var res = await Api.Notes.GetNoteLikesAsync(NoteId, pq); return res; } diff --git a/Iceshrimp.Frontend/Components/NoteQuoteDetails.razor b/Iceshrimp.Frontend/Components/NoteQuoteDetails.razor index be2635ff..d3832103 100644 --- a/Iceshrimp.Frontend/Components/NoteQuoteDetails.razor +++ b/Iceshrimp.Frontend/Components/NoteQuoteDetails.razor @@ -34,7 +34,7 @@ { try { - var res = await Api.Notes.GetQuotes(NoteId, new PaginationQuery { Limit = 20 }); + var res = await Api.Notes.GetQuotesAsync(NoteId, new PaginationQuery { Limit = 20 }); if (res is null) { State = State.NotFound; @@ -58,7 +58,7 @@ { if (data.Next is null) return null; var pq = new PaginationQuery { MaxId = data.Next?.Split('=')[1], Limit = 20 }; - var res = await Api.Notes.GetQuotes(NoteId, pq); + var res = await Api.Notes.GetQuotesAsync(NoteId, pq); return res; } diff --git a/Iceshrimp.Frontend/Components/NoteRenoteDetails.razor b/Iceshrimp.Frontend/Components/NoteRenoteDetails.razor index aa2511c0..ce61c939 100644 --- a/Iceshrimp.Frontend/Components/NoteRenoteDetails.razor +++ b/Iceshrimp.Frontend/Components/NoteRenoteDetails.razor @@ -46,7 +46,7 @@ try { var pq = new PaginationQuery { Limit = 20 }; - var res = await Api.Notes.GetRenotes(NoteId, pq); + var res = await Api.Notes.GetRenotesAsync(NoteId, pq); if (res is null) { State = State.NotFound; @@ -70,7 +70,7 @@ { if (data.Next is null) return null; var pq = new PaginationQuery { MaxId = data.Next?.Split('=')[1], Limit = 20 }; - var res = await Api.Notes.GetRenotes(NoteId, pq); + var res = await Api.Notes.GetRenotesAsync(NoteId, pq); return res; } diff --git a/Iceshrimp.Frontend/Components/NotificationList.razor.cs b/Iceshrimp.Frontend/Components/NotificationList.razor.cs index d5282004..e3456c28 100644 --- a/Iceshrimp.Frontend/Components/NotificationList.razor.cs +++ b/Iceshrimp.Frontend/Components/NotificationList.razor.cs @@ -25,7 +25,7 @@ public partial class NotificationList : IAsyncDisposable { try { - var res = await Api.Notifications.GetNotifications(new PaginationQuery()); + var res = await Api.Notifications.GetNotificationsAsync(new PaginationQuery()); if (res.Count > 0) { Notifications = res; @@ -43,7 +43,7 @@ public partial class NotificationList : IAsyncDisposable private async Task LoadMore() { var pq = new PaginationQuery { MaxId = _minId, Limit = 20 }; - var res = await Api.Notifications.GetNotifications(pq); + var res = await Api.Notifications.GetNotificationsAsync(pq); if (res.Count > 0) { Notifications.AddRange(res); @@ -55,7 +55,7 @@ public partial class NotificationList : IAsyncDisposable protected override async Task OnInitializedAsync() { StreamingService.Notification += OnNotification; - await StreamingService.Connect(); + await StreamingService.ConnectAsync(); await GetNotifications(); StateHasChanged(); } diff --git a/Iceshrimp.Frontend/Components/ReactionDetails.razor b/Iceshrimp.Frontend/Components/ReactionDetails.razor index 2dc3984b..87a46238 100644 --- a/Iceshrimp.Frontend/Components/ReactionDetails.razor +++ b/Iceshrimp.Frontend/Components/ReactionDetails.razor @@ -32,7 +32,7 @@ try { State = State.Loading; - ReactedBy = await Api.Notes.GetNoteReactions(NoteId, Reaction.Name); + ReactedBy = await Api.Notes.GetNoteReactionsAsync(NoteId, Reaction.Name); State = State.Loaded; } catch (ApiException e) diff --git a/Iceshrimp.Frontend/Components/RecursiveNote.razor b/Iceshrimp.Frontend/Components/RecursiveNote.razor index 6382ae2a..d1e27910 100644 --- a/Iceshrimp.Frontend/Components/RecursiveNote.razor +++ b/Iceshrimp.Frontend/Components/RecursiveNote.razor @@ -97,7 +97,7 @@ { if (Depth < MaxDepth) { - var res = await Api.Notes.GetNoteDescendants(Note.Id, MaxDepth - Depth); + var res = await Api.Notes.GetNoteDescendantsAsync(Note.Id, MaxDepth - Depth); Note.Descendants = res; StateHasChanged(); } diff --git a/Iceshrimp.Frontend/Components/SearchComponent.razor b/Iceshrimp.Frontend/Components/SearchComponent.razor index 38221ce9..3661fd05 100644 --- a/Iceshrimp.Frontend/Components/SearchComponent.razor +++ b/Iceshrimp.Frontend/Components/SearchComponent.razor @@ -104,10 +104,10 @@ StateHasChanged(); try { - var lookup = await Api.Search.Lookup(SearchString); + var lookup = await Api.Search.LookupAsync(SearchString); if (lookup is not null && lookup.TargetUrl.Contains("user")) { - var user = await Api.Users.GetUser(lookup.TargetUrl.Split("users/")[1]); + var user = await Api.Users.GetUserAsync(lookup.TargetUrl.Split("users/")[1]); if (user is not null) { var username = $"@{user.Username}"; @@ -124,7 +124,7 @@ { if (SearchType == SearchTypeEnum.Note) { - var searchRes = await Api.Search.SearchNotes(SearchString, new PaginationQuery { Limit = 20 }); + var searchRes = await Api.Search.SearchNotesAsync(SearchString, new PaginationQuery { Limit = 20 }); if (searchRes.Count > 0) { NoteSearchInstance = new NoteSearch(searchString: SearchString, api: Api, noteResponses: searchRes); @@ -135,7 +135,7 @@ if (SearchType == SearchTypeEnum.User) { - var searchRes = await Api.Search.SearchUsers(SearchString, new PaginationQuery() { Limit = 20 }); + var searchRes = await Api.Search.SearchUsersAsync(SearchString, new PaginationQuery() { Limit = 20 }); if (searchRes.Count > 0) { UserSearchInstance = new UserSearch(searchString: SearchString, api: Api, userResponses: searchRes); @@ -196,7 +196,7 @@ public async Task FetchOlder() { var pq = new PaginationQuery { Limit = 15, MaxId = MinId }; - var res = await Api.Search.SearchUsers(SearchString, pq); + var res = await Api.Search.SearchUsersAsync(SearchString, pq); switch (res.Count) { case > 0: @@ -223,7 +223,7 @@ public async Task FetchOlder() { var pq = new PaginationQuery { Limit = 15, MaxId = MinId }; - var res = await Api.Search.SearchNotes(SearchString, pq); + var res = await Api.Search.SearchNotesAsync(SearchString, pq); switch (res.Count) { case > 0: diff --git a/Iceshrimp.Frontend/Components/TimelineComponent.razor.cs b/Iceshrimp.Frontend/Components/TimelineComponent.razor.cs index d8e99656..18c05fa9 100644 --- a/Iceshrimp.Frontend/Components/TimelineComponent.razor.cs +++ b/Iceshrimp.Frontend/Components/TimelineComponent.razor.cs @@ -29,7 +29,7 @@ public partial class TimelineComponent : IAsyncDisposable private async Task Initialize() { var pq = new PaginationQuery { Limit = 30 }; - var res = await ApiService.Timelines.GetHomeTimeline(pq); + var res = await ApiService.Timelines.GetHomeTimelineAsync(pq); if (res.Count < 1) { return false; @@ -49,7 +49,7 @@ public partial class TimelineComponent : IAsyncDisposable if (LockFetch) return true; LockFetch = true; var pq = new PaginationQuery { Limit = 15, MaxId = State.MinId }; - var res = await ApiService.Timelines.GetHomeTimeline(pq); + var res = await ApiService.Timelines.GetHomeTimelineAsync(pq); switch (res.Count) { case > 0: @@ -77,7 +77,7 @@ public partial class TimelineComponent : IAsyncDisposable if (LockFetch) return; LockFetch = true; var pq = new PaginationQuery { Limit = 15, MinId = State.MaxId }; - var res = await ApiService.Timelines.GetHomeTimeline(pq); + var res = await ApiService.Timelines.GetHomeTimelineAsync(pq); if (res.Count > 0) { State.MaxId = res.Last().Id; @@ -112,7 +112,7 @@ public partial class TimelineComponent : IAsyncDisposable protected override async Task OnInitializedAsync() { StreamingService.NotePublished += OnNotePublished; - await StreamingService.Connect(); + await StreamingService.ConnectAsync(); } protected override async Task OnAfterRenderAsync(bool firstRender) diff --git a/Iceshrimp.Frontend/Components/UserProfileCard.razor b/Iceshrimp.Frontend/Components/UserProfileCard.razor index 50fb2e76..c64197ad 100644 --- a/Iceshrimp.Frontend/Components/UserProfileCard.razor +++ b/Iceshrimp.Frontend/Components/UserProfileCard.razor @@ -63,7 +63,7 @@ protected override async Task OnInitializedAsync() { - UserProfile = await Api.Users.GetUserProfile(User.Id); + UserProfile = await Api.Users.GetUserProfileAsync(User.Id); } private void Open() diff --git a/Iceshrimp.Frontend/Components/VirtualScroller.razor.cs b/Iceshrimp.Frontend/Components/VirtualScroller.razor.cs index 42b1ed42..baf1c6e2 100644 --- a/Iceshrimp.Frontend/Components/VirtualScroller.razor.cs +++ b/Iceshrimp.Frontend/Components/VirtualScroller.razor.cs @@ -245,6 +245,7 @@ public partial class VirtualScroller : IAsyncDisposable StateHasChanged(); } + // ReSharper disable once InconsistentNaming private ValueTask LocationChangeHandler(LocationChangingContext arg) { SaveState(); diff --git a/Iceshrimp.Frontend/Core/ControllerModels/AdminControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/AdminControllerModel.cs index c0dd3306..5a1663a5 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/AdminControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/AdminControllerModel.cs @@ -5,8 +5,8 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class AdminControllerModel(ApiClient api) { - public Task GenerateInvite() => - api.Call(HttpMethod.Post, "/invites/generate"); + public Task GenerateInviteAsync() => + api.CallAsync(HttpMethod.Post, "/invites/generate"); //TODO: ActivityStreams debug endpoints //TODO: other endpoints diff --git a/Iceshrimp.Frontend/Core/ControllerModels/AuthControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/AuthControllerModel.cs index 4461a45a..5e32e1c2 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/AuthControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/AuthControllerModel.cs @@ -5,15 +5,15 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class AuthControllerModel(ApiClient api) { - public Task GetAuthStatus() => - api.Call(HttpMethod.Get, "/auth"); + public Task GetAuthStatusAsync() => + api.CallAsync(HttpMethod.Get, "/auth"); - public Task Login(AuthRequest request) => - api.Call(HttpMethod.Post, "/auth/login", data: request); + public Task LoginAsync(AuthRequest request) => + api.CallAsync(HttpMethod.Post, "/auth/login", data: request); - public Task Register(RegistrationRequest request) => - api.Call(HttpMethod.Post, "/auth/register", data: request); + public Task RegisterAsync(RegistrationRequest request) => + api.CallAsync(HttpMethod.Post, "/auth/register", data: request); - public Task ChangePassword(ChangePasswordRequest request) => - api.Call(HttpMethod.Post, "/auth/change-password", data: request); + public Task ChangePasswordAsync(ChangePasswordRequest request) => + api.CallAsync(HttpMethod.Post, "/auth/change-password", data: request); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/DriveControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/DriveControllerModel.cs index 2fa5b634..2c915079 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/DriveControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/DriveControllerModel.cs @@ -6,12 +6,12 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class DriveControllerModel(ApiClient api) { - public Task UploadFile(IBrowserFile file) => - api.Call(HttpMethod.Post, "/drive", data: file); + public Task UploadFileAsync(IBrowserFile file) => + api.CallAsync(HttpMethod.Post, "/drive", data: file); - public Task GetFile(string id) => - api.CallNullable(HttpMethod.Get, $"/drive/{id}"); + public Task GetFileAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/drive/{id}"); - public Task UpdateFile(string id, UpdateDriveFileRequest request) => - api.CallNullable(HttpMethod.Patch, $"/drive/{id}", data: request); + public Task UpdateFileAsync(string id, UpdateDriveFileRequest request) => + api.CallNullableAsync(HttpMethod.Patch, $"/drive/{id}", data: request); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/EmojiControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/EmojiControllerModel.cs index b1a14d8a..61ae4591 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/EmojiControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/EmojiControllerModel.cs @@ -6,15 +6,15 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class EmojiControllerModel(ApiClient api) { - public Task> GetAllEmoji() => - api.Call>(HttpMethod.Get, "/emoji"); + public Task> GetAllEmojiAsync() => + api.CallAsync>(HttpMethod.Get, "/emoji"); - public Task UploadEmoji(IBrowserFile file) => - api.Call(HttpMethod.Post, "/emoji", data: file); + public Task UploadEmojiAsync(IBrowserFile file) => + api.CallAsync(HttpMethod.Post, "/emoji", data: file); - public Task UpdateEmoji(string id, EmojiResponse emoji) => - api.CallNullable(HttpMethod.Patch, $"/emoji/{id}", data: emoji); + public Task UpdateEmojiAsync(string id, EmojiResponse emoji) => + api.CallNullableAsync(HttpMethod.Patch, $"/emoji/{id}", data: emoji); - public Task GetEmoji(string id) => - api.CallNullable(HttpMethod.Get, $"/emoji/{id}"); + public Task GetEmojiAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/emoji/{id}"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/FilterControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/FilterControllerModel.cs index 560421f3..c720cc9f 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/FilterControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/FilterControllerModel.cs @@ -5,14 +5,14 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class FilterControllerModel(ApiClient api) { - public Task> GetFilters() => - api.Call>(HttpMethod.Get, "/filters"); + public Task> GetFiltersAsync() => + api.CallAsync>(HttpMethod.Get, "/filters"); - public Task CreateFilter(FilterRequest request) => - api.Call(HttpMethod.Post, "/filters", data: request); + public Task CreateFilterAsync(FilterRequest request) => + api.CallAsync(HttpMethod.Post, "/filters", data: request); - public Task UpdateFilter(long id, FilterRequest request) => - api.CallNullable(HttpMethod.Put, $"/filters/{id}", data: request); + public Task UpdateFilterAsync(long id, FilterRequest request) => + api.CallNullableAsync(HttpMethod.Put, $"/filters/{id}", data: request); - public Task DeleteFilter(long id) => api.CallNullable(HttpMethod.Delete, $"/filters/{id}"); + public Task DeleteFilterAsync(long id) => api.CallNullableAsync(HttpMethod.Delete, $"/filters/{id}"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/FollowRequestControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/FollowRequestControllerModel.cs index 419ada4c..d849bf7d 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/FollowRequestControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/FollowRequestControllerModel.cs @@ -6,12 +6,12 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class FollowRequestControllerModel(ApiClient api) { - public Task> GetFollowRequests(PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/follow_requests", pq); + public Task> GetFollowRequestsAsync(PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/follow_requests", pq); - public Task AcceptFollowRequest(string id) => - api.CallNullable(HttpMethod.Post, $"/follow_requests/{id}/accept"); + public Task AcceptFollowRequestAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/follow_requests/{id}/accept"); - public Task RejectFollowRequest(string id) => - api.CallNullable(HttpMethod.Post, $"/follow_requests/{id}/reject"); + public Task RejectFollowRequestAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/follow_requests/{id}/reject"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs index 404775c4..9e25f35a 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs @@ -6,6 +6,6 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class MiscControllerModel(ApiClient api) { - public Task> GetMutedThreads(PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/misc/muted_threads", pq); + public Task> GetMutedThreadsAsync(PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/misc/muted_threads", pq); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/NoteControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/NoteControllerModel.cs index 83dd7ea2..caa21dcb 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/NoteControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/NoteControllerModel.cs @@ -8,69 +8,69 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class NoteControllerModel(ApiClient api) { - public Task GetNote(string id) => - api.CallNullable(HttpMethod.Get, $"/notes/{id}"); + public Task GetNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/notes/{id}"); - public Task DeleteNote(string id) => - api.CallNullable(HttpMethod.Delete, $"/notes/{id}"); + public Task DeleteNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Delete, $"/notes/{id}"); - public Task?> GetNoteAscendants(string id, [DefaultValue(20)] [Range(1, 100)] int? limit) + public Task?> GetNoteAscendantsAsync(string id, [DefaultValue(20)] [Range(1, 100)] int? limit) { var query = new QueryString(); if (limit.HasValue) query.Add("limit", limit.Value.ToString()); - return api.CallNullable>(HttpMethod.Get, $"/notes/{id}/ascendants", query); + return api.CallNullableAsync>(HttpMethod.Get, $"/notes/{id}/ascendants", query); } - public Task?> GetNoteDescendants(string id, [DefaultValue(20)] [Range(1, 100)] int? depth) + public Task?> GetNoteDescendantsAsync(string id, [DefaultValue(20)] [Range(1, 100)] int? depth) { var query = new QueryString(); if (depth.HasValue) query.Add("depth", depth.Value.ToString()); - return api.CallNullable>(HttpMethod.Get, $"/notes/{id}/descendants", query); + return api.CallNullableAsync>(HttpMethod.Get, $"/notes/{id}/descendants", query); } - public Task?> GetNoteReactions(string id, string name) => - api.CallNullable>(HttpMethod.Get, $"/notes/{id}/reactions/{name}"); + public Task?> GetNoteReactionsAsync(string id, string name) => + api.CallNullableAsync>(HttpMethod.Get, $"/notes/{id}/reactions/{name}"); - public Task BiteNote(string id) => - api.Call(HttpMethod.Post, $"/notes/{id}/bite"); + public Task BiteNoteAsync(string id) => + api.CallAsync(HttpMethod.Post, $"/notes/{id}/bite"); - public Task LikeNote(string id) => - api.CallNullable(HttpMethod.Post, $"/notes/{id}/like"); + public Task LikeNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/like"); - public Task UnlikeNote(string id) => - api.CallNullable(HttpMethod.Post, $"/notes/{id}/unlike"); + public Task UnlikeNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/unlike"); - public Task>?> GetNoteLikes(string id, PaginationQuery pq) => - api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/likes", pq); + public Task>?> GetNoteLikesAsync(string id, PaginationQuery pq) => + api.CallNullableAsync>>(HttpMethod.Get, $"/notes/{id}/likes", pq); - public Task RenoteNote(string id, NoteVisibility? visibility = null) + public Task RenoteNoteAsync(string id, NoteVisibility? visibility = null) { var query = new QueryString(); if (visibility.HasValue) query.Add("visibility", ((int)visibility.Value).ToString().ToLowerInvariant()); - return api.CallNullable(HttpMethod.Post, $"/notes/{id}/renote", query); + return api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/renote", query); } - public Task UnrenoteNote(string id) => - api.CallNullable(HttpMethod.Post, $"/notes/{id}/unrenote"); + public Task UnrenoteNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/unrenote"); - public Task>?> GetRenotes(string id, PaginationQuery pq) => - api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/renotes", pq); + public Task>?> GetRenotesAsync(string id, PaginationQuery pq) => + api.CallNullableAsync>>(HttpMethod.Get, $"/notes/{id}/renotes", pq); - public Task>?> GetQuotes(string id, PaginationQuery pq) => - api.CallNullable>>(HttpMethod.Get, $"/notes/{id}/quotes"); + public Task>?> GetQuotesAsync(string id, PaginationQuery pq) => + api.CallNullableAsync>>(HttpMethod.Get, $"/notes/{id}/quotes"); - public Task ReactToNote(string id, string name) => - api.CallNullable(HttpMethod.Post, $"/notes/{id}/react/{name}"); + public Task ReactToNoteAsync(string id, string name) => + api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/react/{name}"); - public Task RemoveReactionFromNote(string id, string name) => - api.CallNullable(HttpMethod.Post, $"/notes/{id}/unreact/{name}"); + public Task RemoveReactionFromNoteAsync(string id, string name) => + api.CallNullableAsync(HttpMethod.Post, $"/notes/{id}/unreact/{name}"); - public Task CreateNote(NoteCreateRequest request) => - api.Call(HttpMethod.Post, "/notes", data: request); + public Task CreateNoteAsync(NoteCreateRequest request) => + api.CallAsync(HttpMethod.Post, "/notes", data: request); - public Task RefetchNote(string id) => - api.CallNullable(HttpMethod.Get, $"/notes/{id}/refetch"); + public Task RefetchNoteAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/notes/{id}/refetch"); - public Task MuteNote(string id) => - api.Call(HttpMethod.Post, $"/notes/{id}/mute"); + public Task MuteNoteAsync(string id) => + api.CallAsync(HttpMethod.Post, $"/notes/{id}/mute"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/NotificationControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/NotificationControllerModel.cs index bbc2e3b9..4a05d08d 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/NotificationControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/NotificationControllerModel.cs @@ -7,18 +7,18 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class NotificationControllerModel(ApiClient api) { [LinkPagination(20, 80)] - public Task> GetNotifications(PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/notifications", pq); + public Task> GetNotificationsAsync(PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/notifications", pq); - public Task MarkNotificationAsRead(string id) => - api.CallNullable(HttpMethod.Post, $"/notifications/{id}/read"); + public Task MarkNotificationAsReadAsync(string id) => + api.CallNullableAsync(HttpMethod.Post, $"/notifications/{id}/read"); - public Task MarkAllNotificationsAsRead() => - api.Call(HttpMethod.Post, "/notifications/read"); + public Task MarkAllNotificationsAsReadAsync() => + api.CallAsync(HttpMethod.Post, "/notifications/read"); - public Task DeleteNotification(string id) => - api.CallNullable(HttpMethod.Delete, $"/notifications/{id}"); + public Task DeleteNotificationAsync(string id) => + api.CallNullableAsync(HttpMethod.Delete, $"/notifications/{id}"); - public Task DeleteAllNotifications() => - api.Call(HttpMethod.Delete, "/notifications"); + public Task DeleteAllNotificationsAsync() => + api.CallAsync(HttpMethod.Delete, "/notifications"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/ProfileControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/ProfileControllerModel.cs index a67e3ce5..0059a5be 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/ProfileControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/ProfileControllerModel.cs @@ -5,9 +5,9 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class ProfileControllerModel(ApiClient api) { - public Task GetProfile() => - api.Call(HttpMethod.Get, "/profile"); + public Task GetProfileAsync() => + api.CallAsync(HttpMethod.Get, "/profile"); - public Task UpdateProfile(UserProfileEntity request) => - api.Call(HttpMethod.Put, "/profile", data: request); + public Task UpdateProfileAsync(UserProfileEntity request) => + api.CallAsync(HttpMethod.Put, "/profile", data: request); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/SearchControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/SearchControllerModel.cs index e184107e..d8ca179d 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/SearchControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/SearchControllerModel.cs @@ -7,13 +7,13 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class SearchControllerModel(ApiClient api) { [LinkPagination(20, 80)] - public Task> SearchNotes(string query, PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/search/notes", QueryString.Create("q", query) + pq); + public Task> SearchNotesAsync(string query, PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/search/notes", QueryString.Create("q", query) + pq); [LinkPagination(20, 80)] - public Task> SearchUsers(string query, PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/search/users", QueryString.Create("q", query) + pq); + public Task> SearchUsersAsync(string query, PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/search/users", QueryString.Create("q", query) + pq); - public Task Lookup(string target) => - api.CallNullable(HttpMethod.Get, "/search/lookup", QueryString.Create("target", target)); + public Task LookupAsync(string target) => + api.CallNullableAsync(HttpMethod.Get, "/search/lookup", QueryString.Create("target", target)); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/SettingsControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/SettingsControllerModel.cs index 425694b9..be644ab8 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/SettingsControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/SettingsControllerModel.cs @@ -5,8 +5,8 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class SettingsControllerModel(ApiClient api) { - public Task GetSettings() => api.Call(HttpMethod.Get, "/settings"); + public Task GetSettingsAsync() => api.CallAsync(HttpMethod.Get, "/settings"); - public Task UpdateSettings(UserSettingsEntity settings) => - api.CallNullable(HttpMethod.Put, "/settings", data: settings); + public Task UpdateSettingsAsync(UserSettingsEntity settings) => + api.CallNullableAsync(HttpMethod.Put, "/settings", data: settings); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/TimelineControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/TimelineControllerModel.cs index 541c8311..51de3f0f 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/TimelineControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/TimelineControllerModel.cs @@ -7,6 +7,6 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class TimelineControllerModel(ApiClient api) { [LinkPagination(20, 80)] - public Task> GetHomeTimeline(PaginationQuery pq) => - api.Call>(HttpMethod.Get, "/timelines/home", pq); + public Task> GetHomeTimelineAsync(PaginationQuery pq) => + api.CallAsync>(HttpMethod.Get, "/timelines/home", pq); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/UserControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/UserControllerModel.cs index 3ec44674..f390366b 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/UserControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/UserControllerModel.cs @@ -6,28 +6,28 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class UserControllerModel(ApiClient api) { - public Task GetUser(string id) => - api.CallNullable(HttpMethod.Get, $"/users/{id}"); + public Task GetUserAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/users/{id}"); - public Task GetUserProfile(string id) => - api.CallNullable(HttpMethod.Get, $"/users/{id}/profile"); + public Task GetUserProfileAsync(string id) => + api.CallNullableAsync(HttpMethod.Get, $"/users/{id}/profile"); [LinkPagination(20, 80)] - public Task?> GetUserNotes(string id, PaginationQuery pq) => - api.CallNullable>(HttpMethod.Get, $"/users/{id}/notes", pq); + public Task?> GetUserNotesAsync(string id, PaginationQuery pq) => + api.CallNullableAsync>(HttpMethod.Get, $"/users/{id}/notes", pq); - public Task LookupUser(string username, string? host) + public Task LookupUserAsync(string username, string? host) { var query = new QueryString(); query = query.Add("username", username); if (host != null) query = query.Add("host", host); - return api.CallNullable(HttpMethod.Get, "/users/lookup", query); + return api.CallNullableAsync(HttpMethod.Get, "/users/lookup", query); } - public Task BiteUser(string id) => - api.Call(HttpMethod.Post, $"/users/{id}/bite"); + public Task BiteUserAsync(string id) => + api.CallAsync(HttpMethod.Post, $"/users/{id}/bite"); - public Task FollowUser(string id) => api.CallNullable(HttpMethod.Post, $"/users/{id}/follow"); - public Task RemoveUserFromFollowers(string id) => api.CallNullable(HttpMethod.Post, $"/users/{id}/remove_from_followers"); - public Task UnfollowUser(string id) => api.CallNullable(HttpMethod.Post, $"/users/{id}/unfollow"); + public Task FollowUserAsync(string id) => api.CallNullableAsync(HttpMethod.Post, $"/users/{id}/follow"); + public Task RemoveUserFromFollowersAsync(string id) => api.CallNullableAsync(HttpMethod.Post, $"/users/{id}/remove_from_followers"); + public Task UnfollowUserAsync(string id) => api.CallNullableAsync(HttpMethod.Post, $"/users/{id}/unfollow"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/VersionControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/VersionControllerModel.cs index 4e0c0f34..6cab3d8a 100644 --- a/Iceshrimp.Frontend/Core/ControllerModels/VersionControllerModel.cs +++ b/Iceshrimp.Frontend/Core/ControllerModels/VersionControllerModel.cs @@ -5,6 +5,6 @@ namespace Iceshrimp.Frontend.Core.ControllerModels; internal class VersionControllerModel(ApiClient api) { - public Task GetVersion() => - api.Call(HttpMethod.Get, "/version"); + public Task GetVersionAsync() => + api.CallAsync(HttpMethod.Get, "/version"); } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs index 9c1ff556..792e7ebc 100644 --- a/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs +++ b/Iceshrimp.Frontend/Core/Miscellaneous/RenderMfm.cs @@ -8,7 +8,7 @@ namespace Iceshrimp.Frontend.Core.Miscellaneous; public static class MfmRenderer { - public static async Task RenderString(string text, List emoji, bool simple = false) + public static async Task RenderStringAsync(string text, List emoji, bool simple = false) { var res = simple ? Mfm.parseSimple(text) : Mfm.parse(text); var context = BrowsingContext.New(); diff --git a/Iceshrimp.Frontend/Core/Services/ApiClient.cs b/Iceshrimp.Frontend/Core/Services/ApiClient.cs index f197a0e1..4c032452 100644 --- a/Iceshrimp.Frontend/Core/Services/ApiClient.cs +++ b/Iceshrimp.Frontend/Core/Services/ApiClient.cs @@ -16,9 +16,9 @@ internal class ApiClient(HttpClient client) public void SetToken(string token) => _token = token; - public async Task Call(HttpMethod method, string path, QueryString? query = null, object? data = null) + public async Task CallAsync(HttpMethod method, string path, QueryString? query = null, object? data = null) { - var res = await MakeRequest(method, path, query, data); + var res = await MakeRequestAsync(method, path, query, data); if (res.IsSuccessStatusCode) return; @@ -28,11 +28,11 @@ internal class ApiClient(HttpClient client) throw new ApiException(error); } - public async Task CallNullable( + public async Task CallNullableAsync( HttpMethod method, string path, QueryString? query = null, object? data = null ) { - var res = await MakeRequest(method, path, query, data); + var res = await MakeRequestAsync(method, path, query, data); if (res.IsSuccessStatusCode) return true; @@ -42,21 +42,21 @@ internal class ApiClient(HttpClient client) throw new ApiException(error); } - public async Task Call( + public async Task CallAsync( HttpMethod method, string path, QueryString? query = null, object? data = null ) where T : class { - var res = await CallInternal(method, path, query, data); + var res = await CallInternalAsync(method, path, query, data); if (res.result != null) return res.result; throw new ApiException(res.error ?? throw new Exception("Deserialized API error was null")); } - public async Task CallNullable( + public async Task CallNullableAsync( HttpMethod method, string path, QueryString? query = null, object? data = null ) where T : class { - var res = await CallInternal(method, path, query, data); + var res = await CallInternalAsync(method, path, query, data); if (res.result != null) return res.result; @@ -67,11 +67,11 @@ internal class ApiClient(HttpClient client) throw new ApiException(err); } - private async Task<(T? result, ErrorResponse? error)> CallInternal( + private async Task<(T? result, ErrorResponse? error)> CallInternalAsync( HttpMethod method, string path, QueryString? query, object? data ) where T : class { - var res = await MakeRequest(method, path, query, data); + var res = await MakeRequestAsync(method, path, query, data); if (res.IsSuccessStatusCode) { @@ -87,7 +87,7 @@ internal class ApiClient(HttpClient client) return (null, error); } - private async Task MakeRequest( + private async Task MakeRequestAsync( HttpMethod method, string path, QueryString? query, object? data ) { diff --git a/Iceshrimp.Frontend/Core/Services/EmojiService.cs b/Iceshrimp.Frontend/Core/Services/EmojiService.cs index 5a8ffd06..31672503 100644 --- a/Iceshrimp.Frontend/Core/Services/EmojiService.cs +++ b/Iceshrimp.Frontend/Core/Services/EmojiService.cs @@ -9,12 +9,12 @@ internal class EmojiService(ApiService api) [Inject] private ApiService Api { get; set; } = api; private List? Emojis { get; set; } - public async Task> GetEmoji() + public async Task> GetEmojiAsync() { if (Emojis is not null) return Emojis; try { - var emoji = await Api.Emoji.GetAllEmoji(); + var emoji = await Api.Emoji.GetAllEmojiAsync(); Emojis = emoji; return Emojis; } diff --git a/Iceshrimp.Frontend/Core/Services/MessageService.cs b/Iceshrimp.Frontend/Core/Services/MessageService.cs index 3d241c61..db568cde 100644 --- a/Iceshrimp.Frontend/Core/Services/MessageService.cs +++ b/Iceshrimp.Frontend/Core/Services/MessageService.cs @@ -68,7 +68,7 @@ internal class MessageService } } - public Task UpdateNote(NoteResponse note) + public Task UpdateNoteAsync(NoteResponse note) { AnyNoteChanged?.Invoke(this, note); _noteChangedHandlers.TryGetValue((note.Id, Type.Updated), out var xHandler); @@ -76,7 +76,7 @@ internal class MessageService return Task.CompletedTask; } - public Task DeleteNote(NoteResponse note) + public Task DeleteNoteAsync(NoteResponse note) { AnyNoteDeleted?.Invoke(this, note); _noteChangedHandlers.TryGetValue((note.Id, Type.Deleted), out var xHandler); diff --git a/Iceshrimp.Frontend/Core/Services/StreamingService.cs b/Iceshrimp.Frontend/Core/Services/StreamingService.cs index a38c8708..8eaf3c8c 100644 --- a/Iceshrimp.Frontend/Core/Services/StreamingService.cs +++ b/Iceshrimp.Frontend/Core/Services/StreamingService.cs @@ -38,7 +38,7 @@ internal class StreamingService( public event EventHandler? FilterRemoved; public event EventHandler? OnConnectionChange; - public async Task Connect(StoredUser? user = null) + public async Task ConnectAsync(StoredUser? user = null) { if (_hubConnection != null) { @@ -64,7 +64,7 @@ internal class StreamingService( try { await _hubConnection.StartAsync(); - await _hub.Subscribe(StreamingTimeline.Home); + await _hub.SubscribeAsync(StreamingTimeline.Home); } catch (Exception e) { @@ -78,11 +78,11 @@ internal class StreamingService( options.AccessTokenProvider = () => Task.FromResult(user.Token); } - public async Task Reconnect(StoredUser? user = null) + public async Task ReconnectAsync(StoredUser? user = null) { if (_hubConnection is null) { - await Connect(user); + await ConnectAsync(user); return; } @@ -110,44 +110,44 @@ internal class StreamingService( return Task.CompletedTask; } - public Task Notification(NotificationResponse notification) + public Task NotificationAsync(NotificationResponse notification) { streaming.Notification?.Invoke(this, notification); return Task.CompletedTask; } - public Task NotePublished(List timelines, NoteResponse note) + public Task NotePublishedAsync(List timelines, NoteResponse note) { foreach (var timeline in timelines) streaming.NotePublished?.Invoke(this, (timeline, note)); return Task.CompletedTask; } - public Task NoteUpdated(NoteResponse note) + public Task NoteUpdatedAsync(NoteResponse note) { streaming.NoteUpdated?.Invoke(this, note); return Task.CompletedTask; } - public Task NoteDeleted(string noteId) + public Task NoteDeletedAsync(string noteId) { streaming.NoteDeleted?.Invoke(this, noteId); return Task.CompletedTask; } - public Task FilterAdded(FilterResponse filter) + public Task FilterAddedAsync(FilterResponse filter) { streaming.FilterAdded?.Invoke(this, filter); return Task.CompletedTask; } - public Task FilterUpdated(FilterResponse filter) + public Task FilterUpdatedAsync(FilterResponse filter) { streaming.FilterUpdated?.Invoke(this, filter); return Task.CompletedTask; } - public Task FilterRemoved(long filterId) + public Task FilterRemovedAsync(long filterId) { streaming.FilterRemoved?.Invoke(this, filterId); return Task.CompletedTask; diff --git a/Iceshrimp.Frontend/Core/Services/UpdateService.cs b/Iceshrimp.Frontend/Core/Services/UpdateService.cs index b838c638..f9a8503a 100644 --- a/Iceshrimp.Frontend/Core/Services/UpdateService.cs +++ b/Iceshrimp.Frontend/Core/Services/UpdateService.cs @@ -34,11 +34,11 @@ internal class UpdateService "import", "./Core/Services/UpdateService.cs.js") .AsTask()); - Timer = new Timer(Callback, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); - _ = RegisterUpdateCallback(); + Timer = new Timer(CallbackAsync, null, TimeSpan.Zero, TimeSpan.FromSeconds(60)); + _ = RegisterUpdateCallbackAsync(); } - private async Task RegisterUpdateCallback() + private async Task RegisterUpdateCallbackAsync() { var module = await _moduleTask.Value; var objRef = DotNetObjectReference.Create(this); @@ -55,34 +55,34 @@ internal class UpdateService _globalComponentSvc.BannerComponent?.AddBanner(banner); } - public async Task ServiceWorkerCheckWaiting() + public async Task ServiceWorkerCheckWaitingAsync() { var module = await _moduleTask.Value; return await module.InvokeAsync("ServiceWorkerCheckWaiting"); } - public async Task ServiceWorkerUpdate() + public async Task ServiceWorkerUpdateAsync() { var module = await _moduleTask.Value; await module.InvokeVoidAsync("ServiceWorkerUpdate"); } - public async Task ServiceWorkerSkipWaiting() + public async Task ServiceWorkerSkipWaitingAsync() { var module = await _moduleTask.Value; return await module.InvokeAsync("ServiceWorkerSkipWaiting"); } - private async void Callback(object? _) + private async void CallbackAsync(object? _) { - await CheckVersion(); + await CheckVersionAsync(); } - private async Task GetVersion() + private async Task GetVersionAsync() { try { - var backendVersion = await _api.Version.GetVersion(); + var backendVersion = await _api.Version.GetVersionAsync(); _logger.LogInformation("Successfully fetched backend version."); return backendVersion; } @@ -93,14 +93,14 @@ internal class UpdateService } } - private async Task CheckVersion() + private async Task CheckVersionAsync() { - var version = await GetVersion(); + var version = await GetVersionAsync(); if (version is null) return; BackendVersion = version; if (version.Version != FrontendVersion.Version) { - await ServiceWorkerUpdate(); + await ServiceWorkerUpdateAsync(); } } } \ No newline at end of file diff --git a/Iceshrimp.Frontend/Pages/Login.razor b/Iceshrimp.Frontend/Pages/Login.razor index fe685e6f..172f9372 100644 --- a/Iceshrimp.Frontend/Pages/Login.razor +++ b/Iceshrimp.Frontend/Pages/Login.razor @@ -56,7 +56,7 @@ return; } - var res = await Api.Auth.Login(new AuthRequest { Username = Username, Password = Password }); + var res = await Api.Auth.LoginAsync(new AuthRequest { Username = Username, Password = Password }); switch (res.Status) { case AuthStatusEnum.Authenticated: diff --git a/Iceshrimp.Frontend/Pages/ProfileView.razor b/Iceshrimp.Frontend/Pages/ProfileView.razor index c8f3c472..b46f2b96 100644 --- a/Iceshrimp.Frontend/Pages/ProfileView.razor +++ b/Iceshrimp.Frontend/Pages/ProfileView.razor @@ -90,7 +90,7 @@ private async Task GetNotes(string? minId) { var pq = new PaginationQuery { Limit = 10, MaxId = minId }; - var notes = await Api.Users.GetUserNotes(UserResponse.Id, pq); + var notes = await Api.Users.GetUserNotesAsync(UserResponse.Id, pq); if (notes is not null && notes.Count > 0) { MinId = notes.Last().Id; @@ -121,7 +121,7 @@ { var pattern = "^@(.[^@]+)@?(.+)?$"; var matches = Regex.Match(User, pattern); - var userResponse = await Api.Users.LookupUser(matches.Groups[1].Value, matches.Groups[2].Value); + var userResponse = await Api.Users.LookupUserAsync(matches.Groups[1].Value, matches.Groups[2].Value); if (userResponse is null) { _notFound = true; @@ -129,7 +129,7 @@ else { UserResponse = userResponse; - Profile = await Api.Users.GetUserProfile(UserResponse.Id); + Profile = await Api.Users.GetUserProfileAsync(UserResponse.Id); await GetNotes(null); _init = true; _loading = false; diff --git a/Iceshrimp.Frontend/Pages/Settings/About.razor b/Iceshrimp.Frontend/Pages/Settings/About.razor index 1946314c..c2f06fdf 100644 --- a/Iceshrimp.Frontend/Pages/Settings/About.razor +++ b/Iceshrimp.Frontend/Pages/Settings/About.razor @@ -112,7 +112,7 @@ { try { - await UpdateSvc.ServiceWorkerUpdate(); + await UpdateSvc.ServiceWorkerUpdateAsync(); } catch (Exception e) { @@ -121,7 +121,7 @@ return; } - var res = await UpdateSvc.ServiceWorkerCheckWaiting(); + var res = await UpdateSvc.ServiceWorkerCheckWaitingAsync(); _updateAvailable = res ? CheckState.True : CheckState.False; _newVersion = UpdateSvc.BackendVersion; StateHasChanged(); @@ -129,7 +129,7 @@ private async void SkipWaiting() { - var res = await UpdateSvc.ServiceWorkerSkipWaiting(); + var res = await UpdateSvc.ServiceWorkerSkipWaitingAsync(); _skipWaitingRes = res ? CheckState.True : CheckState.Error; if (res) { diff --git a/Iceshrimp.Frontend/Pages/Settings/Filters.razor b/Iceshrimp.Frontend/Pages/Settings/Filters.razor index c290e6b3..480c9f8f 100644 --- a/Iceshrimp.Frontend/Pages/Settings/Filters.razor +++ b/Iceshrimp.Frontend/Pages/Settings/Filters.razor @@ -200,7 +200,7 @@ { try { - FilterList = (List)await Api.Filters.GetFilters(); + FilterList = (List)await Api.Filters.GetFiltersAsync(); State = State.Loaded; } catch (ApiException) @@ -213,7 +213,7 @@ { try { - if (await Api.Filters.DeleteFilter(id)) + if (await Api.Filters.DeleteFilterAsync(id)) { var index = FilterList.FindIndex(p => p.Id == id); FilterList.RemoveAt(index); @@ -267,7 +267,7 @@ }; try { - var filter = await Api.Filters.CreateFilter(newFilterRequest); + var filter = await Api.Filters.CreateFilterAsync(newFilterRequest); FilterList.Add(filter); } catch (ApiException) { } diff --git a/Iceshrimp.Frontend/Pages/Settings/Profile.razor b/Iceshrimp.Frontend/Pages/Settings/Profile.razor index 2fee2480..acdce6a6 100644 --- a/Iceshrimp.Frontend/Pages/Settings/Profile.razor +++ b/Iceshrimp.Frontend/Pages/Settings/Profile.razor @@ -83,7 +83,7 @@ { try { - UserProfile = await Api.Profile.GetProfile(); + UserProfile = await Api.Profile.GetProfileAsync(); State = State.Loaded; } catch (ApiException e) @@ -110,7 +110,7 @@ try { SaveButton.State = StateButton.StateEnum.Loading; - await Api.Profile.UpdateProfile(UserProfile); + await Api.Profile.UpdateProfileAsync(UserProfile); SaveButton.State = StateButton.StateEnum.Success; } catch (ApiException e) diff --git a/Iceshrimp.Frontend/Pages/SingleNote.razor b/Iceshrimp.Frontend/Pages/SingleNote.razor index f0f7ea5d..d8452668 100644 --- a/Iceshrimp.Frontend/Pages/SingleNote.razor +++ b/Iceshrimp.Frontend/Pages/SingleNote.razor @@ -149,9 +149,9 @@ try { - var rootNoteTask = ApiService.Notes.GetNote(NoteId); - var descendantsTask = ApiService.Notes.GetNoteDescendants(NoteId, _depth); - var ascendantsTask = ApiService.Notes.GetNoteAscendants(NoteId, default); + var rootNoteTask = ApiService.Notes.GetNoteAsync(NoteId); + var descendantsTask = ApiService.Notes.GetNoteDescendantsAsync(NoteId, _depth); + var ascendantsTask = ApiService.Notes.GetNoteAscendantsAsync(NoteId, default); RootNote = await rootNoteTask; Descendants = await descendantsTask; Ascendants = await ascendantsTask; @@ -219,11 +219,12 @@ private async Task Refresh() { if (NoteId == null) throw new InvalidOperationException("RefreshNote called under impossible circumstances"); - Descendants = await ApiService.Notes.GetNoteDescendants(NoteId, default); - Ascendants = await ApiService.Notes.GetNoteAscendants(NoteId, default); + Descendants = await ApiService.Notes.GetNoteDescendantsAsync(NoteId, default); + Ascendants = await ApiService.Notes.GetNoteAscendantsAsync(NoteId, default); StateHasChanged(); } + // ReSharper disable once InconsistentNaming private ValueTask LocationChangeHandler(LocationChangingContext arg) { SaveState(); diff --git a/Iceshrimp.Shared/Schemas/SignalR/StreamingHub.cs b/Iceshrimp.Shared/Schemas/SignalR/StreamingHub.cs index 68912502..20fb6a7d 100644 --- a/Iceshrimp.Shared/Schemas/SignalR/StreamingHub.cs +++ b/Iceshrimp.Shared/Schemas/SignalR/StreamingHub.cs @@ -4,20 +4,20 @@ namespace Iceshrimp.Shared.Schemas.SignalR; public interface IStreamingHubServer { - public Task Subscribe(StreamingTimeline timeline); - public Task Unsubscribe(StreamingTimeline timeline); + public Task SubscribeAsync(StreamingTimeline timeline); + public Task UnsubscribeAsync(StreamingTimeline timeline); } public interface IStreamingHubClient { - public Task Notification(NotificationResponse notification); - public Task NotePublished(List timelines, NoteResponse note); - public Task NoteUpdated(NoteResponse note); - public Task NoteDeleted(string noteId); + public Task NotificationAsync(NotificationResponse notification); + public Task NotePublishedAsync(List timelines, NoteResponse note); + public Task NoteUpdatedAsync(NoteResponse note); + public Task NoteDeletedAsync(string noteId); - public Task FilterAdded(FilterResponse filter); - public Task FilterUpdated(FilterResponse filter); - public Task FilterRemoved(long filterId); + public Task FilterAddedAsync(FilterResponse filter); + public Task FilterUpdatedAsync(FilterResponse filter); + public Task FilterRemovedAsync(long filterId); } public enum StreamingTimeline