[backend/core] Fix ArrayTypeMismatchException in APMentionsResolver

This commit is contained in:
Laura Hausmann 2024-12-07 04:10:22 +01:00
parent 5dee8bc783
commit b160a97f0e
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices;
using CommunityToolkit.HighPerformance;
using Iceshrimp.Backend.Core.Configuration;
using Iceshrimp.Backend.Core.Database.Tables;
@ -45,6 +46,26 @@ public class MentionsResolver(IOptions<Config.InstanceSection> config) : ISingle
}
}
[OverloadResolutionPriority(1)]
private void ResolveMentions(
Span<IMfmInlineNode> nodes, string? host,
List<Note.MentionedUser> mentionCache,
SplitDomainMapping splitDomainMapping
)
{
for (var i = 0; i < nodes.Length; i++)
{
var node = nodes[i];
if (node is not MfmMentionNode mention)
{
ResolveMentions(node.Children, host, mentionCache, splitDomainMapping);
continue;
}
nodes[i] = ResolveMention(mention, host, mentionCache, splitDomainMapping);
}
}
private IMfmInlineNode ResolveMention(
MfmMentionNode node, string? host,
IEnumerable<Note.MentionedUser> mentionCache,