summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-12-05 11:44:19 +0100
committerGitHub <noreply@github.com>2018-12-05 11:44:19 +0100
commit2059a5f6cd9c5ea85479e48e381322e856fc527b (patch)
tree4742ccd0d998f1f8bf223b9a99e14a31e4eb3278 /lib
parent107d8b28fbfd948f671019ff7d7babf0a2a368bd (diff)
parent8184dbd70583e79686322f5b551167168e283392 (diff)
Merge pull request #135 from nextcloud-gmbh/fix/do-not-follow-your-own-account
exception when following yourself
Diffstat (limited to 'lib')
-rw-r--r--lib/Exceptions/FollowSameAccountException.php8
-rw-r--r--lib/Service/ActivityPub/FollowService.php6
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Exceptions/FollowSameAccountException.php b/lib/Exceptions/FollowSameAccountException.php
new file mode 100644
index 00000000..cdf5140a
--- /dev/null
+++ b/lib/Exceptions/FollowSameAccountException.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace OCA\Social\Exceptions;
+
+class FollowSameAccountException extends \Exception {
+
+}
+
diff --git a/lib/Service/ActivityPub/FollowService.php b/lib/Service/ActivityPub/FollowService.php
index 4e9942af..bd802be5 100644
--- a/lib/Service/ActivityPub/FollowService.php
+++ b/lib/Service/ActivityPub/FollowService.php
@@ -36,6 +36,7 @@ use OCA\Social\Db\FollowsRequest;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
use OCA\Social\Exceptions\FollowDoesNotExistException;
+use OCA\Social\Exceptions\FollowSameAccountException;
use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\RequestException;
use OCA\Social\Exceptions\SocialAppConfigException;
@@ -121,9 +122,14 @@ class FollowService implements ICoreService {
* @throws CacheActorDoesNotExistException
* @throws InvalidResourceException
* @throws UrlCloudException
+ * @throws FollowSameAccountException
*/
public function followAccount(Person $actor, string $account) {
$remoteActor = $this->personService->getFromAccount($account);
+ if ($remoteActor->getId() === $actor->getId()) {
+ throw new FollowSameAccountException("Don't follow yourself, be your own lead");
+ }
+
$follow = new Follow();
$follow->setUrlCloud($this->configService->getCloudAddress());
$follow->generateUniqueId();