[backend/federation] Add Guid to end of follow activity URIs

This stops mastodon from caching the undo, preventing re-follows & debugging of federation issues
This commit is contained in:
Laura Hausmann 2024-05-07 16:29:28 +02:00
parent 16fdc48800
commit b705c95714
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 7 additions and 2 deletions

View file

@ -184,7 +184,10 @@ public class ActivityHandlerService(
throw GracefulException.UnprocessableEntity($"Object id '{obj.Id}' not a valid follow request id");
var ids = obj.Id[prefix.Length..].TrimEnd('/').Split("/");
if (ids.Length != 2 || ids[1] != actor.Id)
if (ids.Length < 2)
throw GracefulException
.UnprocessableEntity("Failed to parse ASAccept activity: ASFollow id doesn't have enough components");
if (ids[1] != actor.Id)
throw GracefulException
.UnprocessableEntity($"Actor id '{actor.Id}' doesn't match followee id '{ids[1]}'");

View file

@ -179,7 +179,7 @@ public class ActivityRenderer(
[SuppressMessage("ReSharper", "SuggestBaseTypeForParameter", Justification = "This only makes sense for users")]
private string RenderFollowId(User follower, User followee) =>
$"https://{config.Value.WebDomain}/follows/{follower.Id}/{followee.Id}";
$"https://{config.Value.WebDomain}/follows/{follower.Id}/{followee.Id}/{Guid.NewGuid().ToStringLower()}";
public static ASAnnounce RenderAnnounce(
ASNote note, ASActor actor, List<ASObjectBase> to, List<ASObjectBase> cc, string uri

View file

@ -49,6 +49,8 @@ public class ObjectResolver(
return new ASNote { Id = baseObj.Id, VerifiedFetch = true };
if (baseObj.Id.StartsWith($"https://{config.Value.WebDomain}/users/"))
return new ASActor { Id = baseObj.Id };
if (baseObj.Id.StartsWith($"https://{config.Value.WebDomain}/follows/"))
return new ASFollow { Id = baseObj.Id };
if (await federationCtrl.ShouldBlockAsync(baseObj.Id))
{