kopia lustrzana https://github.com/nextcloud/social
exception when following yourself
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/135/head
rodzic
ef5db6043a
commit
3232df7a8c
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
class FollowSameAccountException extends \Exception {
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
Ładowanie…
Reference in New Issue