diff --git a/Iceshrimp.Backend/Core/Extensions/GuidExtensions.cs b/Iceshrimp.Backend/Core/Extensions/GuidExtensions.cs new file mode 100644 index 00000000..c2d1f79a --- /dev/null +++ b/Iceshrimp.Backend/Core/Extensions/GuidExtensions.cs @@ -0,0 +1,6 @@ +namespace Iceshrimp.Backend.Core.Extensions; + +public static class GuidExtensions +{ + public static string ToStringLower(this Guid guid) => guid.ToString().ToLowerInvariant(); +} \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs index eade9ffe..4e94a7b3 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityRenderer.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database.Tables; +using Iceshrimp.Backend.Core.Extensions; using Iceshrimp.Backend.Core.Federation.ActivityStreams.Types; using Iceshrimp.Backend.Core.Middleware; using Microsoft.Extensions.Options; @@ -14,7 +15,7 @@ public class ActivityRenderer( ) { private string GenerateActivityId() => - $"https://{config.Value.WebDomain}/activities/ephemeral/{Guid.NewGuid().ToString().ToLowerInvariant()}"; + $"https://{config.Value.WebDomain}/activities/ephemeral/{Guid.NewGuid().ToStringLower()}"; public static ASCreate RenderCreate(ASNote obj, ASObject actor) => new() { diff --git a/Iceshrimp.Backend/Core/Queues/InboxQueue.cs b/Iceshrimp.Backend/Core/Queues/InboxQueue.cs index c67df6ca..dc985952 100644 --- a/Iceshrimp.Backend/Core/Queues/InboxQueue.cs +++ b/Iceshrimp.Backend/Core/Queues/InboxQueue.cs @@ -1,4 +1,5 @@ using Iceshrimp.Backend.Core.Database.Tables; +using Iceshrimp.Backend.Core.Extensions; using Iceshrimp.Backend.Core.Federation.ActivityStreams; using Iceshrimp.Backend.Core.Federation.ActivityStreams.Types; using Iceshrimp.Backend.Core.Middleware; @@ -19,7 +20,7 @@ public class InboxQueue() : PostgresJobQueue("inbox", InboxQueuePr ) { var logger = scope.GetRequiredService>(); - logger.LogDebug("Processing inbox job {id}", job.Id.ToString().ToLowerInvariant()); + logger.LogDebug("Processing inbox job {id}", job.Id.ToStringLower()); var expanded = LdHelpers.Expand(JToken.Parse(jobData.Body)) ?? throw new Exception("Failed to expand ASObject"); var obj = ASObject.Deserialize(expanded) ?? throw new Exception("Failed to deserialize ASObject"); if (obj is not ASActivity activity) diff --git a/Iceshrimp.Backend/Core/Services/DriveService.cs b/Iceshrimp.Backend/Core/Services/DriveService.cs index b8b7d964..ca33131d 100644 --- a/Iceshrimp.Backend/Core/Services/DriveService.cs +++ b/Iceshrimp.Backend/Core/Services/DriveService.cs @@ -3,6 +3,7 @@ using Blurhash.ImageSharp; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Database.Tables; +using Iceshrimp.Backend.Core.Extensions; using Iceshrimp.Backend.Core.Federation.Cryptography; using Iceshrimp.Backend.Core.Helpers; using Iceshrimp.Backend.Core.Middleware; @@ -318,14 +319,14 @@ public class DriveService( private static string GenerateFilenameKeepingExtension(string filename) { - var guid = Guid.NewGuid().ToString().ToLowerInvariant(); + var guid = Guid.NewGuid().ToStringLower(); var ext = Path.GetExtension(filename); return guid + ext; } private static string GenerateWebpFilename(string prefix = "") { - var guid = Guid.NewGuid().ToString().ToLowerInvariant(); + var guid = Guid.NewGuid().ToStringLower(); return $"{prefix}{guid}.webp"; } @@ -340,7 +341,7 @@ public class DriveService( public class DriveFileCreationRequest { public string? Comment; - public required string Filename = Guid.NewGuid().ToString().ToLowerInvariant(); + public required string Filename = Guid.NewGuid().ToStringLower(); public required bool IsSensitive; public required string MimeType; public Dictionary? RequestHeaders; diff --git a/Iceshrimp.Backend/Core/Services/QueueService.cs b/Iceshrimp.Backend/Core/Services/QueueService.cs index 02b8aaeb..7b2a9b01 100644 --- a/Iceshrimp.Backend/Core/Services/QueueService.cs +++ b/Iceshrimp.Backend/Core/Services/QueueService.cs @@ -436,12 +436,13 @@ public class PostgresJobQueue( var queueName = data is BackgroundTaskJobData ? name + $" ({data.GetType().Name})" : name; if (e is GracefulException { Details: not null } ce) { - logger.LogError("Failed to process job in {queue} queue: {error} - {details}", - queueName, ce.Message, ce.Details); + logger.LogError("Failed to process job {id} in {queue} queue: {error} - {details}", + queueName, job.Id.ToStringLower(), ce.Message, ce.Details); } else { - logger.LogError(e, "Failed to process job in {queue} queue:", queueName); + logger.LogError(e, "Failed to process job {id} in {queue} queue:", job.Id.ToStringLower(), + queueName); } }