diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-12-05 10:38:16 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-12-05 10:38:16 -0100 |
commit | ec0e6253a78d8fb1f286ee80a2a9166c3ce71a85 (patch) | |
tree | ef45250bc8fbb4da0d182e32e0cda34f5568aeb8 /lib | |
parent | 2059a5f6cd9c5ea85479e48e381322e856fc527b (diff) |
cleaning & fixing
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/LocalController.php | 14 | ||||
-rw-r--r-- | lib/Db/ActorsRequest.php | 1 | ||||
-rw-r--r-- | lib/Model/ActivityPub/Person.php | 4 | ||||
-rw-r--r-- | lib/Service/ActivityPub/PersonService.php | 2 | ||||
-rw-r--r-- | lib/Service/ActivityService.php | 2 |
5 files changed, 19 insertions, 4 deletions
diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index 2e31350a..8ba1c6f7 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -465,9 +465,9 @@ class LocalController extends Controller { * @return DataResponse */ public function accountFollowers(string $username): DataResponse { - $this->initViewer(); - try { + $this->initViewer(); + $actor = $this->actorService->getActor($username); $followers = $this->followService->getFollowers($actor); @@ -574,7 +574,7 @@ class LocalController extends Controller { throw new InvalidResourceException('no avatar for this Actor'); } } catch (Exception $e) { - return $this->fail($e, [], Http::STATUS_NOT_FOUND); + return $this->fail($e, [], Http::STATUS_NOT_FOUND, false); } } @@ -595,6 +595,14 @@ class LocalController extends Controller { public function globalAccountsSearch(string $search): DataResponse { $this->initViewer(); + if (substr($search, 0, 1) === '@') { + $search = substr($search, 1); + } + + if ($search === '') { + return $this->success(['accounts' => [], 'exact' => []]); + } + /* Look for an exactly matching account */ $match = null; try { diff --git a/lib/Db/ActorsRequest.php b/lib/Db/ActorsRequest.php index 00572296..30673b5a 100644 --- a/lib/Db/ActorsRequest.php +++ b/lib/Db/ActorsRequest.php @@ -97,6 +97,7 @@ class ActorsRequest extends ActorsRequestBuilder { public function getFromUsername(string $username): Person { $qb = $this->getActorsSelectSql(); $this->limitToPreferredUsername($qb, $username); + $this->limitToLocal($qb, true); $cursor = $qb->execute(); $data = $cursor->fetch(); diff --git a/lib/Model/ActivityPub/Person.php b/lib/Model/ActivityPub/Person.php index 91c584cf..6b40e0b0 100644 --- a/lib/Model/ActivityPub/Person.php +++ b/lib/Model/ActivityPub/Person.php @@ -246,6 +246,10 @@ class Person extends ACore implements JsonSerializable { * @return Person */ public function setAccount(string $account): Person { + if ($account !== '' && substr($account, 0, 1) === '@') { + $account = substr($account, 1); + } + $this->account = $account; return $this; diff --git a/lib/Service/ActivityPub/PersonService.php b/lib/Service/ActivityPub/PersonService.php index a3a6432d..9f0bd0f3 100644 --- a/lib/Service/ActivityPub/PersonService.php +++ b/lib/Service/ActivityPub/PersonService.php @@ -38,6 +38,7 @@ use OCA\Social\Db\CacheActorsRequest; use OCA\Social\Db\CacheDocumentsRequest; use OCA\Social\Exceptions\CacheActorDoesNotExistException; use OCA\Social\Exceptions\CacheDocumentDoesNotExistException; +use OCA\Social\Exceptions\InvalidResourceEntryException; use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\Request410Exception; use OCA\Social\Exceptions\RequestException; @@ -227,6 +228,7 @@ class PersonService implements ICoreService { * @throws InvalidResourceException * @throws SocialAppConfigException * @throws UrlCloudException + * @throws InvalidResourceEntryException */ private function generateActorFromObject(array $object) { diff --git a/lib/Service/ActivityService.php b/lib/Service/ActivityService.php index 8e094e56..45f3aa20 100644 --- a/lib/Service/ActivityService.php +++ b/lib/Service/ActivityService.php @@ -543,7 +543,7 @@ class ActivityService { $target = ''; try { - $target = strtolower($request->getMethod()) . " " . $request->getPathInfo(); + $target = strtolower($request->getMethod()) . " " . $request->getRequestUri(); } catch (Exception $e) { } |