kopia lustrzana https://github.com/nextcloud/social
Add exact matches to the search
Signed-off-by: Julius Härtl <jus@bitgrid.net>pull/18/head
rodzic
b022dd039d
commit
61d0ce3d46
|
@ -35,6 +35,7 @@ use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
|||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Exceptions\RequestException;
|
||||
use OCA\Social\Model\Post;
|
||||
use OCA\Social\Service\ActivityPub\FollowService;
|
||||
use OCA\Social\Service\ActivityPub\NoteService;
|
||||
|
@ -228,10 +229,17 @@ class LocalController extends Controller {
|
|||
* @return DataResponse
|
||||
*/
|
||||
public function accountsSearch(string $search): DataResponse {
|
||||
/* Look for an exactly matching account */
|
||||
$match = null;
|
||||
try {
|
||||
$match = $this->personService->getFromAccount($search);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
try {
|
||||
$accounts = $this->personService->searchCachedAccounts($search);
|
||||
|
||||
return $this->success(['accounts' => $accounts]);
|
||||
return $this->success(['accounts' => $accounts, 'exact' => $match]);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
|
|
|
@ -162,6 +162,9 @@ class PersonService implements ICoreService {
|
|||
$actor = $this->cacheActorsRequest->getFromAccount($account);
|
||||
} catch (CacheActorDoesNotExistException $e) {
|
||||
$object = $this->instanceService->retrieveAccount($account);
|
||||
if ($object === null) {
|
||||
throw new InvalidResourceException();
|
||||
}
|
||||
$actor = new Person();
|
||||
$actor->import($object);
|
||||
|
||||
|
|
|
@ -73,7 +73,10 @@ class CurlService {
|
|||
// $this->parseRequestResultCode500($code);
|
||||
// $this->parseRequestResult($result);
|
||||
|
||||
$ret = json_decode($result, true);
|
||||
$ret = json_decode((string)$result, true);
|
||||
if ($ret === null) {
|
||||
throw new RequestException('500 Internal server error - could not parse JSON response');
|
||||
}
|
||||
if (!is_array($ret)) {
|
||||
$ret = ['_result' => $result];
|
||||
}
|
||||
|
|
|
@ -83,6 +83,10 @@ class InstanceService {
|
|||
|
||||
list($username, $host) = explode('@', $account);
|
||||
|
||||
if ($username === null || $host === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$request = new Request('/.well-known/webfinger');
|
||||
$request->addData('resource', 'acct:' . $account);
|
||||
$request->setAddress($host);
|
||||
|
|
Ładowanie…
Reference in New Issue