[backend/libmfm] Fix broken rendering of mentions of local users in some circumstances (ISH-567)
This was caused because of an inconsistency of whether to set the account domain as a fallback value or not. Therefore, invocations with the mentioned local user host not having a fallback value would cause broken mention rendering, e.g. in bios/profile fields.
This commit is contained in:
parent
e61e3d2fde
commit
525bd02022
1 changed files with 8 additions and 4 deletions
|
@ -193,7 +193,7 @@ public class MfmConverter(IOptions<Config.InstanceSection> config)
|
||||||
var punyHost = host?.ToPunycodeLower();
|
var punyHost = host?.ToPunycodeLower();
|
||||||
if (emoji?.FirstOrDefault(p => p.Name == emojiCodeNode.Name && p.Host == punyHost) is { } hit)
|
if (emoji?.FirstOrDefault(p => p.Name == emojiCodeNode.Name && p.Host == punyHost) is { } hit)
|
||||||
{
|
{
|
||||||
var el = document.CreateElement("span");
|
var el = document.CreateElement("span");
|
||||||
var inner = document.CreateElement("img");
|
var inner = document.CreateElement("img");
|
||||||
inner.SetAttribute("src", hit.PublicUrl);
|
inner.SetAttribute("src", hit.PublicUrl);
|
||||||
el.AppendChild(inner);
|
el.AppendChild(inner);
|
||||||
|
@ -246,9 +246,13 @@ public class MfmConverter(IOptions<Config.InstanceSection> config)
|
||||||
if (finalHost == config.Value.WebDomain)
|
if (finalHost == config.Value.WebDomain)
|
||||||
finalHost = config.Value.AccountDomain;
|
finalHost = config.Value.AccountDomain;
|
||||||
|
|
||||||
var mention = mentions.FirstOrDefault(p => p.Username.EqualsIgnoreCase(mentionNode.Username) &&
|
Func<Note.MentionedUser, bool> predicate = finalHost == config.Value.AccountDomain
|
||||||
p.Host.EqualsIgnoreCase(finalHost));
|
? p => p.Username.EqualsIgnoreCase(mentionNode.Username) &&
|
||||||
if (mention == null)
|
(p.Host.EqualsIgnoreCase(finalHost) || p.Host == null)
|
||||||
|
: p => p.Username.EqualsIgnoreCase(mentionNode.Username) &&
|
||||||
|
p.Host.EqualsIgnoreCase(finalHost);
|
||||||
|
|
||||||
|
if (mentions.FirstOrDefault(predicate) is not { } mention)
|
||||||
{
|
{
|
||||||
el.TextContent = $"@{mentionNode.Acct}";
|
el.TextContent = $"@{mentionNode.Acct}";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue