👔 Auto accept follows from activitypub
This commit is contained in:
@@ -129,7 +129,8 @@ public class ActivityPubActivityProcessor(
|
|||||||
{
|
{
|
||||||
ActorId = actor.Id,
|
ActorId = actor.Id,
|
||||||
TargetActorId = localActor.Id,
|
TargetActorId = localActor.Id,
|
||||||
State = RelationshipState.Pending
|
State = RelationshipState.Accepted,
|
||||||
|
FollowedBackAt = SystemClock.Instance.GetCurrentInstant()
|
||||||
};
|
};
|
||||||
db.FediverseRelationships.Add(existingRelationship);
|
db.FediverseRelationships.Add(existingRelationship);
|
||||||
logger.LogInformation("Created new follow relationship. ActorId: {ActorId}, TargetActorId: {TargetActorId}",
|
logger.LogInformation("Created new follow relationship. ActorId: {ActorId}, TargetActorId: {TargetActorId}",
|
||||||
@@ -137,19 +138,21 @@ public class ActivityPubActivityProcessor(
|
|||||||
}
|
}
|
||||||
else
|
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);
|
existingRelationship.State);
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
await deliveryService.SendAcceptActivityAsync(
|
await deliveryService.SendAcceptActivityAsync(
|
||||||
targetPublisher.Id,
|
targetPublisher.Id,
|
||||||
actorUri,
|
actorUri,
|
||||||
activityId ?? ""
|
activityId ?? ""
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.LogInformation("Processed follow from {Actor} to {Target}. RelationshipState: Pending",
|
logger.LogInformation("Processed follow from {Actor} to {Target}. RelationshipState: Accepted",
|
||||||
actorUri, objectUri);
|
actorUri, objectUri);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user