Personas a remote post is addressed to see it, named or not
A remote post decided who here may see it by its Mention tags alone. A followers-only post addressed in to or cc to a persona without naming it (Akkoma's to[], or a GoToSocial edit that took the @name out while the post stayed addressed to the persona) was hidden from that persona. Such personas are now kept as silent mentions, as Mastodon does: they see the post and it reaches their home, and no list shows them as mentioned. An edit never narrows who a post was for. The GoToSocial note that showed it is the first captured fixture (Fixtures/gotosocial), and parses with its lone tag, to and cc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
b9286c2c6e
commit
08acdc0503
7 files changed
+62
-10
No files matched your search
@@ -55,15 +55,33 @@ namespace PrivaPub.Federation.Inbox
|
||||
_queue = queue;
|
||||
}
|
||||
|
||||
public async Task<PostEntity> Build(NoteDocument note, ForeignAvatar author, PostVisibility visibility, IReadOnlyList<string> to,
|
||||
IReadOnlyList<string> cc, PostEntity parent, CancellationToken token)
|
||||
// The accounts a remote post names (its Mention tags), plus our personas it is addressed to without naming them: Mastodon
|
||||
// keeps those as silent mentions, and Akkoma's to[], or an edit that dropped the @name, address someone that way. A
|
||||
// silent mention lets the persona see the post and puts it in its home, and is never shown as a mention.
|
||||
public static async Task<List<PostMention>> Mentions(NoteDocument note, IEnumerable<string> addressed, ILocalActorService localActors,
|
||||
CancellationToken token)
|
||||
{
|
||||
var mentions = new List<PostMention>();
|
||||
foreach (var mention in note.Mentions)
|
||||
{
|
||||
var local = await _localActors.FindByUri(mention.ActorURI, token);
|
||||
var local = await localActors.FindByUri(mention.ActorURI, token);
|
||||
mentions.Add(new PostMention { ActorURI = mention.ActorURI, Handle = mention.Handle, IsLocal = local != default, AccountId = local?.Id });
|
||||
}
|
||||
foreach (var uri in addressed.Where(a => !string.IsNullOrEmpty(a) && !Addressing.IsPublic(a)).Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
if (mentions.Any(m => m.ActorURI == uri))
|
||||
continue;
|
||||
var local = await localActors.FindByUri(uri, token);
|
||||
if (local is { Kind: LocalActorKind.Person })
|
||||
mentions.Add(new PostMention { ActorURI = uri, Handle = "@" + local.Handle, IsLocal = true, AccountId = local.Id, Silent = true });
|
||||
}
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public async Task<PostEntity> Build(NoteDocument note, ForeignAvatar author, PostVisibility visibility, IReadOnlyList<string> to,
|
||||
IReadOnlyList<string> cc, PostEntity parent, CancellationToken token)
|
||||
{
|
||||
var mentions = await Mentions(note, to.Concat(cc), _localActors, token);
|
||||
|
||||
return new PostEntity
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user