[backend/core] Fix runtime ArrayTypeMismatchException in EmojiService

This commit is contained in:
Laura Hausmann 2024-12-15 01:09:06 +01:00
parent b8ba778842
commit ce646e84d9
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using AsyncKeyedLock;
using Iceshrimp.Backend.Core.Configuration;
@ -71,8 +72,8 @@ public partial class EmojiService(
{
var user = await sysUserSvc.GetInstanceActorAsync();
var driveFile = await driveSvc.StoreFileAsync(existing.OriginalUrl, user, false, forceStore: true,
skipImageProcessing: false) ??
throw new Exception("Error storing emoji file");
skipImageProcessing: false)
?? throw new Exception("Error storing emoji file");
var emoji = new Emoji
{
@ -206,6 +207,19 @@ public partial class EmojiService(
}
}
[OverloadResolutionPriority(1)]
private static void ResolveChildren(
Span<IMfmInlineNode> nodes, ref List<MfmEmojiCodeNode> list
)
{
foreach (var node in nodes)
{
if (node is MfmEmojiCodeNode emojiNode) list.Add(emojiNode);
list.AddRange(node.Children.OfType<MfmEmojiCodeNode>());
ResolveChildren(node.Children, ref list);
}
}
public async Task<Emoji?> UpdateLocalEmojiAsync(
string id, string? name, List<string>? aliases, string? category, string? license, bool? sensitive
)
@ -245,4 +259,4 @@ public partial class EmojiService(
[GeneratedRegex(@"^:?([\w+-]+)@([a-zA-Z0-9._\-]+\.[a-zA-Z0-9._\-]+):?$", RegexOptions.Compiled)]
private static partial Regex RemoteCustomEmojiRegex { get; }
}
}