Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/82/head
Maxence Lange 2018-11-30 10:21:11 -01:00
rodzic 75447af767
commit c27f697f0a
20 zmienionych plików z 30 dodań i 93 usunięć

Wyświetl plik

@ -5,7 +5,7 @@
<name>Social</name>
<summary>🎉 Nextcloud becomes part of the federated social networks!</summary>
<description><![CDATA[test]]></description>
<version>0.0.54</version>
<version>0.0.60</version>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com">Maxence Lange</author>
<author mail="jus@bitgrid.net">Julius Härtl</author>

Wyświetl plik

@ -32,7 +32,6 @@ namespace OCA\Social\AppInfo;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
class Application extends App {

Wyświetl plik

@ -31,9 +31,7 @@ declare(strict_types=1);
namespace OCA\Social\Command;
use Exception;
use OC\Core\Command\Base;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\RequestException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityService;

Wyświetl plik

@ -74,9 +74,6 @@ class ActivityPubController extends Controller {
/** @var MiscService */
private $miscService;
/** @var NavigationController */
private $navigationController;
/**
* ActivityPubController constructor.
@ -94,13 +91,11 @@ class ActivityPubController extends Controller {
IRequest $request, SocialPubController $socialPubController,
ActivityService $activityService, ImportService $importService,
FollowService $followService, ActorService $actorService, NotesRequest $notesRequest,
NavigationController $navigationController,
MiscService $miscService
) {
parent::__construct(Application::APP_NAME, $request);
$this->socialPubController = $socialPubController;
$this->navigationController = $navigationController;
$this->activityService = $activityService;
$this->importService = $importService;
@ -258,7 +253,7 @@ class ActivityPubController extends Controller {
*
* @return Response
*/
public function followers(string $username, $data): Response {
public function followers(string $username): Response {
if (!$this->checkSourceActivityStreams()) {
return $this->socialPubController->followers($username);

Wyświetl plik

@ -25,11 +25,8 @@ declare(strict_types=1);
namespace OCA\Social\Controller;
use OCA\Activity\Data;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ConfigService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
@ -46,16 +43,12 @@ class ConfigController extends Controller {
/**
* @param string $cloudAddress
*
* @return DataResponse
*/
public function setCloudAddress(string $cloudAddress): DataResponse {
try {
$this->configService->setCloudAddress($cloudAddress);
return new DataResponse([]);
} catch (SocialAppConfigException $e) {
return new DataResponse([
'message' => $e->getMessage()
], Http::STATUS_BAD_REQUEST);
}
$this->configService->setCloudAddress($cloudAddress);
return new DataResponse([]);
}
}
}

Wyświetl plik

@ -219,6 +219,9 @@ class LocalController extends Controller {
* @NoAdminRequired
* @NoSubAdminRequired
*
* @param int $since
* @param int $limit
*
* @return DataResponse
*/
public function streamDirect(int $since = 0, int $limit = 5): DataResponse {

Wyświetl plik

@ -30,11 +30,9 @@ declare(strict_types=1);
namespace OCA\Social\Controller;
use daita\MySmallPhpTools\Traits\TArrayTools;
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception;
use OC\Files\Node\File;
use OC\Files\SimpleFS\SimpleFile;
use OC\User\NoUserException;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\AccountAlreadyExistsException;
@ -48,9 +46,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
@ -132,9 +128,11 @@ class NavigationController extends Controller {
* @NoAdminRequired
* @NoSubAdminRequired
*
* @param string $path
*
* @return TemplateResponse
*/
public function navigate($path = ''): TemplateResponse {
public function navigate(string $path = ''): TemplateResponse {
$data = [
'serverData' => [
'public' => false,
@ -230,10 +228,11 @@ class NavigationController extends Controller {
* @NoAdminRequired
* @NoSubAdminRequired
*
* @param string $path
*
* @return TemplateResponse
* @throws NoUserException
*/
public function timeline($path = ''): TemplateResponse {
public function timeline(string $path = ''): TemplateResponse {
return $this->navigate();
}
@ -244,10 +243,11 @@ class NavigationController extends Controller {
* @NoAdminRequired
* @NoSubAdminRequired
*
* @param string $path
*
* @return TemplateResponse
* @throws NoUserException
*/
public function account($path = ''): TemplateResponse {
public function account(string $path = ''): TemplateResponse {
return $this->navigate();
}

Wyświetl plik

@ -32,12 +32,10 @@ namespace OCA\Social\Controller;
use daita\MySmallPhpTools\Traits\TAsync;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\RequestException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Model\RequestQueue;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\CurlService;
use OCA\Social\Service\MiscService;
use OCA\Social\Service\QueueService;
use OCP\AppFramework\Controller;

Wyświetl plik

@ -137,7 +137,7 @@ class SocialPubController extends Controller {
} catch (CacheActorDoesNotExistException $e) {
return new NotFoundResponse();
} catch (Exception $e) {
$this->fail($e);
return $this->fail($e);
}
}

Wyświetl plik

@ -31,18 +31,11 @@ declare(strict_types=1);
namespace OCA\Social\Cron;
use Exception;
use OC\BackgroundJob\TimedJob;
use OCA\Social\AppInfo\Application;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\RequestException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Service\ActivityPub\DocumentService;
use OCA\Social\Service\ActivityPub\PersonService;
use OCA\Social\Service\ActivityService;
use OCA\Social\Service\ActorService;
use OCA\Social\Service\CacheService;
use OCA\Social\Service\ConfigService;
use OCA\Social\Service\MiscService;
use OCA\Social\Service\QueueService;
use OCP\AppFramework\QueryException;

Wyświetl plik

@ -201,32 +201,6 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
}
/**
* get Cached version of a local Actor, based on the preferred username
*
* @param string $account
*
* @return Person
* @throws CacheActorDoesNotExistException
*/
public function getFromLocalAccount(string $account): Person {
$qb = $this->getCacheActorsSelectSql();
$this->limitToPreferredUsername($qb, $account);
$this->limitToLocal($qb, true);
$this->leftJoinCacheDocuments($qb, 'icon_id');
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor->closeCursor();
if ($data === false) {
throw new CacheActorDoesNotExistException();
}
return $this->parseCacheActorsSelectSql($data);
}
/**
* @param string $search
* @param string $viewerId
@ -243,7 +217,6 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
$this->leftJoinFollowAsViewer($qb, 'id', $viewerId, false, 'as_followed');
}
$accounts = [];
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {

Wyświetl plik

@ -108,22 +108,6 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
}
/**
* Base of the Sql Select request for Shares
*
* @return IQueryBuilder
*/
protected function countFollowsSelectSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
$qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
->from(self::TABLE_SERVER_FOLLOWS, 'f');
$this->defaultSelectAlias = 'f';
return $qb;
}
/**
* Base of the Sql Delete request
*

Wyświetl plik

@ -35,7 +35,6 @@ use DateTime;
use Exception;
use OCA\Social\Exceptions\QueueStatusException;
use OCA\Social\Model\RequestQueue;
use OCA\Social\Service\QueueService;
use OCP\DB\QueryBuilder\IQueryBuilder;

Wyświetl plik

@ -336,9 +336,12 @@ class NoteService implements ICoreService {
/**
* @param Person $actor
*
* @param int $since
* @param int $limit
*
* @return Note[]
*/
public function getDirectNotesForActor(Person $actor, $since, $limit): array {
public function getDirectNotesForActor(Person $actor, int $since = 0, int $limit = 5): array {
return $this->notesRequest->getDirectNotesForActorId($actor->getId(), $since, $limit);
}

Wyświetl plik

@ -284,8 +284,12 @@ class ActivityService {
);
} catch (ActorDoesNotExistException $e) {
$this->queueService->deleteRequest($queue);
return;
} catch (Request410Exception $e) {
$this->queueService->deleteRequest($queue);
return;
}
try {

Wyświetl plik

@ -237,8 +237,6 @@ class ConfigService {
/**
* @param string $cloudAddress
*
* @return string
*/
public function setCloudAddress(string $cloudAddress) {
$this->setAppValue(self::SOCIAL_ADDRESS, $cloudAddress);

Wyświetl plik

@ -249,8 +249,6 @@ class CurlService {
/**
* @param int $code
*
* @param Request $request
*
* @throws Request410Exception
*/
private function parseRequestResultCode410(int $code) {

Wyświetl plik

@ -31,7 +31,6 @@ declare(strict_types=1);
namespace OCA\Social\Service;
use Exception;
use OC\User\NoUserException;
use OCA\Social\AppInfo\Application;
use OCP\ILogger;

Wyświetl plik

@ -33,7 +33,6 @@ namespace OCA\Social\Service;
use Exception;
use OC\User\NoUserException;
use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\RequestException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\Post;

Wyświetl plik

@ -78,6 +78,7 @@ class QueueService {
/**
* @param array $instancePaths
* @param ACore $item
* @param string $author
*
* @return string
* @throws Exception