Fix follower handling

This commit is contained in:
Tim Zöller 2025-11-29 21:49:21 +01:00
parent 97dcd92657
commit 3fa67c43d6
4 changed files with 39 additions and 3 deletions

View file

@ -31,13 +31,22 @@ public class Follow {
/**
* The local user who is following.
* NULL if this is a remote user following a local user.
*/
@Column(name = "follower_id", nullable = false)
@Column(name = "follower_id")
private UUID followerId;
/**
* The ActivityPub actor URI being followed (local or remote).
* The remote actor URI of the follower (for remote-to-local follows).
* Example: https://mastodon.social/users/alice
* NULL if followerId is set (local follower).
*/
@Column(name = "remote_actor_uri", length = 512)
private String remoteActorUri;
/**
* The ActivityPub actor URI being followed (local or remote).
* Example: https://example.com/users/bob
*/
@Column(name = "following_actor_uri", nullable = false, length = 512)
private String followingActorUri;

View file

@ -128,7 +128,14 @@ public class FederationService {
@Transactional
public void sendAcceptActivity(Follow follow, User localUser) {
try {
RemoteActor remoteActor = fetchRemoteActor(follow.getFollowingActorUri());
// Get the remote actor who sent the follow request
String remoteActorUri = follow.getRemoteActorUri();
if (remoteActorUri == null) {
log.error("Cannot send Accept: Follow has no remote actor URI");
return;
}
RemoteActor remoteActor = fetchRemoteActor(remoteActorUri);
String acceptId = baseUrl + "/activities/" + UUID.randomUUID();
String actorUri = baseUrl + "/users/" + localUser.getUsername();

View file

@ -95,6 +95,7 @@ public class InboxProcessor {
// Note: We're storing it from the perspective of "who is following whom"
Follow follow = Follow.builder()
.followerId(null) // Remote actor, so no local user ID
.remoteActorUri(actor) // The remote actor who is following
.followingActorUri(expectedObjectUri) // The local user being followed
.status(Follow.FollowStatus.ACCEPTED) // Auto-accept for now
.activityId(activityId)