From 3da6de1febc5f9d603f31ac9bcb07deb25c6946b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 31 Dec 2025 18:32:37 +0800 Subject: [PATCH] :necktie: Auto accept follows from activitypub --- .../ActivityPub/ActivityPubActivityProcessor.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs b/DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs index 20325c1..25f5086 100644 --- a/DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs +++ b/DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs @@ -129,7 +129,8 @@ public class ActivityPubActivityProcessor( { ActorId = actor.Id, TargetActorId = localActor.Id, - State = RelationshipState.Pending + State = RelationshipState.Accepted, + FollowedBackAt = SystemClock.Instance.GetCurrentInstant() }; db.FediverseRelationships.Add(existingRelationship); logger.LogInformation("Created new follow relationship. ActorId: {ActorId}, TargetActorId: {TargetActorId}", @@ -137,19 +138,21 @@ public class ActivityPubActivityProcessor( } else { - logger.LogInformation("Updating existing relationship. CurrentState: {State}, NewState: Pending", + existingRelationship.State = RelationshipState.Accepted; + existingRelationship.FollowedBackAt = SystemClock.Instance.GetCurrentInstant(); + logger.LogInformation("Updating existing relationship. CurrentState: {State}, NewState: Accepted", existingRelationship.State); } - + await db.SaveChangesAsync(); - + await deliveryService.SendAcceptActivityAsync( targetPublisher.Id, actorUri, activityId ?? "" ); - - logger.LogInformation("Processed follow from {Actor} to {Target}. RelationshipState: Pending", + + logger.LogInformation("Processed follow from {Actor} to {Target}. RelationshipState: Accepted", actorUri, objectUri); return true; }