kopia lustrzana https://github.com/nextcloud/social
routes and methods
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/86/head
rodzic
a6e705671e
commit
bf45757997
|
@ -75,16 +75,18 @@ return [
|
|||
['name' => 'Local#actionFollow', 'url' => '/api/v1/current/follow', 'verb' => 'PUT'],
|
||||
['name' => 'Local#actionUnfollow', 'url' => '/api/v1/current/follow', 'verb' => 'DELETE'],
|
||||
|
||||
['name' => 'Local#currentInfo', 'url' => '/api/v1/current/info', 'verb' => 'PUT'],
|
||||
['name' => 'Local#currentFollowers', 'url' => '/api/v1/current/followers', 'verb' => 'GET'],
|
||||
['name' => 'Local#currentFollowing', 'url' => '/api/v1/current/following', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#accountInfo', 'url' => '/api/v1/account/{username}/info', 'verb' => 'GET'],
|
||||
['name' => 'Local#accountFollowers', 'url' => '/api/v1/account/{username}/followers', 'verb' => 'GET'],
|
||||
['name' => 'Local#accountFollowing', 'url' => '/api/v1/account/{username}/following', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#accountInfo', 'url' => '/api/v1/global/account/info', 'verb' => 'GET'],
|
||||
['name' => 'Local#actorInfo', 'url' => '/api/v1/global/actor/info', 'verb' => 'GET'],
|
||||
['name' => 'Local#actorAvatar', 'url' => '/api/v1/global/actor/avatar', 'verb' => 'GET'],
|
||||
['name' => 'Local#accountsSearch', 'url' => '/api/v1/global/accounts/search', 'verb' => 'GET'],
|
||||
['name' => 'Local#globalAccountInfo', 'url' => '/api/v1/global/account/info', 'verb' => 'GET'],
|
||||
['name' => 'Local#globalActorInfo', 'url' => '/api/v1/global/actor/info', 'verb' => 'GET'],
|
||||
['name' => 'Local#globalActorAvatar', 'url' => '/api/v1/global/actor/avatar', 'verb' => 'GET'],
|
||||
['name' => 'Local#globalAccountsSearch', 'url' => '/api/v1/global/accounts/search', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#documentsCache', 'url' => '/api/v1/documents/cache', 'verb' => 'POST'],
|
||||
|
||||
|
|
|
@ -286,46 +286,6 @@ class LocalController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function accountsSearch(string $search): DataResponse {
|
||||
try {
|
||||
$viewer = $this->actorService->getActorFromUserId($this->userId, true);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
$this->personService->setViewerId($viewer->getId());
|
||||
|
||||
/* Look for an exactly matching account */
|
||||
$match = null;
|
||||
try {
|
||||
$match = $this->personService->getFromAccount($search, false);
|
||||
$match->setCompleteDetails(true);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$accounts = $this->personService->searchCachedAccounts($search);
|
||||
|
||||
return $this->success(['accounts' => $accounts, 'exact' => $match]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
|
@ -338,7 +298,7 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountFollow(string $account): DataResponse {
|
||||
public function actionFollow(string $account): DataResponse {
|
||||
try {
|
||||
$actor = $this->actorService->getActorFromUserId($this->userId);
|
||||
$this->followService->followAccount($actor, $account);
|
||||
|
@ -362,7 +322,7 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountUnfollow(string $account): DataResponse {
|
||||
public function actionUnfollow(string $account): DataResponse {
|
||||
try {
|
||||
$actor = $this->actorService->getActorFromUserId($this->userId);
|
||||
$this->followService->unfollowAccount($actor, $account);
|
||||
|
@ -374,6 +334,28 @@ class LocalController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function currentInfo(): DataResponse {
|
||||
try {
|
||||
$actor = $this->actorService->getActorFromUserId($this->userId);
|
||||
$actor = $this->personService->getFromLocalAccount($actor->getPreferredUsername());
|
||||
|
||||
return $this->success(['account' => $actor]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
|
@ -413,10 +395,36 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountInfo(string $username): DataResponse {
|
||||
try {
|
||||
$actor = $this->actorService->getActor($username);
|
||||
$actor = $this->personService->getFromLocalAccount($actor->getPreferredUsername());
|
||||
|
||||
return $this->success(['account' => $actor]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountFollowers(string $username): DataResponse {
|
||||
|
@ -436,6 +444,8 @@ class LocalController extends Controller {
|
|||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountFollowing(string $username): DataResponse {
|
||||
|
@ -462,7 +472,7 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountInfo(string $account): DataResponse {
|
||||
public function globalAccountInfo(string $account): DataResponse {
|
||||
try {
|
||||
$actor = $this->personService->getFromAccount($account);
|
||||
|
||||
|
@ -485,7 +495,7 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function actorInfo(string $id): DataResponse {
|
||||
public function globalActorInfo(string $id): DataResponse {
|
||||
try {
|
||||
$actor = $this->personService->getFromId($id);
|
||||
|
||||
|
@ -504,7 +514,7 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function actorAvatar(string $id): Response {
|
||||
public function globalActorAvatar(string $id): Response {
|
||||
try {
|
||||
$actor = $this->personService->getFromId($id);
|
||||
if ($actor->gotIcon()) {
|
||||
|
@ -521,6 +531,46 @@ class LocalController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function globalAccountsSearch(string $search): DataResponse {
|
||||
try {
|
||||
$viewer = $this->actorService->getActorFromUserId($this->userId, true);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
$this->personService->setViewerId($viewer->getId());
|
||||
|
||||
/* Look for an exactly matching account */
|
||||
$match = null;
|
||||
try {
|
||||
$match = $this->personService->getFromAccount($search, false);
|
||||
$match->setCompleteDetails(true);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$accounts = $this->personService->searchCachedAccounts($search);
|
||||
|
||||
return $this->success(['accounts' => $accounts, 'exact' => $match]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
|
|
Ładowanie…
Reference in New Issue