diff options
Diffstat (limited to 'Digitigrade/Model/Actor.php')
| -rw-r--r-- | Digitigrade/Model/Actor.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Digitigrade/Model/Actor.php b/Digitigrade/Model/Actor.php index ffaf4e8..3fb7e4e 100644 --- a/Digitigrade/Model/Actor.php +++ b/Digitigrade/Model/Actor.php @@ -2,6 +2,7 @@ namespace Digitigrade\Model; use Digitigrade\Db; +use Digitigrade\Job\PeriodicFetchRemoteFeed; use Digitigrade\Job\ProcessIncomingPush; use Digitigrade\Job\ProcessIncomingSimplePush; use Digitigrade\Notification\PendingFollowActionedNotif; @@ -254,10 +255,26 @@ class Actor extends PushableModel implements RpcReceiver { * @return FollowRelationStatus PENDING if a request was sent or ACTIVE if the follow went through immediately */ public function follow(self $target): FollowRelationStatus { + // handle actors with no follow endpoint + if (!$target->isLocal && !isset($target->endpoints->follow, $target->endpoints->unfollow)) { + // if this is the first time someone local followed this actor, put a job in to update them + if (count(array_filter($target->findFollowers(), fn(Actor $a) => $a->isLocal)) == 0) { + (new PeriodicFetchRemoteFeed($target))->submit(); + } + FollowRelation::create($this, $target, FollowRelationStatus::ACTIVE); + // no need to processNotifications because it's always going to be a remote user & not pending + return FollowRelationStatus::ACTIVE; + } + return $target->rpcCall('follow', [$this]); } public function unfollow(self $target) { + // handle actors with no follow endpoint + if (!$target->isLocal && !isset($target->endpoints->follow, $target->endpoints->unfollow)) { + FollowRelation::findByActors($this, $target)?->remove(); + return; + } $target->rpcCall('unfollow', [$this]); } |
