kopia lustrzana https://github.com/nextcloud/social
Add psalm static analysis
Signed-off-by: Carl Schwan <carl@carlschwan.eu>pull/1377/head
rodzic
9e20993c4d
commit
46df90a0fb
|
@ -18,7 +18,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php-versions: ["7.4", "8.0"]
|
php-versions: ["7.4", "8.0", "8.1"]
|
||||||
|
|
||||||
name: php-lint
|
name: php-lint
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
name: Static analysis
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
static-psalm-analysis:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
ocp-version: [ 'dev-master' ]
|
||||||
|
name: Nextcloud ${{ matrix.ocp-version }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up php
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: 7.4
|
||||||
|
tools: composer:v1
|
||||||
|
coverage: none
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer i
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }}
|
||||||
|
- name: Run coding standards check
|
||||||
|
run: composer run psalm
|
|
@ -28,8 +28,6 @@
|
||||||
"friendica/json-ld": "^1.0"
|
"friendica/json-ld": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"jakub-onderka/php-parallel-lint": "^1.0",
|
|
||||||
"rector/rector": "^0.12.20",
|
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^9.5",
|
||||||
"nextcloud/coding-standard": "^1.0.0",
|
"nextcloud/coding-standard": "^1.0.0",
|
||||||
"christophwurst/nextcloud": "dev-master",
|
"christophwurst/nextcloud": "dev-master",
|
||||||
|
@ -39,7 +37,7 @@
|
||||||
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
|
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
|
||||||
"cs:check": "php-cs-fixer fix --dry-run --diff",
|
"cs:check": "php-cs-fixer fix --dry-run --diff",
|
||||||
"cs:fix": "php-cs-fixer fix",
|
"cs:fix": "php-cs-fixer fix",
|
||||||
"psalm": "psalm --threads=1",
|
"psalm": "psalm --threads=1 --update-baseline",
|
||||||
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
|
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
|
||||||
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
|
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
|
||||||
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
|
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "303af33a7156caaf44b7a28ce25c7755",
|
"content-hash": "c9f825ade4c2baa82438409e058171bc",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "daita/my-small-php-tools",
|
"name": "daita/my-small-php-tools",
|
||||||
|
@ -1097,59 +1097,6 @@
|
||||||
],
|
],
|
||||||
"time": "2022-03-18T17:20:59+00:00"
|
"time": "2022-03-18T17:20:59+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "jakub-onderka/php-parallel-lint",
|
|
||||||
"version": "v1.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git",
|
|
||||||
"reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
|
|
||||||
"reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"jakub-onderka/php-console-highlighter": "~0.3",
|
|
||||||
"nette/tester": "~1.3",
|
|
||||||
"squizlabs/php_codesniffer": "~2.7"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"parallel-lint"
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"classmap": [
|
|
||||||
"./"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-2-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jakub Onderka",
|
|
||||||
"email": "ahoj@jakubonderka.cz"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
|
|
||||||
"homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/JakubOnderka/PHP-Parallel-Lint/issues",
|
|
||||||
"source": "https://github.com/JakubOnderka/PHP-Parallel-Lint/tree/master"
|
|
||||||
},
|
|
||||||
"abandoned": "php-parallel-lint/php-parallel-lint",
|
|
||||||
"time": "2018-02-24T15:31:20+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "myclabs/deep-copy",
|
"name": "myclabs/deep-copy",
|
||||||
"version": "1.11.0",
|
"version": "1.11.0",
|
||||||
|
@ -1800,65 +1747,6 @@
|
||||||
},
|
},
|
||||||
"time": "2021-12-08T12:19:24+00:00"
|
"time": "2021-12-08T12:19:24+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpstan/phpstan",
|
|
||||||
"version": "1.5.5",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
|
||||||
"reference": "d77a607667f29ae099c0686f99664bd451fd23df"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d77a607667f29ae099c0686f99664bd451fd23df",
|
|
||||||
"reference": "d77a607667f29ae099c0686f99664bd451fd23df",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2|^8.0"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"phpstan/phpstan-shim": "*"
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"phpstan",
|
|
||||||
"phpstan.phar"
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"description": "PHPStan - PHP Static Analysis Tool",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
|
||||||
"source": "https://github.com/phpstan/phpstan/tree/1.5.5"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/ondrejmirtes",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/phpstan",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://www.patreon.com/phpstan",
|
|
||||||
"type": "patreon"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2022-04-14T12:20:26+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "9.2.15",
|
"version": "9.2.15",
|
||||||
|
@ -2477,66 +2365,6 @@
|
||||||
},
|
},
|
||||||
"time": "2021-05-03T11:20:27+00:00"
|
"time": "2021-05-03T11:20:27+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "rector/rector",
|
|
||||||
"version": "0.12.20",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/rectorphp/rector.git",
|
|
||||||
"reference": "cfa8d3e236a6e1a41d69712a84d434dfdf70e560"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/cfa8d3e236a6e1a41d69712a84d434dfdf70e560",
|
|
||||||
"reference": "cfa8d3e236a6e1a41d69712a84d434dfdf70e560",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2|^8.0",
|
|
||||||
"phpstan/phpstan": "^1.5"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"phpstan/phpdoc-parser": "<1.2",
|
|
||||||
"rector/rector-cakephp": "*",
|
|
||||||
"rector/rector-doctrine": "*",
|
|
||||||
"rector/rector-laravel": "*",
|
|
||||||
"rector/rector-nette": "*",
|
|
||||||
"rector/rector-phpoffice": "*",
|
|
||||||
"rector/rector-phpunit": "*",
|
|
||||||
"rector/rector-prefixed": "*",
|
|
||||||
"rector/rector-symfony": "*"
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"bin/rector"
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "0.12-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/rectorphp/rector/issues",
|
|
||||||
"source": "https://github.com/rectorphp/rector/tree/0.12.20"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/tomasvotruba",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2022-04-06T12:55:14+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "sebastian/cli-parser",
|
"name": "sebastian/cli-parser",
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
|
|
|
@ -32,7 +32,6 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\AppInfo;
|
namespace OCA\Social\AppInfo;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use OC\DB\SchemaWrapper;
|
|
||||||
use OCA\Social\Notification\Notifier;
|
use OCA\Social\Notification\Notifier;
|
||||||
use OCA\Social\Search\UnifiedSearchProvider;
|
use OCA\Social\Search\UnifiedSearchProvider;
|
||||||
use OCA\Social\Service\ConfigService;
|
use OCA\Social\Service\ConfigService;
|
||||||
|
@ -45,6 +44,8 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||||
use OCP\AppFramework\QueryException;
|
use OCP\AppFramework\QueryException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use OCP\IServerContainer;
|
use OCP\IServerContainer;
|
||||||
|
use OC\DB\SchemaWrapper;
|
||||||
|
use OCP\DB\ISchemaWrapper;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
@ -106,6 +107,7 @@ class Application extends App implements IBootstrap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var ISchemaWrapper $schema */
|
||||||
$schema = new SchemaWrapper($container->get(IDBConnection::class));
|
$schema = new SchemaWrapper($container->get(IDBConnection::class));
|
||||||
if ($schema->hasTable('social_a2_stream')) {
|
if ($schema->hasTable('social_a2_stream')) {
|
||||||
$updateService->checkUpdateStatus();
|
$updateService->checkUpdateStatus();
|
||||||
|
|
|
@ -175,7 +175,7 @@ class CheckInstall extends Base {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function regenerateIndex(OutputInterface $output) {
|
private function regenerateIndex(OutputInterface $output): void {
|
||||||
$streams = $this->streamRequest->getAll();
|
$streams = $this->streamRequest->getAll();
|
||||||
$progressBar = new ProgressBar($output, count($streams));
|
$progressBar = new ProgressBar($output, count($streams));
|
||||||
$progressBar->start();
|
$progressBar->start();
|
||||||
|
|
|
@ -49,22 +49,10 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
*/
|
*/
|
||||||
class NoteBoost extends Base {
|
class NoteBoost extends Base {
|
||||||
private StreamService $streamService;
|
private StreamService $streamService;
|
||||||
|
|
||||||
private AccountService $accountService;
|
private AccountService $accountService;
|
||||||
|
|
||||||
private BoostService $boostService;
|
private BoostService $boostService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NoteBoost constructor.
|
|
||||||
*
|
|
||||||
* @param AccountService $accountService
|
|
||||||
* @param StreamService $streamService
|
|
||||||
* @param BoostService $boostService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AccountService $accountService, StreamService $streamService, BoostService $boostService,
|
AccountService $accountService, StreamService $streamService, BoostService $boostService,
|
||||||
MiscService $miscService
|
MiscService $miscService
|
||||||
|
@ -104,6 +92,7 @@ class NoteBoost extends Base {
|
||||||
$actor = $this->accountService->getActorFromUserId($userId);
|
$actor = $this->accountService->getActorFromUserId($userId);
|
||||||
$this->streamService->setViewer($actor);
|
$this->streamService->setViewer($actor);
|
||||||
|
|
||||||
|
$token = '';
|
||||||
if (!$input->getOption('unboost')) {
|
if (!$input->getOption('unboost')) {
|
||||||
$activity = $this->boostService->create($actor, $noteId, $token);
|
$activity = $this->boostService->create($actor, $noteId, $token);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,6 +137,7 @@ class NoteCreate extends Base {
|
||||||
$post->addTo(($to === null) ? '' : $to);
|
$post->addTo(($to === null) ? '' : $to);
|
||||||
$post->setHashtags(($hashtag === null) ? [] : [$hashtag]);
|
$post->setHashtags(($hashtag === null) ? [] : [$hashtag]);
|
||||||
|
|
||||||
|
$token = '';
|
||||||
$activity = $this->postService->createPost($post, $token);
|
$activity = $this->postService->createPost($post, $token);
|
||||||
|
|
||||||
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
||||||
|
|
|
@ -104,6 +104,7 @@ class NoteLike extends Base {
|
||||||
$actor = $this->accountService->getActorFromUserId($userId);
|
$actor = $this->accountService->getActorFromUserId($userId);
|
||||||
$this->streamService->setViewer($actor);
|
$this->streamService->setViewer($actor);
|
||||||
|
|
||||||
|
$token = '';
|
||||||
if (!$input->getOption('unlike')) {
|
if (!$input->getOption('unlike')) {
|
||||||
$activity = $this->likeService->create($actor, $noteId, $token);
|
$activity = $this->likeService->create($actor, $noteId, $token);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,6 +125,7 @@ class LocalController extends Controller {
|
||||||
$post->setHashtags($this->getArray('hashtags', $data, []));
|
$post->setHashtags($this->getArray('hashtags', $data, []));
|
||||||
$post->setAttachments($this->getArray('attachments', $data, []));
|
$post->setAttachments($this->getArray('attachments', $data, []));
|
||||||
|
|
||||||
|
$token = '';
|
||||||
$activity = $this->postService->createPost($post, $token);
|
$activity = $this->postService->createPost($post, $token);
|
||||||
|
|
||||||
return $this->success(
|
return $this->success(
|
||||||
|
@ -209,6 +210,7 @@ class LocalController extends Controller {
|
||||||
public function postBoost(string $postId): DataResponse {
|
public function postBoost(string $postId): DataResponse {
|
||||||
try {
|
try {
|
||||||
$this->initViewer(true);
|
$this->initViewer(true);
|
||||||
|
$token = '';
|
||||||
$announce = $this->boostService->create($this->viewer, $postId, $token);
|
$announce = $this->boostService->create($this->viewer, $postId, $token);
|
||||||
|
|
||||||
return $this->success(
|
return $this->success(
|
||||||
|
@ -231,6 +233,7 @@ class LocalController extends Controller {
|
||||||
public function postUnboost(string $postId): DataResponse {
|
public function postUnboost(string $postId): DataResponse {
|
||||||
try {
|
try {
|
||||||
$this->initViewer(true);
|
$this->initViewer(true);
|
||||||
|
$token = '';
|
||||||
$announce = $this->boostService->delete($this->viewer, $postId, $token);
|
$announce = $this->boostService->delete($this->viewer, $postId, $token);
|
||||||
|
|
||||||
return $this->success(
|
return $this->success(
|
||||||
|
@ -253,6 +256,7 @@ class LocalController extends Controller {
|
||||||
public function postLike(string $postId): DataResponse {
|
public function postLike(string $postId): DataResponse {
|
||||||
try {
|
try {
|
||||||
$this->initViewer(true);
|
$this->initViewer(true);
|
||||||
|
$token = '';
|
||||||
$announce = $this->likeService->create($this->viewer, $postId, $token);
|
$announce = $this->likeService->create($this->viewer, $postId, $token);
|
||||||
|
|
||||||
return $this->success(
|
return $this->success(
|
||||||
|
@ -275,6 +279,7 @@ class LocalController extends Controller {
|
||||||
public function postUnlike(string $postId): DataResponse {
|
public function postUnlike(string $postId): DataResponse {
|
||||||
try {
|
try {
|
||||||
$this->initViewer(true);
|
$this->initViewer(true);
|
||||||
|
$token = '';
|
||||||
$like = $this->likeService->delete($this->viewer, $postId, $token);
|
$like = $this->likeService->delete($this->viewer, $postId, $token);
|
||||||
|
|
||||||
return $this->success(
|
return $this->success(
|
||||||
|
|
|
@ -74,6 +74,7 @@ class NavigationController extends Controller {
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
private IL10N $l10n;
|
private IL10N $l10n;
|
||||||
private CheckService $checkService;
|
private CheckService $checkService;
|
||||||
|
private IInitialStateService $initialStateService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
|
|
|
@ -140,10 +140,11 @@ class OAuthController extends Controller {
|
||||||
/**
|
/**
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
* @PublicPage
|
* @PublicPage
|
||||||
|
* @param array|string $redirect_uris
|
||||||
* @throws ClientException
|
* @throws ClientException
|
||||||
*/
|
*/
|
||||||
public function apps(
|
public function apps(
|
||||||
string $client_name = '', string $redirect_uris = '', string $website = '', string $scopes = 'read'
|
string $client_name = '', $redirect_uris = '', string $website = '', string $scopes = 'read'
|
||||||
): DataResponse {
|
): DataResponse {
|
||||||
// TODO: manage array from request
|
// TODO: manage array from request
|
||||||
if (!is_array($redirect_uris)) {
|
if (!is_array($redirect_uris)) {
|
||||||
|
|
|
@ -67,6 +67,7 @@ class SocialPubController extends Controller {
|
||||||
private CacheActorService $cacheActorService;
|
private CacheActorService $cacheActorService;
|
||||||
private StreamService $streamService;
|
private StreamService $streamService;
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
private IInitialStateService $initialStateService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
?string $userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
?string $userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
||||||
|
|
|
@ -32,7 +32,7 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Cron;
|
namespace OCA\Social\Cron;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\TimedJob;
|
use OCP\BackgroundJob\TimedJob;
|
||||||
use OCA\Social\AppInfo\Application;
|
use OCA\Social\AppInfo\Application;
|
||||||
use OCA\Social\Service\AccountService;
|
use OCA\Social\Service\AccountService;
|
||||||
|
@ -52,7 +52,7 @@ class Cache extends TimedJob {
|
||||||
private ?DocumentService $documentService = null;
|
private ?DocumentService $documentService = null;
|
||||||
private ?HashtagService $hashtagService = null;
|
private ?HashtagService $hashtagService = null;
|
||||||
|
|
||||||
public function __construct(TimeFactory $time) {
|
public function __construct(ITimeFactory $time) {
|
||||||
parent::__construct($time);
|
parent::__construct($time);
|
||||||
$this->setInterval(12 * 60); // 12 minutes
|
$this->setInterval(12 * 60); // 12 minutes
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Social\Cron;
|
namespace OCA\Social\Cron;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\TimedJob;
|
use OCP\BackgroundJob\TimedJob;
|
||||||
use OCA\Social\AppInfo\Application;
|
use OCA\Social\AppInfo\Application;
|
||||||
use OCA\Social\Service\ConfigService;
|
use OCA\Social\Service\ConfigService;
|
||||||
use OCA\Social\Service\MiscService;
|
|
||||||
use OCP\AppFramework\QueryException;
|
use OCP\AppFramework\QueryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +45,7 @@ use OCP\AppFramework\QueryException;
|
||||||
class Chunk extends TimedJob {
|
class Chunk extends TimedJob {
|
||||||
private ?ConfigService $configService = null;
|
private ?ConfigService $configService = null;
|
||||||
|
|
||||||
public function __construct(TimeFactory $time) {
|
public function __construct(ITimeFactory $time) {
|
||||||
parent::__construct($time);
|
parent::__construct($time);
|
||||||
$this->setInterval(12 * 3600); // 12 hours
|
$this->setInterval(12 * 3600); // 12 hours
|
||||||
}
|
}
|
||||||
|
@ -62,7 +61,6 @@ class Chunk extends TimedJob {
|
||||||
$c = $app->getContainer();
|
$c = $app->getContainer();
|
||||||
|
|
||||||
$this->configService = $c->query(ConfigService::class);
|
$this->configService = $c->query(ConfigService::class);
|
||||||
$this->miscService = $c->query(MiscService::class);
|
|
||||||
|
|
||||||
$size = (int)$this->configService->getAppValue(ConfigService::DATABASE_CHUNK_SIZE);
|
$size = (int)$this->configService->getAppValue(ConfigService::DATABASE_CHUNK_SIZE);
|
||||||
$this->morphChunks($size);
|
$this->morphChunks($size);
|
||||||
|
|
|
@ -31,12 +31,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Social\Cron;
|
namespace OCA\Social\Cron;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\BackgroundJob\TimedJob;
|
use OCP\BackgroundJob\TimedJob;
|
||||||
use OCA\Social\AppInfo\Application;
|
use OCA\Social\AppInfo\Application;
|
||||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||||
use OCA\Social\Service\ActivityService;
|
use OCA\Social\Service\ActivityService;
|
||||||
use OCA\Social\Service\MiscService;
|
|
||||||
use OCA\Social\Service\RequestQueueService;
|
use OCA\Social\Service\RequestQueueService;
|
||||||
use OCA\Social\Service\StreamQueueService;
|
use OCA\Social\Service\StreamQueueService;
|
||||||
use OCP\AppFramework\QueryException;
|
use OCP\AppFramework\QueryException;
|
||||||
|
@ -51,11 +50,10 @@ class Queue extends TimedJob {
|
||||||
private ?RequestQueueService $requestQueueService = null;
|
private ?RequestQueueService $requestQueueService = null;
|
||||||
private ?StreamQueueService $streamQueueService = null;
|
private ?StreamQueueService $streamQueueService = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache constructor.
|
* Cache constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(TimeFactory $time) {
|
public function __construct(ITimeFactory $time) {
|
||||||
parent::__construct($time);
|
parent::__construct($time);
|
||||||
$this->setInterval(12 * 60); // 12 minutes
|
$this->setInterval(12 * 60); // 12 minutes
|
||||||
}
|
}
|
||||||
|
@ -74,7 +72,6 @@ class Queue extends TimedJob {
|
||||||
$this->requestQueueService = $c->get(RequestQueueService::class);
|
$this->requestQueueService = $c->get(RequestQueueService::class);
|
||||||
$this->streamQueueService = $c->get(StreamQueueService::class);
|
$this->streamQueueService = $c->get(StreamQueueService::class);
|
||||||
$this->activityService = $c->get(ActivityService::class);
|
$this->activityService = $c->get(ActivityService::class);
|
||||||
$this->miscService = $c->get(MiscService::class);
|
|
||||||
|
|
||||||
$this->manageRequestQueue();
|
$this->manageRequestQueue();
|
||||||
$this->manageStreamQueue();
|
$this->manageStreamQueue();
|
||||||
|
|
|
@ -69,7 +69,7 @@ class ActionsRequest extends ActionsRequestBuilder {
|
||||||
|
|
||||||
$this->generatePrimaryKey($qb, $like->getId());
|
$this->generatePrimaryKey($qb, $like->getId());
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,8 +118,8 @@ class ActionsRequestBuilder extends CoreRequestBuilder {
|
||||||
* @throws ActionDoesNotExistException
|
* @throws ActionDoesNotExistException
|
||||||
*/
|
*/
|
||||||
protected function getActionFromRequest(SocialQueryBuilder $qb): ACore {
|
protected function getActionFromRequest(SocialQueryBuilder $qb): ACore {
|
||||||
/** @var ACore $result */
|
|
||||||
try {
|
try {
|
||||||
|
/** @var ACore $result */
|
||||||
$result = $qb->getRow([$this, 'parseActionsSelectSql']);
|
$result = $qb->getRow([$this, 'parseActionsSelectSql']);
|
||||||
} catch (RowNotFoundException $e) {
|
} catch (RowNotFoundException $e) {
|
||||||
throw new ActionDoesNotExistException($e->getMessage());
|
throw new ActionDoesNotExistException($e->getMessage());
|
||||||
|
|
|
@ -31,22 +31,20 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Db;
|
namespace OCA\Social\Db;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||||
|
use OCP\DB\Exception as DBException;
|
||||||
|
|
||||||
class CacheActorsRequest extends CacheActorsRequestBuilder {
|
class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||||
public const CACHE_TTL = 60 * 24; // 1d
|
public const CACHE_TTL = 60 * 24; // 1d
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert cache about an Actor in database.
|
* Insert cache about an Actor in database.
|
||||||
*
|
|
||||||
* @param Person $actor
|
|
||||||
*/
|
*/
|
||||||
public function save(Person $actor) {
|
public function save(Person $actor): void {
|
||||||
$qb = $this->getCacheActorsInsertSql();
|
$qb = $this->getCacheActorsInsertSql();
|
||||||
$qb->setValue('id', $qb->createNamedParameter($actor->getId()))
|
$qb->setValue('id', $qb->createNamedParameter($actor->getId()))
|
||||||
->setValue('id_prim', $qb->createNamedParameter($this->prim($actor->getId())))
|
->setValue('id_prim', $qb->createNamedParameter($this->prim($actor->getId())))
|
||||||
|
@ -95,18 +93,14 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||||
$qb->generatePrimaryKey($actor->getId());
|
$qb->generatePrimaryKey($actor->getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
} catch (UniqueConstraintViolationException $e) {
|
} catch (DBException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert cache about an Actor in database.
|
* Insert cache about an Actor in database.
|
||||||
*
|
|
||||||
* @param Person $actor
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function update(Person $actor): int {
|
public function update(Person $actor): int {
|
||||||
$qb = $this->getCacheActorsUpdateSql();
|
$qb = $this->getCacheActorsUpdateSql();
|
||||||
|
@ -151,7 +145,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||||
|
|
||||||
$this->limitToIdString($qb, $actor->getId());
|
$this->limitToIdString($qb, $actor->getId());
|
||||||
|
|
||||||
return $qb->execute();
|
return $qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,6 +196,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||||
$qb = $this->getCacheActorsSelectSql();
|
$qb = $this->getCacheActorsSelectSql();
|
||||||
$this->limitToPreferredUsername($qb, $account);
|
$this->limitToPreferredUsername($qb, $account);
|
||||||
$this->limitToLocal($qb, true);
|
$this->limitToLocal($qb, true);
|
||||||
|
/** @var SocialQueryBuilder $qb */
|
||||||
$qb->leftJoinCacheDocuments('icon_id');
|
$qb->leftJoinCacheDocuments('icon_id');
|
||||||
$this->leftJoinDetails($qb);
|
$this->leftJoinDetails($qb);
|
||||||
|
|
||||||
|
@ -217,6 +212,7 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||||
public function searchAccounts(string $search): array {
|
public function searchAccounts(string $search): array {
|
||||||
$qb = $this->getCacheActorsSelectSql();
|
$qb = $this->getCacheActorsSelectSql();
|
||||||
$this->searchInAccount($qb, $search);
|
$this->searchInAccount($qb, $search);
|
||||||
|
/** @var SocialQueryBuilder $qb */
|
||||||
$qb->leftJoinCacheDocuments('icon_id');
|
$qb->leftJoinCacheDocuments('icon_id');
|
||||||
$this->leftJoinDetails($qb);
|
$this->leftJoinDetails($qb);
|
||||||
$this->limitResults($qb, 25);
|
$this->limitResults($qb, 25);
|
||||||
|
|
|
@ -38,6 +38,7 @@ use Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use Exception;
|
use Exception;
|
||||||
use OC;
|
use OC;
|
||||||
use OC\DB\SchemaWrapper;
|
use OC\DB\SchemaWrapper;
|
||||||
|
use OCP\DB\ISchemaWrapper;
|
||||||
use OCA\Social\Exceptions\InvalidResourceException;
|
use OCA\Social\Exceptions\InvalidResourceException;
|
||||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||||
use OCA\Social\Model\ActivityPub\Object\Follow;
|
use OCA\Social\Model\ActivityPub\Object\Follow;
|
||||||
|
@ -109,7 +110,6 @@ class CoreRequestBuilder {
|
||||||
) {
|
) {
|
||||||
$this->dbConnection = $connection;
|
$this->dbConnection = $connection;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->loggerInterface = $logger;
|
|
||||||
$this->urlGenerator = $urlGenerator;
|
$this->urlGenerator = $urlGenerator;
|
||||||
$this->configService = $configService;
|
$this->configService = $configService;
|
||||||
$this->miscService = $miscService;
|
$this->miscService = $miscService;
|
||||||
|
@ -122,7 +122,7 @@ class CoreRequestBuilder {
|
||||||
public function getQueryBuilder(): SocialQueryBuilder {
|
public function getQueryBuilder(): SocialQueryBuilder {
|
||||||
$qb = new SocialQueryBuilder(
|
$qb = new SocialQueryBuilder(
|
||||||
$this->dbConnection,
|
$this->dbConnection,
|
||||||
OC::$server->getSystemConfig(),
|
OC::$server->get(\OC\SystemConfig::class),
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->urlGenerator
|
$this->urlGenerator
|
||||||
);
|
);
|
||||||
|
@ -729,20 +729,11 @@ class CoreRequestBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
protected function limitToDBFieldArray(IQueryBuilder &$qb, string $field, array $values): void {
|
||||||
* @param IQueryBuilder $qb
|
|
||||||
* @param string $field
|
|
||||||
* @param array $values
|
|
||||||
*/
|
|
||||||
protected function limitToDBFieldArray(IQueryBuilder &$qb, string $field, array $values) {
|
|
||||||
$expr = $qb->expr();
|
$expr = $qb->expr();
|
||||||
$pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->defaultSelectAlias . '.' : '';
|
$pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->defaultSelectAlias . '.' : '';
|
||||||
$field = $pf . $field;
|
$field = $pf . $field;
|
||||||
|
|
||||||
if (!is_array($values)) {
|
|
||||||
$values = [$values];
|
|
||||||
}
|
|
||||||
|
|
||||||
$orX = $expr->orX();
|
$orX = $expr->orX();
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$orX->add($expr->eq($field, $qb->createNamedParameter($value)));
|
$orX->add($expr->eq($field, $qb->createNamedParameter($value)));
|
||||||
|
@ -1185,6 +1176,7 @@ class CoreRequestBuilder {
|
||||||
* this just empty all tables from the app.
|
* this just empty all tables from the app.
|
||||||
*/
|
*/
|
||||||
public function uninstallSocialTables() {
|
public function uninstallSocialTables() {
|
||||||
|
/** @var ISchemaWrapper|SchemaWrapper $schema */
|
||||||
$schema = new SchemaWrapper($this->dbConnection);
|
$schema = new SchemaWrapper($this->dbConnection);
|
||||||
foreach ($this->tables as $table) {
|
foreach ($this->tables as $table) {
|
||||||
if ($schema->hasTable($table)) {
|
if ($schema->hasTable($table)) {
|
||||||
|
|
|
@ -43,11 +43,9 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new Queue in the database.
|
* Create a new Queue in the database.
|
||||||
*
|
|
||||||
* @param StreamAction $action
|
|
||||||
*/
|
*/
|
||||||
public function create(StreamAction $action) {
|
public function create(StreamAction $action): void {
|
||||||
$qb = $this->getStreamActionInsertSql();
|
$qb = $this->getStreamActionInsertSql();
|
||||||
|
|
||||||
$values = $action->getValues();
|
$values = $action->getValues();
|
||||||
|
@ -68,16 +66,12 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
||||||
->setValue('boosted', $qb->createNamedParameter(($boosted) ? 1 : 0))
|
->setValue('boosted', $qb->createNamedParameter(($boosted) ? 1 : 0))
|
||||||
->setValue('replied', $qb->createNamedParameter(($replied) ? 1 : 0));
|
->setValue('replied', $qb->createNamedParameter(($replied) ? 1 : 0));
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a new Queue in the database.
|
* Create a new Queue in the database.
|
||||||
*
|
|
||||||
* @param StreamAction $action
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function update(StreamAction $action): int {
|
public function update(StreamAction $action): int {
|
||||||
$qb = $this->getStreamActionUpdateSql();
|
$qb = $this->getStreamActionUpdateSql();
|
||||||
|
@ -95,15 +89,11 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
||||||
$this->limitToActorId($qb, $action->getActorId());
|
$this->limitToActorId($qb, $action->getActorId());
|
||||||
$this->limitToStreamId($qb, $action->getStreamId());
|
$this->limitToStreamId($qb, $action->getStreamId());
|
||||||
|
|
||||||
return $qb->execute();
|
return $qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $actorId
|
|
||||||
* @param string $streamId
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
* @throws StreamActionDoesNotExistException
|
* @throws StreamActionDoesNotExistException
|
||||||
*/
|
*/
|
||||||
public function getAction(string $actorId, string $streamId): StreamAction {
|
public function getAction(string $actorId, string $streamId): StreamAction {
|
||||||
|
@ -111,7 +101,7 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
||||||
$this->limitToActorId($qb, $actorId);
|
$this->limitToActorId($qb, $actorId);
|
||||||
$this->limitToStreamId($qb, $streamId);
|
$this->limitToStreamId($qb, $streamId);
|
||||||
|
|
||||||
$cursor = $qb->execute();
|
$cursor = $qb->executeQuery();
|
||||||
$data = $cursor->fetch();
|
$data = $cursor->fetch();
|
||||||
if ($data === false) {
|
if ($data === false) {
|
||||||
throw new StreamActionDoesNotExistException();
|
throw new StreamActionDoesNotExistException();
|
||||||
|
@ -121,15 +111,11 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
||||||
return $this->parseStreamActionsSelectSql($data);
|
return $this->parseStreamActionsSelectSql($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(StreamAction $action): void {
|
||||||
/**
|
|
||||||
* @param StreamAction $action
|
|
||||||
*/
|
|
||||||
public function delete(StreamAction $action) {
|
|
||||||
$qb = $this->getStreamActionDeleteSql();
|
$qb = $this->getStreamActionDeleteSql();
|
||||||
$this->limitToActorId($qb, $action->getActorId());
|
$this->limitToActorId($qb, $action->getActorId());
|
||||||
$this->limitToStreamId($qb, $action->getStreamId());
|
$this->limitToStreamId($qb, $action->getStreamId());
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Db;
|
namespace OCA\Social\Db;
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Traits\TStringTools;
|
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use OCP\DB\Exception as DBException;
|
||||||
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
|
use OCA\Social\Model\ActivityPub\Internal\SocialAppNotification;
|
||||||
use OCA\Social\Model\ActivityPub\Stream;
|
use OCA\Social\Model\ActivityPub\Stream;
|
||||||
use OCA\Social\Service\CacheActorService;
|
use OCA\Social\Service\CacheActorService;
|
||||||
|
@ -71,16 +71,12 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
||||||
$qb->setValue('subtype', $qb->createNamedParameter($subType));
|
$qb->setValue('subtype', $qb->createNamedParameter($subType));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
} catch (UniqueConstraintViolationException $e) {
|
} catch (DBException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateStreamDest(Stream $stream): void {
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*/
|
|
||||||
public function generateStreamDest(Stream $stream) {
|
|
||||||
if ($this->generateStreamNotification($stream)) {
|
if ($this->generateStreamNotification($stream)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -92,12 +88,6 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
||||||
$this->generateStreamHome($stream);
|
$this->generateStreamHome($stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function generateStreamHome(Stream $stream): bool {
|
private function generateStreamHome(Stream $stream): bool {
|
||||||
$recipients =
|
$recipients =
|
||||||
[
|
[
|
||||||
|
@ -118,12 +108,6 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function generateStreamDirect(Stream $stream): bool {
|
private function generateStreamDirect(Stream $stream): bool {
|
||||||
try {
|
try {
|
||||||
$author = $this->cacheActorService->getFromId($stream->getAttributedTo());
|
$author = $this->cacheActorService->getFromId($stream->getAttributedTo());
|
||||||
|
@ -152,12 +136,6 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function generateStreamNotification(Stream $stream): bool {
|
private function generateStreamNotification(Stream $stream): bool {
|
||||||
if ($stream->getType() !== SocialAppNotification::TYPE) {
|
if ($stream->getType() !== SocialAppNotification::TYPE) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -174,14 +152,10 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function emptyStreamDest(): void {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function emptyStreamDest() {
|
|
||||||
$qb = $this->dbConnection->getQueryBuilder();
|
$qb = $this->dbConnection->getQueryBuilder();
|
||||||
$qb->delete(self::TABLE_STREAM_DEST);
|
$qb->delete(self::TABLE_STREAM_DEST);
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,6 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base of the Sql Insert request
|
* Base of the Sql Insert request
|
||||||
*
|
|
||||||
* @return IQueryBuilder
|
|
||||||
*/
|
*/
|
||||||
protected function getStreamDestInsertSql(): SocialQueryBuilder {
|
protected function getStreamDestInsertSql(): SocialQueryBuilder {
|
||||||
$qb = $this->getQueryBuilder();
|
$qb = $this->getQueryBuilder();
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace OCA\Social\Db;
|
||||||
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
||||||
use daita\MySmallPhpTools\Model\Cache;
|
use daita\MySmallPhpTools\Model\Cache;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use OCP\DB\Exception as DBException;
|
||||||
use OCA\Social\Exceptions\ItemUnknownException;
|
use OCA\Social\Exceptions\ItemUnknownException;
|
||||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||||
use OCA\Social\Model\ActivityPub\ACore;
|
use OCA\Social\Model\ActivityPub\ACore;
|
||||||
|
@ -70,11 +70,7 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
$this->streamTagsRequest = $streamTagsRequest;
|
$this->streamTagsRequest = $streamTagsRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save(Stream $stream): void {
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*/
|
|
||||||
public function save(Stream $stream) {
|
|
||||||
$qb = $this->saveStream($stream);
|
$qb = $this->saveStream($stream);
|
||||||
if ($stream->getType() === Note::TYPE) {
|
if ($stream->getType() === Note::TYPE) {
|
||||||
/** @var Note $stream */
|
/** @var Note $stream */
|
||||||
|
@ -87,19 +83,15 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
|
|
||||||
$this->streamDestRequest->generateStreamDest($stream);
|
$this->streamDestRequest->generateStreamDest($stream);
|
||||||
$this->streamTagsRequest->generateStreamTags($stream);
|
$this->streamTagsRequest->generateStreamTags($stream);
|
||||||
} catch (UniqueConstraintViolationException $e) {
|
} catch (DBException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update(Stream $stream): void {
|
||||||
/**
|
|
||||||
* @param Stream $stream \
|
|
||||||
*/
|
|
||||||
public function update(Stream $stream) {
|
|
||||||
$qb = $this->getStreamUpdateSql();
|
$qb = $this->getStreamUpdateSql();
|
||||||
|
|
||||||
$qb->set('details', $qb->createNamedParameter(json_encode($stream->getDetailsAll())));
|
$qb->set('details', $qb->createNamedParameter(json_encode($stream->getDetailsAll())));
|
||||||
|
@ -109,34 +101,25 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$qb->limitToIdPrim($qb->prim($stream->getId()));
|
$qb->limitToIdPrim($qb->prim($stream->getId()));
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
|
|
||||||
$this->streamDestRequest->generateStreamDest($stream);
|
$this->streamDestRequest->generateStreamDest($stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateCache(Stream $stream, Cache $cache): void {
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
* @param Cache $cache
|
|
||||||
*/
|
|
||||||
public function updateCache(Stream $stream, Cache $cache) {
|
|
||||||
$qb = $this->getStreamUpdateSql();
|
$qb = $this->getStreamUpdateSql();
|
||||||
$qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES)));
|
$qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES)));
|
||||||
|
|
||||||
$qb->limitToIdPrim($qb->prim($stream->getId()));
|
$qb->limitToIdPrim($qb->prim($stream->getId()));
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateAttachments(Document $document): void {
|
||||||
/**
|
|
||||||
* @param Document $document
|
|
||||||
*/
|
|
||||||
public function updateAttachments(Document $document) {
|
|
||||||
$qb = $this->getStreamSelectSql();
|
$qb = $this->getStreamSelectSql();
|
||||||
$qb->limitToIdPrim($qb->prim($document->getParentId()));
|
$qb->limitToIdPrim($qb->prim($document->getParentId()));
|
||||||
|
|
||||||
$cursor = $qb->execute();
|
$cursor = $qb->executeQuery();
|
||||||
$data = $cursor->fetch();
|
$data = $cursor->fetch();
|
||||||
$cursor->closeCursor();
|
$cursor->closeCursor();
|
||||||
|
|
||||||
|
@ -149,13 +132,10 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
$qb->set('attachments', $qb->createNamedParameter(json_encode($new, JSON_UNESCAPED_SLASHES)));
|
$qb->set('attachments', $qb->createNamedParameter(json_encode($new, JSON_UNESCAPED_SLASHES)));
|
||||||
$qb->limitToIdPrim($qb->prim($document->getParentId()));
|
$qb->limitToIdPrim($qb->prim($document->getParentId()));
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Document $document
|
|
||||||
* @param array $attachments
|
|
||||||
*
|
|
||||||
* @return Document[]
|
* @return Document[]
|
||||||
*/
|
*/
|
||||||
private function updateAttachmentInList(Document $document, array $attachments): array {
|
private function updateAttachmentInList(Document $document, array $attachments): array {
|
||||||
|
@ -174,18 +154,14 @@ class StreamRequest extends StreamRequestBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
public function updateAttributedTo(string $itemId, string $to): void {
|
||||||
* @param string $itemId
|
|
||||||
* @param string $to
|
|
||||||
*/
|
|
||||||
public function updateAttributedTo(string $itemId, string $to) {
|
|
||||||
$qb = $this->getStreamUpdateSql();
|
$qb = $this->getStreamUpdateSql();
|
||||||
$qb->set('attributed_to', $qb->createNamedParameter($to));
|
$qb->set('attributed_to', $qb->createNamedParameter($to));
|
||||||
$qb->set('attributed_to_prim', $qb->createNamedParameter($qb->prim($to)));
|
$qb->set('attributed_to_prim', $qb->createNamedParameter($qb->prim($to)));
|
||||||
|
|
||||||
$qb->limitToIdPrim($qb->prim($itemId));
|
$qb->limitToIdPrim($qb->prim($itemId));
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\Db;
|
namespace OCA\Social\Db;
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Traits\TStringTools;
|
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
|
||||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||||
use OCA\Social\Model\ActivityPub\Stream;
|
use OCA\Social\Model\ActivityPub\Stream;
|
||||||
|
use OCP\DB\Exception as DBException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StreamTagsRequest
|
* Class StreamTagsRequest
|
||||||
|
@ -44,11 +44,7 @@ use OCA\Social\Model\ActivityPub\Stream;
|
||||||
class StreamTagsRequest extends StreamTagsRequestBuilder {
|
class StreamTagsRequest extends StreamTagsRequestBuilder {
|
||||||
use TStringTools;
|
use TStringTools;
|
||||||
|
|
||||||
|
public function generateStreamTags(Stream $stream): void {
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*/
|
|
||||||
public function generateStreamTags(Stream $stream) {
|
|
||||||
if ($stream->getType() !== Note::TYPE) {
|
if ($stream->getType() !== Note::TYPE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,22 +56,18 @@ class StreamTagsRequest extends StreamTagsRequestBuilder {
|
||||||
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
|
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
|
||||||
$qb->setValue('hashtag', $qb->createNamedParameter($hashtag));
|
$qb->setValue('hashtag', $qb->createNamedParameter($hashtag));
|
||||||
try {
|
try {
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
} catch (UniqueConstraintViolationException $e) {
|
} catch (DBException $e) {
|
||||||
\OC::$server->getLogger()
|
\OC::$server->getLogger()
|
||||||
->log(1, 'Social - Duplicate hashtag on Stream ' . json_encode($stream));
|
->log(1, 'Social - Duplicate hashtag on Stream ' . json_encode($stream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function emptyStreamTags(): void {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function emptyStreamTags() {
|
|
||||||
$qb = $this->dbConnection->getQueryBuilder();
|
$qb = $this->dbConnection->getQueryBuilder();
|
||||||
$qb->delete(self::TABLE_STREAM_TAGS);
|
$qb->delete(self::TABLE_STREAM_TAGS);
|
||||||
|
|
||||||
$qb->execute();
|
$qb->executeStatement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,30 +54,13 @@ use OCA\Social\Service\MiscService;
|
||||||
class PersonInterface implements IActivityPubInterface {
|
class PersonInterface implements IActivityPubInterface {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
|
|
||||||
|
|
||||||
private CacheActorsRequest $cacheActorsRequest;
|
private CacheActorsRequest $cacheActorsRequest;
|
||||||
|
|
||||||
private StreamRequest $streamRequest;
|
private StreamRequest $streamRequest;
|
||||||
|
|
||||||
private FollowsRequest $followsRequest;
|
private FollowsRequest $followsRequest;
|
||||||
|
|
||||||
private ActorService $actorService;
|
private ActorService $actorService;
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UndoService constructor.
|
|
||||||
*
|
|
||||||
* @param CacheActorsRequest $cacheActorsRequest
|
|
||||||
* @param StreamRequest $streamRequest
|
|
||||||
* @param FollowsRequest $followsRequest
|
|
||||||
* @param ActorService $actorService
|
|
||||||
* @param ConfigService $configService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CacheActorsRequest $cacheActorsRequest, StreamRequest $streamRequest,
|
CacheActorsRequest $cacheActorsRequest, StreamRequest $streamRequest,
|
||||||
FollowsRequest $followsRequest, ActorService $actorService, ConfigService $configService,
|
FollowsRequest $followsRequest, ActorService $actorService, ConfigService $configService,
|
||||||
|
@ -91,25 +74,15 @@ class PersonInterface implements IActivityPubInterface {
|
||||||
$this->miscService = $miscService;
|
$this->miscService = $miscService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processIncomingRequest(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $person
|
|
||||||
*/
|
|
||||||
public function processIncomingRequest(ACore $person) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
*/
|
|
||||||
public function processResult(ACore $item) {
|
public function processResult(ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ACore $item
|
|
||||||
*
|
|
||||||
* @return ACore
|
|
||||||
* @throws ItemNotFoundException
|
* @throws ItemNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getItem(ACore $item): ACore {
|
public function getItem(ACore $item): ACore {
|
||||||
|
@ -149,12 +122,9 @@ class PersonInterface implements IActivityPubInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $person
|
|
||||||
*/
|
|
||||||
public function save(ACore $person) {
|
|
||||||
/** @var Person $person */
|
/** @var Person $person */
|
||||||
|
$person = $item;
|
||||||
try {
|
try {
|
||||||
$this->getItemById($person->getId());
|
$this->getItemById($person->getId());
|
||||||
$this->actorService->update($person);
|
$this->actorService->update($person);
|
||||||
|
@ -163,17 +133,9 @@ class PersonInterface implements IActivityPubInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
*/
|
|
||||||
public function update(ACore $item) {
|
public function update(ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
*/
|
|
||||||
public function delete(ACore $item) {
|
public function delete(ACore $item) {
|
||||||
/** @var Person $item */
|
/** @var Person $item */
|
||||||
$this->cacheActorsRequest->deleteCacheById($item->getId());
|
$this->cacheActorsRequest->deleteCacheById($item->getId());
|
||||||
|
@ -181,19 +143,9 @@ class PersonInterface implements IActivityPubInterface {
|
||||||
$this->followsRequest->deleteRelatedId($item->getId());
|
$this->followsRequest->deleteRelatedId($item->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
* @param string $source
|
|
||||||
*/
|
|
||||||
public function event(ACore $item, string $source) {
|
public function event(ACore $item, string $source) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Person $actor
|
|
||||||
* @param ACore $activity
|
|
||||||
*/
|
|
||||||
private function updateActor(Person $actor, ACore $activity) {
|
private function updateActor(Person $actor, ACore $activity) {
|
||||||
$actor->setCreation($activity->getOriginCreationTime());
|
$actor->setCreation($activity->getOriginCreationTime());
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
|
||||||
/**
|
/**
|
||||||
* @param ACore $note
|
* @param ACore $note
|
||||||
*/
|
*/
|
||||||
public function processIncomingRequest(ACore $note) {
|
public function processIncomingRequest(ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,12 +113,9 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
|
||||||
public function activity(Acore $activity, ACore $item) {
|
public function activity(Acore $activity, ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $notification
|
|
||||||
*/
|
|
||||||
public function save(ACore $notification) {
|
|
||||||
/** @var SocialAppNotification $notification */
|
/** @var SocialAppNotification $notification */
|
||||||
|
$notification = $item;
|
||||||
if ($notification->getId() === '') {
|
if ($notification->getId() === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,12 +129,9 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
|
||||||
$this->streamRequest->save($notification);
|
$this->streamRequest->save($notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $notification
|
|
||||||
*/
|
|
||||||
public function update(ACore $notification) {
|
|
||||||
/** @var SocialAppNotification $notification */
|
/** @var SocialAppNotification $notification */
|
||||||
|
$notification = $item;
|
||||||
$this->miscService->log(
|
$this->miscService->log(
|
||||||
'Updating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1
|
'Updating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1
|
||||||
);
|
);
|
||||||
|
|
|
@ -149,8 +149,9 @@ class AnnounceInterface implements IActivityPubInterface {
|
||||||
* @throws RequestServerException
|
* @throws RequestServerException
|
||||||
* @throws UnauthorizedFediverseException
|
* @throws UnauthorizedFediverseException
|
||||||
*/
|
*/
|
||||||
public function activity(Acore $activity, ACore $announce) {
|
public function activity(Acore $activity, ACore $item) {
|
||||||
/** @var Announce $announce */
|
/** @var Announce $announce */
|
||||||
|
$announce = $item;
|
||||||
if ($activity->getType() === Undo::TYPE) {
|
if ($activity->getType() === Undo::TYPE) {
|
||||||
$activity->checkOrigin($announce->getId());
|
$activity->checkOrigin($announce->getId());
|
||||||
$activity->checkOrigin($announce->getActorId());
|
$activity->checkOrigin($announce->getActorId());
|
||||||
|
|
|
@ -69,28 +69,12 @@ use OCA\Social\Service\MiscService;
|
||||||
*/
|
*/
|
||||||
class FollowInterface implements IActivityPubInterface {
|
class FollowInterface implements IActivityPubInterface {
|
||||||
private FollowsRequest $followsRequest;
|
private FollowsRequest $followsRequest;
|
||||||
|
|
||||||
private CacheActorService $cacheActorService;
|
private CacheActorService $cacheActorService;
|
||||||
|
|
||||||
private AccountService $accountService;
|
private AccountService $accountService;
|
||||||
|
|
||||||
private ActivityService $activityService;
|
private ActivityService $activityService;
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NoteInterface constructor.
|
|
||||||
*
|
|
||||||
* @param FollowsRequest $followsRequest
|
|
||||||
* @param CacheActorService $cacheActorService
|
|
||||||
* @param AccountService $accountService
|
|
||||||
* @param ActivityService $activityService
|
|
||||||
* @param ConfigService $configService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
FollowsRequest $followsRequest, CacheActorService $cacheActorService,
|
FollowsRequest $followsRequest, CacheActorService $cacheActorService,
|
||||||
AccountService $accountService, ActivityService $activityService,
|
AccountService $accountService, ActivityService $activityService,
|
||||||
|
@ -104,17 +88,9 @@ class FollowInterface implements IActivityPubInterface {
|
||||||
$this->miscService = $miscService;
|
$this->miscService = $miscService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
*/
|
|
||||||
public function processResult(ACore $item) {
|
public function processResult(ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Follow $follow
|
|
||||||
*/
|
|
||||||
public function confirmFollowRequest(Follow $follow) {
|
public function confirmFollowRequest(Follow $follow) {
|
||||||
try {
|
try {
|
||||||
$remoteActor = $this->cacheActorService->getFromId($follow->getActorId());
|
$remoteActor = $this->cacheActorService->getFromId($follow->getActorId());
|
||||||
|
@ -165,8 +141,9 @@ class FollowInterface implements IActivityPubInterface {
|
||||||
* @throws RequestResultNotJsonException
|
* @throws RequestResultNotJsonException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function processIncomingRequest(ACore $follow) {
|
public function processIncomingRequest(ACore $item) {
|
||||||
/** @var Follow $follow */
|
/** @var Follow $follow */
|
||||||
|
$follow = $item;
|
||||||
$follow->checkOrigin($follow->getActorId());
|
$follow->checkOrigin($follow->getActorId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -88,12 +88,13 @@ class LikeInterface implements IActivityPubInterface {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ACore $like
|
* @param ACore $item
|
||||||
*
|
*
|
||||||
* @throws InvalidOriginException
|
* @throws InvalidOriginException
|
||||||
*/
|
*/
|
||||||
public function processIncomingRequest(ACore $like) {
|
public function processIncomingRequest(ACore $item) {
|
||||||
/** @var Like $like */
|
/** @var Like $like */
|
||||||
|
$like = $item;
|
||||||
$like->checkOrigin($like->getId());
|
$like->checkOrigin($like->getId());
|
||||||
$like->checkOrigin($like->getActorId());
|
$like->checkOrigin($like->getActorId());
|
||||||
|
|
||||||
|
@ -110,8 +111,9 @@ class LikeInterface implements IActivityPubInterface {
|
||||||
*
|
*
|
||||||
* @throws InvalidOriginException
|
* @throws InvalidOriginException
|
||||||
*/
|
*/
|
||||||
public function activity(ACore $activity, ACore $like) {
|
public function activity(ACore $activity, ACore $item) {
|
||||||
/** @var Like $like */
|
/** @var Like $like */
|
||||||
|
$like = $item;
|
||||||
if ($activity->getType() === Undo::TYPE) {
|
if ($activity->getType() === Undo::TYPE) {
|
||||||
$activity->checkOrigin($like->getId());
|
$activity->checkOrigin($like->getId());
|
||||||
$activity->checkOrigin($like->getActorId());
|
$activity->checkOrigin($like->getActorId());
|
||||||
|
@ -212,7 +214,9 @@ class LikeInterface implements IActivityPubInterface {
|
||||||
/**
|
/**
|
||||||
* @param ACore $like
|
* @param ACore $like
|
||||||
*/
|
*/
|
||||||
private function undoLikeAction(ACore $like) {
|
private function undoLikeAction(ACore $item) {
|
||||||
|
/** @var Like $like */
|
||||||
|
$like = $item;
|
||||||
try {
|
try {
|
||||||
if ($like->hasActor()) {
|
if ($like->hasActor()) {
|
||||||
$actor = $like->getActor();
|
$actor = $like->getActor();
|
||||||
|
|
|
@ -47,25 +47,11 @@ use OCA\Social\Service\PushService;
|
||||||
|
|
||||||
class NoteInterface implements IActivityPubInterface {
|
class NoteInterface implements IActivityPubInterface {
|
||||||
private StreamRequest $streamRequest;
|
private StreamRequest $streamRequest;
|
||||||
|
|
||||||
private CurlService $curlService;
|
private CurlService $curlService;
|
||||||
|
|
||||||
private PushService $pushService;
|
private PushService $pushService;
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NoteInterface constructor.
|
|
||||||
*
|
|
||||||
* @param StreamRequest $streamRequest
|
|
||||||
* @param CurlService $curlService
|
|
||||||
* @param PushService $pushService
|
|
||||||
* @param ConfigService $configService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
StreamRequest $streamRequest, CurlService $curlService, PushService $pushService,
|
StreamRequest $streamRequest, CurlService $curlService, PushService $pushService,
|
||||||
ConfigService $configService, MiscService $miscService
|
ConfigService $configService, MiscService $miscService
|
||||||
|
@ -77,36 +63,20 @@ class NoteInterface implements IActivityPubInterface {
|
||||||
$this->miscService = $miscService;
|
$this->miscService = $miscService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processIncomingRequest(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $note
|
|
||||||
*/
|
|
||||||
public function processIncomingRequest(ACore $note) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ACore $item
|
|
||||||
*/
|
|
||||||
public function processResult(ACore $item) {
|
public function processResult(ACore $item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ACore $item
|
|
||||||
*
|
|
||||||
* @return ACore
|
|
||||||
* @throws ItemNotFoundException
|
* @throws ItemNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getItem(ACore $item): ACore {
|
public function getItem(ACore $item): ACore {
|
||||||
throw new ItemNotFoundException();
|
throw new ItemNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $id
|
|
||||||
*
|
|
||||||
* @return ACore
|
|
||||||
* @throws ItemNotFoundException
|
* @throws ItemNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getItemById(string $id): ACore {
|
public function getItemById(string $id): ACore {
|
||||||
|
@ -140,13 +110,9 @@ class NoteInterface implements IActivityPubInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save(ACore $item) {
|
||||||
/**
|
|
||||||
* @param ACore $note
|
|
||||||
*/
|
|
||||||
public function save(ACore $note) {
|
|
||||||
/** @var Note $note */
|
/** @var Note $note */
|
||||||
|
$note = $item;
|
||||||
try {
|
try {
|
||||||
$this->streamRequest->getStreamById($note->getId());
|
$this->streamRequest->getStreamById($note->getId());
|
||||||
} catch (StreamNotFoundException $e) {
|
} catch (StreamNotFoundException $e) {
|
||||||
|
|
|
@ -37,163 +37,85 @@ use OCA\Social\Model\InstancePath;
|
||||||
class Item {
|
class Item {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
|
|
||||||
|
|
||||||
private string $urlSocial = '';
|
private string $urlSocial = '';
|
||||||
|
|
||||||
private string $urlCloud = '';
|
private string $urlCloud = '';
|
||||||
|
|
||||||
private string $address = '';
|
private string $address = '';
|
||||||
|
|
||||||
private string $id = '';
|
private string $id = '';
|
||||||
|
|
||||||
private int $nid = 0;
|
private int $nid = 0;
|
||||||
|
|
||||||
private string $type = '';
|
private string $type = '';
|
||||||
|
|
||||||
private string $subType = '';
|
private string $subType = '';
|
||||||
|
|
||||||
private string $url = '';
|
private string $url = '';
|
||||||
|
|
||||||
private string $attributedTo = '';
|
private string $attributedTo = '';
|
||||||
|
|
||||||
private string $summary = '';
|
private string $summary = '';
|
||||||
|
|
||||||
/** @var InstancePath[] */
|
/** @var InstancePath[] */
|
||||||
private array $instancePaths = [];
|
private array $instancePaths = [];
|
||||||
|
|
||||||
private string $to = '';
|
private string $to = '';
|
||||||
|
|
||||||
private array $toArray = [];
|
private array $toArray = [];
|
||||||
|
|
||||||
private array $cc = [];
|
private array $cc = [];
|
||||||
|
|
||||||
private array $bcc = [];
|
private array $bcc = [];
|
||||||
|
|
||||||
private string $published = '';
|
private string $published = '';
|
||||||
|
|
||||||
private array $tags = [];
|
private array $tags = [];
|
||||||
|
|
||||||
private ?Person $actor = null;
|
private ?Person $actor = null;
|
||||||
|
|
||||||
private string $actorId = '';
|
private string $actorId = '';
|
||||||
|
|
||||||
private string $iconId = '';
|
private string $iconId = '';
|
||||||
|
|
||||||
private string $objectId = '';
|
private string $objectId = '';
|
||||||
|
|
||||||
private bool $completeDetails = false;
|
private bool $completeDetails = false;
|
||||||
|
|
||||||
private string $source = '';
|
private string $source = '';
|
||||||
|
|
||||||
private bool $local = false;
|
private bool $local = false;
|
||||||
|
|
||||||
private string $origin = '';
|
private string $origin = '';
|
||||||
|
|
||||||
private int $originSource = 0;
|
private int $originSource = 0;
|
||||||
|
|
||||||
private int $originCreationTime = 0;
|
private int $originCreationTime = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getId(): string {
|
public function getId(): string {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $id
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setId(string $id): Item {
|
public function setId(string $id): Item {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getNid(): int {
|
public function getNid(): int {
|
||||||
return $this->nid;
|
return $this->nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $nid
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setNid(int $nid): self {
|
public function setNid(int $nid): self {
|
||||||
$this->nid = $nid;
|
$this->nid = $nid;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getType(): string {
|
public function getType(): string {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setType(string $type): Item {
|
public function setType(string $type): Item {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getSubType(): string {
|
public function getSubType(): string {
|
||||||
return $this->subType;
|
return $this->subType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setSubType(string $type): Item {
|
public function setSubType(string $type): Item {
|
||||||
$this->subType = $type;
|
$this->subType = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getUrl(): string {
|
public function getUrl(): string {
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $url
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setUrl(string $url): Item {
|
public function setUrl(string $url): Item {
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param InstancePath $instancePath
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function addInstancePath(InstancePath $instancePath): Item {
|
public function addInstancePath(InstancePath $instancePath): Item {
|
||||||
if ($instancePath->getUri() !== '') {
|
if ($instancePath->getUri() !== '') {
|
||||||
$this->instancePaths[] = $instancePath;
|
$this->instancePaths[] = $instancePath;
|
||||||
|
@ -202,11 +124,8 @@ class Item {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param InstancePath[] $path
|
* @param InstancePath[] $path
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
*/
|
||||||
public function addInstancePaths(array $path): Item {
|
public function addInstancePaths(array $path): Item {
|
||||||
$this->instancePaths = array_merge($this->instancePaths, $path);
|
$this->instancePaths = array_merge($this->instancePaths, $path);
|
||||||
|
@ -232,10 +151,6 @@ class Item {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getSummary(): string {
|
public function getSummary(): string {
|
||||||
return $this->summary;
|
return $this->summary;
|
||||||
}
|
}
|
||||||
|
@ -255,15 +170,10 @@ class Item {
|
||||||
/**
|
/**
|
||||||
* @return Person
|
* @return Person
|
||||||
*/
|
*/
|
||||||
public function getActor(): Person {
|
public function getActor(): ?Person {
|
||||||
return $this->actor;
|
return $this->actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Person $actor
|
|
||||||
*
|
|
||||||
* @return Item
|
|
||||||
*/
|
|
||||||
public function setActor(Person $actor): Item {
|
public function setActor(Person $actor): Item {
|
||||||
$this->actor = $actor;
|
$this->actor = $actor;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Announce extends Stream implements JsonSerializable {
|
||||||
*
|
*
|
||||||
* @param ACore $parent
|
* @param ACore $parent
|
||||||
*/
|
*/
|
||||||
public function __construct($parent = null) {
|
public function __construct(?ACore $parent = null) {
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
|
|
||||||
$this->setType(self::TYPE);
|
$this->setType(self::TYPE);
|
||||||
|
|
|
@ -58,40 +58,26 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
||||||
public const TYPE_DIRECT = 'direct';
|
public const TYPE_DIRECT = 'direct';
|
||||||
public const TYPE_ANNOUNCE = 'announce';
|
public const TYPE_ANNOUNCE = 'announce';
|
||||||
|
|
||||||
|
|
||||||
private string $activityId = '';
|
private string $activityId = '';
|
||||||
|
|
||||||
private string $content = '';
|
private string $content = '';
|
||||||
|
|
||||||
private string $spoilerText = '';
|
private string $spoilerText = '';
|
||||||
|
|
||||||
private string $language = 'en';
|
private string $language = 'en';
|
||||||
|
|
||||||
private string $attributedTo = '';
|
private string $attributedTo = '';
|
||||||
|
|
||||||
private string $inReplyTo = '';
|
private string $inReplyTo = '';
|
||||||
|
|
||||||
private bool $sensitive = false;
|
private bool $sensitive = false;
|
||||||
|
|
||||||
private string $conversation = '';
|
private string $conversation = '';
|
||||||
|
|
||||||
private ?Cache $cache = null;
|
private ?Cache $cache = null;
|
||||||
|
|
||||||
private int $publishedTime = 0;
|
private int $publishedTime = 0;
|
||||||
|
|
||||||
private ?StreamAction $action = null;
|
private ?StreamAction $action = null;
|
||||||
|
|
||||||
private string $timeline = '';
|
private string $timeline = '';
|
||||||
|
|
||||||
private bool $filterDuplicate = false;
|
private bool $filterDuplicate = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream constructor.
|
* Stream constructor.
|
||||||
*
|
*
|
||||||
* @param null $parent
|
* @param ?ACore $parent
|
||||||
*/
|
*/
|
||||||
public function __construct($parent = null) {
|
public function __construct(?ACore $parent = null) {
|
||||||
parent::__construct($parent);
|
parent::__construct($parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +272,7 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
||||||
/**
|
/**
|
||||||
* @return Cache
|
* @return Cache
|
||||||
*/
|
*/
|
||||||
public function getCache(): Cache {
|
public function getCache(): ?Cache {
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,19 +301,10 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAction(): ?StreamAction {
|
||||||
/**
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function getAction(): StreamAction {
|
|
||||||
return $this->action;
|
return $this->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param StreamAction $action
|
|
||||||
*
|
|
||||||
* @return Stream
|
|
||||||
*/
|
|
||||||
public function setAction(StreamAction $action): Stream {
|
public function setAction(StreamAction $action): Stream {
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
|
|
||||||
|
|
|
@ -107,18 +107,27 @@ class LinkedDataSignature implements JsonSerializable {
|
||||||
return $this->privateKey;
|
return $this->privateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrivateKey(string $privateKey): LinkedDataSignature {
|
public function setPrivateKey(string $privateKey): self {
|
||||||
$this->privateKey = $privateKey;
|
$this->privateKey = $privateKey;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPublicKey(string $publicKey): LinkedDataSignature {
|
public function setPublicKey(string $publicKey): self {
|
||||||
$this->publicKey = $publicKey;
|
$this->publicKey = $publicKey;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getObject(): array {
|
||||||
|
return $this->object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setObject(array $object): self {
|
||||||
|
$this->object = $object;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws LinkedDataSignatureMissingException
|
* @throws LinkedDataSignatureMissingException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,169 +49,88 @@ class StreamAction implements JsonSerializable {
|
||||||
public const BOOSTED = 'boosted';
|
public const BOOSTED = 'boosted';
|
||||||
public const REPLIED = 'replied';
|
public const REPLIED = 'replied';
|
||||||
|
|
||||||
|
|
||||||
private int $id = 0;
|
private int $id = 0;
|
||||||
|
|
||||||
private string $actorId = '';
|
private string $actorId = '';
|
||||||
|
|
||||||
private string $streamId = '';
|
private string $streamId = '';
|
||||||
|
|
||||||
private array $values = [];
|
private array $values = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StreamAction constructor.
|
* StreamAction constructor.
|
||||||
*
|
|
||||||
* @param string $actorId
|
|
||||||
* @param string $streamId
|
|
||||||
*/
|
*/
|
||||||
public function __construct(string $actorId = '', string $streamId = '') {
|
public function __construct(string $actorId = '', string $streamId = '') {
|
||||||
$this->actorId = $actorId;
|
$this->actorId = $actorId;
|
||||||
$this->streamId = $streamId;
|
$this->streamId = $streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId(): int {
|
public function getId(): int {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function setId(int $id): StreamAction {
|
public function setId(int $id): StreamAction {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getActorId(): string {
|
public function getActorId(): string {
|
||||||
return $this->actorId;
|
return $this->actorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $actorId
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function setActorId(string $actorId): StreamAction {
|
public function setActorId(string $actorId): StreamAction {
|
||||||
$this->actorId = $actorId;
|
$this->actorId = $actorId;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getStreamId(): string {
|
public function getStreamId(): string {
|
||||||
return $this->streamId;
|
return $this->streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $streamId
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function setStreamId(string $streamId): StreamAction {
|
public function setStreamId(string $streamId): StreamAction {
|
||||||
$this->streamId = $streamId;
|
$this->streamId = $streamId;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateValue(string $key, string $value): void {
|
||||||
/**
|
|
||||||
* @param string $key
|
|
||||||
* @param string $value
|
|
||||||
*/
|
|
||||||
public function updateValue(string $key, string $value) {
|
|
||||||
$this->values[$key] = $value;
|
$this->values[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function updateValueInt(string $key, int $value): void {
|
||||||
* @param string $key
|
|
||||||
* @param int $value
|
|
||||||
*/
|
|
||||||
public function updateValueInt(string $key, int $value) {
|
|
||||||
$this->values[$key] = $value;
|
$this->values[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function updateValueBool(string $key, bool $value): void {
|
||||||
* @param string $key
|
|
||||||
* @param bool $value
|
|
||||||
*/
|
|
||||||
public function updateValueBool(string $key, bool $value) {
|
|
||||||
$this->values[$key] = $value;
|
$this->values[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $key
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function hasValue(string $key): bool {
|
public function hasValue(string $key): bool {
|
||||||
return (array_key_exists($key, $this->values));
|
return (array_key_exists($key, $this->values));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $key
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getValue(string $key): string {
|
public function getValue(string $key): string {
|
||||||
return $this->values[$key];
|
return $this->values[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $key
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getValueInt(string $key): int {
|
public function getValueInt(string $key): int {
|
||||||
return $this->values[$key];
|
return $this->values[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $key
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getValueBool(string $key): bool {
|
public function getValueBool(string $key): bool {
|
||||||
return $this->values[$key];
|
return $this->values[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getValues(): array {
|
public function getValues(): array {
|
||||||
return $this->values;
|
return $this->values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $values
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function setValues(array $values): StreamAction {
|
public function setValues(array $values): StreamAction {
|
||||||
$this->values = $values;
|
$this->values = $values;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $default
|
|
||||||
*
|
|
||||||
* @return StreamAction
|
|
||||||
*/
|
|
||||||
public function setDefaultValues(array $default): StreamAction {
|
public function setDefaultValues(array $default): StreamAction {
|
||||||
$keys = array_keys($default);
|
$keys = array_keys($default);
|
||||||
foreach ($keys as $k) {
|
foreach ($keys as $k) {
|
||||||
|
@ -223,21 +142,13 @@ class StreamAction implements JsonSerializable {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function importFromDatabase(array $data): void {
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
public function importFromDatabase(array $data) {
|
|
||||||
$this->setId($this->getInt('id', $data, 0));
|
$this->setId($this->getInt('id', $data, 0));
|
||||||
$this->setActorId($this->get('actor_id', $data, ''));
|
$this->setActorId($this->get('actor_id', $data, ''));
|
||||||
$this->setStreamId($this->get('stream_id', $data, ''));
|
$this->setStreamId($this->get('stream_id', $data, ''));
|
||||||
$this->setValues($this->getArray('values', $data, []));
|
$this->setValues($this->getArray('values', $data, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
return [
|
return [
|
||||||
'id' => $this->getId(),
|
'id' => $this->getId(),
|
||||||
|
|
|
@ -44,7 +44,6 @@ use OCA\Social\Model\ActivityPub\Stream;
|
||||||
class StreamDetails implements JsonSerializable {
|
class StreamDetails implements JsonSerializable {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
|
|
||||||
|
|
||||||
private Stream $stream;
|
private Stream $stream;
|
||||||
|
|
||||||
/** @var Person[] */
|
/** @var Person[] */
|
||||||
|
@ -52,82 +51,51 @@ class StreamDetails implements JsonSerializable {
|
||||||
|
|
||||||
/** @var Person[] */
|
/** @var Person[] */
|
||||||
private array $directViewers = [];
|
private array $directViewers = [];
|
||||||
|
|
||||||
private bool $public = false;
|
private bool $public = false;
|
||||||
|
|
||||||
private bool $federated = false;
|
private bool $federated = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StreamDetails constructor.
|
* StreamDetails constructor.
|
||||||
*
|
|
||||||
* @param Stream|null $stream
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Stream $stream = null) {
|
public function __construct(?Stream $stream = null) {
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Stream
|
|
||||||
*/
|
|
||||||
public function getStream(): Stream {
|
public function getStream(): Stream {
|
||||||
return $this->stream;
|
return $this->stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Stream $stream
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function setStream(Stream $stream): self {
|
public function setStream(Stream $stream): self {
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return Person[] */
|
||||||
/**
|
|
||||||
* @return Person[]
|
|
||||||
*/
|
|
||||||
public function getHomeViewers(): array {
|
public function getHomeViewers(): array {
|
||||||
return $this->homeViewers;
|
return $this->homeViewers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @param Person[] $viewers */
|
||||||
* @param Person[] $viewers
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function setHomeViewers(array $viewers): self {
|
public function setHomeViewers(array $viewers): self {
|
||||||
$this->homeViewers = $viewers;
|
$this->homeViewers = $viewers;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Person $viewer
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function addHomeViewer(Person $viewer): self {
|
public function addHomeViewer(Person $viewer): self {
|
||||||
$this->homeViewers[] = $viewer;
|
$this->homeViewers[] = $viewer;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Person[]
|
|
||||||
*/
|
|
||||||
public function getDirectViewers(): array {
|
public function getDirectViewers(): array {
|
||||||
return $this->directViewers;
|
return $this->directViewers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Person[] $viewers
|
* @param Person[] $viewers
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
*/
|
||||||
public function setDirectViewers(array $viewers): self {
|
public function setDirectViewers(array $viewers): self {
|
||||||
$this->directViewers = $viewers;
|
$this->directViewers = $viewers;
|
||||||
|
@ -135,59 +103,32 @@ class StreamDetails implements JsonSerializable {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Person $viewer
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function addDirectViewer(Person $viewer): self {
|
public function addDirectViewer(Person $viewer): self {
|
||||||
$this->directViewers[] = $viewer;
|
$this->directViewers[] = $viewer;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isPublic(): bool {
|
public function isPublic(): bool {
|
||||||
return $this->public;
|
return $this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $public
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function setPublic(bool $public): self {
|
public function setPublic(bool $public): self {
|
||||||
$this->public = $public;
|
$this->public = $public;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isFederated(): bool {
|
public function isFederated(): bool {
|
||||||
return $this->federated;
|
return $this->federated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $federated
|
|
||||||
*
|
|
||||||
* @return StreamDetails
|
|
||||||
*/
|
|
||||||
public function setFederated(bool $federated): self {
|
public function setFederated(bool $federated): self {
|
||||||
$this->federated = $federated;
|
$this->federated = $federated;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
return [
|
return [
|
||||||
'stream' => $this->getStream(),
|
'stream' => $this->getStream(),
|
||||||
|
|
|
@ -44,7 +44,6 @@ use JsonSerializable;
|
||||||
class StreamQueue implements JsonSerializable {
|
class StreamQueue implements JsonSerializable {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
|
|
||||||
|
|
||||||
public const TYPE_CACHE = 'Cache';
|
public const TYPE_CACHE = 'Cache';
|
||||||
public const TYPE_VERIFY = 'Signature';
|
public const TYPE_VERIFY = 'Signature';
|
||||||
|
|
||||||
|
@ -52,58 +51,30 @@ class StreamQueue implements JsonSerializable {
|
||||||
public const STATUS_RUNNING = 1;
|
public const STATUS_RUNNING = 1;
|
||||||
public const STATUS_SUCCESS = 9;
|
public const STATUS_SUCCESS = 9;
|
||||||
|
|
||||||
|
|
||||||
private int $id = 0;
|
private int $id = 0;
|
||||||
|
|
||||||
private string $token = '';
|
private string $token = '';
|
||||||
|
|
||||||
private string $streamId = '';
|
private string $streamId = '';
|
||||||
|
|
||||||
private string $type = '';
|
private string $type = '';
|
||||||
|
|
||||||
private int $status = 0;
|
private int $status = 0;
|
||||||
|
|
||||||
private int $tries = 0;
|
private int $tries = 0;
|
||||||
|
|
||||||
private int $last = 0;
|
private int $last = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StreamQueue constructor.
|
|
||||||
*
|
|
||||||
* @param string $token
|
|
||||||
* @param string $type
|
|
||||||
* @param string $streamId
|
|
||||||
*/
|
|
||||||
public function __construct(string $token = '', string $type = '', string $streamId = '') {
|
public function __construct(string $token = '', string $type = '', string $streamId = '') {
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->streamId = $streamId;
|
$this->streamId = $streamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId(): int {
|
public function getId(): int {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
*
|
|
||||||
* @return StreamQueue
|
|
||||||
*/
|
|
||||||
public function setId(int $id): StreamQueue {
|
public function setId(int $id): StreamQueue {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getToken(): string {
|
public function getToken(): string {
|
||||||
return $this->token;
|
return $this->token;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,51 +61,22 @@ class CheckService {
|
||||||
public const CACHE_PREFIX = 'social_check_';
|
public const CACHE_PREFIX = 'social_check_';
|
||||||
|
|
||||||
private IUserManager $userManager;
|
private IUserManager $userManager;
|
||||||
|
|
||||||
private ICache $cache;
|
private ICache $cache;
|
||||||
|
|
||||||
private IConfig $config;
|
private IConfig $config;
|
||||||
|
|
||||||
private IClientService $clientService;
|
private IClientService $clientService;
|
||||||
|
|
||||||
private IRequest $request;
|
private IRequest $request;
|
||||||
|
|
||||||
private IURLGenerator $urlGenerator;
|
private IURLGenerator $urlGenerator;
|
||||||
|
|
||||||
private FollowsRequest $followRequest;
|
private FollowsRequest $followRequest;
|
||||||
|
|
||||||
private CacheActorsRequest $cacheActorsRequest;
|
private CacheActorsRequest $cacheActorsRequest;
|
||||||
|
|
||||||
private StreamDestRequest $streamDestRequest;
|
private StreamDestRequest $streamDestRequest;
|
||||||
|
|
||||||
private StreamRequest $streamRequest;
|
private StreamRequest $streamRequest;
|
||||||
|
|
||||||
private AccountService $accountService;
|
private AccountService $accountService;
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
private ?string $userId = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CheckService constructor.
|
|
||||||
*
|
|
||||||
* @param IUserManager $userManager
|
|
||||||
* @param ICache $cache
|
|
||||||
* @param IConfig $config
|
|
||||||
* @param IClientService $clientService
|
|
||||||
* @param IRequest $request
|
|
||||||
* @param IURLGenerator $urlGenerator
|
|
||||||
* @param FollowsRequest $followRequest
|
|
||||||
* @param CacheActorsRequest $cacheActorsRequest
|
|
||||||
* @param StreamDestRequest $streamDestRequest
|
|
||||||
* @param StreamRequest $streamRequest
|
|
||||||
* @param AccountService $accountService
|
|
||||||
* @param ConfigService $configService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IUserManager $userManager, ICache $cache, IConfig $config, IClientService $clientService,
|
IUserManager $userManager, ?string $userId, ICache $cache, IConfig $config, IClientService $clientService,
|
||||||
IRequest $request, IURLGenerator $urlGenerator, FollowsRequest $followRequest,
|
IRequest $request, IURLGenerator $urlGenerator, FollowsRequest $followRequest,
|
||||||
CacheActorsRequest $cacheActorsRequest, StreamDestRequest $streamDestRequest,
|
CacheActorsRequest $cacheActorsRequest, StreamDestRequest $streamDestRequest,
|
||||||
StreamRequest $streamRequest, AccountService $accountService, ConfigService $configService,
|
StreamRequest $streamRequest, AccountService $accountService, ConfigService $configService,
|
||||||
|
@ -124,6 +95,7 @@ class CheckService {
|
||||||
$this->accountService = $accountService;
|
$this->accountService = $accountService;
|
||||||
$this->configService = $configService;
|
$this->configService = $configService;
|
||||||
$this->miscService = $miscService;
|
$this->miscService = $miscService;
|
||||||
|
$this->userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,16 +263,12 @@ class CheckService {
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function requestWellKnown(string $base): bool {
|
||||||
/**
|
|
||||||
* @param string $base
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function requestWellKnown(string $base) {
|
|
||||||
try {
|
try {
|
||||||
$url = $base . '/.well-known/webfinger';
|
$url = $base . '/.well-known/webfinger?resource=acct:' . $this->userId . '@' . parse_url($base, PHP_URL_HOST);
|
||||||
$options['nextcloud']['allow_local_address'] = true;
|
$options['nextcloud']['allow_local_address'] = true;
|
||||||
|
$options['verify'] = $this->config->getSystemValue('social.checkssl', true);
|
||||||
|
|
||||||
$response = $this->clientService->newClient()
|
$response = $this->clientService->newClient()
|
||||||
->get($url, $options);
|
->get($url, $options);
|
||||||
if ($response->getStatusCode() === Http::STATUS_OK) {
|
if ($response->getStatusCode() === Http::STATUS_OK) {
|
||||||
|
|
|
@ -87,29 +87,14 @@ class ConfigService {
|
||||||
'WHITELIST' => 'none_but'
|
'WHITELIST' => 'none_but'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private ?string $userId = null;
|
||||||
private string $userId;
|
|
||||||
|
|
||||||
private IConfig $config;
|
private IConfig $config;
|
||||||
|
|
||||||
private IRequest $request;
|
private IRequest $request;
|
||||||
|
|
||||||
private IURLGenerator $urlGenerator;
|
private IURLGenerator $urlGenerator;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ConfigService constructor.
|
|
||||||
*
|
|
||||||
* @param string $userId
|
|
||||||
* @param IConfig $config
|
|
||||||
* @param IRequest $request
|
|
||||||
* @param IURLGenerator $urlGenerator
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$userId, IConfig $config, IRequest $request, IURLGenerator $urlGenerator,
|
?string $userId, IConfig $config, IRequest $request, IURLGenerator $urlGenerator,
|
||||||
MiscService $miscService
|
MiscService $miscService
|
||||||
) {
|
) {
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
|
|
|
@ -65,11 +65,8 @@ class CurlService {
|
||||||
public const ASYNC_REQUEST_TOKEN = '/async/request/{token}';
|
public const ASYNC_REQUEST_TOKEN = '/async/request/{token}';
|
||||||
public const USER_AGENT = 'Nextcloud Social';
|
public const USER_AGENT = 'Nextcloud Social';
|
||||||
|
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private FediverseService $fediverseService;
|
private FediverseService $fediverseService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,10 +112,12 @@ class CurlService {
|
||||||
throw new InvalidResourceException('account format is not valid');
|
throw new InvalidResourceException('account format is not valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($username, $host) = explode('@', $account);
|
$exploded = explode('@', $account);
|
||||||
if ($username === null || $host === null) {
|
|
||||||
|
if (count($exploded) < 2) {
|
||||||
throw new InvalidResourceException();
|
throw new InvalidResourceException();
|
||||||
}
|
}
|
||||||
|
[$username, $host] = $exploded;
|
||||||
|
|
||||||
$protocols = ['https', 'http'];
|
$protocols = ['https', 'http'];
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -69,38 +69,21 @@ use stdClass;
|
||||||
class SignatureService {
|
class SignatureService {
|
||||||
use TArrayTools;
|
use TArrayTools;
|
||||||
|
|
||||||
|
|
||||||
public const ORIGIN_HEADER = 1;
|
public const ORIGIN_HEADER = 1;
|
||||||
public const ORIGIN_SIGNATURE = 2;
|
public const ORIGIN_SIGNATURE = 2;
|
||||||
public const ORIGIN_REQUEST = 3;
|
public const ORIGIN_REQUEST = 3;
|
||||||
|
|
||||||
|
|
||||||
public const DATE_HEADER = 'D, d M Y H:i:s T';
|
public const DATE_HEADER = 'D, d M Y H:i:s T';
|
||||||
public const DATE_OBJECT = 'Y-m-d\TH:i:s\Z';
|
public const DATE_OBJECT = 'Y-m-d\TH:i:s\Z';
|
||||||
|
|
||||||
public const DATE_DELAY = 300;
|
public const DATE_DELAY = 300;
|
||||||
|
|
||||||
|
|
||||||
private CacheActorService $cacheActorService;
|
private CacheActorService $cacheActorService;
|
||||||
|
|
||||||
private ActorsRequest $actorsRequest;
|
private ActorsRequest $actorsRequest;
|
||||||
|
|
||||||
private CurlService $curlService;
|
private CurlService $curlService;
|
||||||
|
|
||||||
private ConfigService $configService;
|
private ConfigService $configService;
|
||||||
|
|
||||||
private MiscService $miscService;
|
private MiscService $miscService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActivityService constructor.
|
|
||||||
*
|
|
||||||
* @param ActorsRequest $actorsRequest
|
|
||||||
* @param CacheActorService $cacheActorService
|
|
||||||
* @param CurlService $curlService
|
|
||||||
* @param ConfigService $configService
|
|
||||||
* @param MiscService $miscService
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ActorsRequest $actorsRequest, CacheActorService $cacheActorService,
|
ActorsRequest $actorsRequest, CacheActorService $cacheActorService,
|
||||||
CurlService $curlService,
|
CurlService $curlService,
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<psalm
|
||||||
|
errorLevel="4"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="https://getpsalm.org/schema/config"
|
||||||
|
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||||
|
errorBaseline="tests/psalm-baseline.xml"
|
||||||
|
>
|
||||||
|
<stubs>
|
||||||
|
<file name="tests/stub.phpstub" preloadClasses="true"/>
|
||||||
|
</stubs>
|
||||||
|
<projectFiles>
|
||||||
|
<directory name="lib" />
|
||||||
|
<ignoreFiles>
|
||||||
|
<directory name="vendor" />
|
||||||
|
</ignoreFiles>
|
||||||
|
</projectFiles>
|
||||||
|
<extraFiles>
|
||||||
|
<directory name="vendor" />
|
||||||
|
<ignoreFiles>
|
||||||
|
<directory name="vendor/phpunit/php-code-coverage" />
|
||||||
|
</ignoreFiles>
|
||||||
|
</extraFiles>
|
||||||
|
<issueHandlers>
|
||||||
|
<UndefinedClass>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<referencedClass name="OC" />
|
||||||
|
</errorLevel>
|
||||||
|
</UndefinedClass>
|
||||||
|
<UndefinedDocblockClass>
|
||||||
|
<errorLevel type="suppress">
|
||||||
|
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
|
||||||
|
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
|
||||||
|
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
|
||||||
|
<referencedClass name="Doctrine\DBAL\Schema\Table" />
|
||||||
|
</errorLevel>
|
||||||
|
</UndefinedDocblockClass>
|
||||||
|
</issueHandlers>
|
||||||
|
</psalm>
|
30
rector.php
30
rector.php
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Rector\Core\Configuration\Option;
|
|
||||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
|
||||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
||||||
|
|
||||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
||||||
$parameters = $containerConfigurator->parameters();
|
|
||||||
$parameters->set(Option::PATHS, [
|
|
||||||
__DIR__ . '/lib',
|
|
||||||
__DIR__ . '/tests/',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$parameters->set(Option::BOOTSTRAP_FILES, [
|
|
||||||
__DIR__ . '/vendor/autoload.php',
|
|
||||||
__DIR__ . '/../../lib/composer/autoload.php',
|
|
||||||
__DIR__ . '/../../3rdparty/autoload.php',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
|
|
||||||
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);
|
|
||||||
|
|
||||||
$services = $containerConfigurator->services();
|
|
||||||
$services->set(TypedPropertyRector::class)
|
|
||||||
->configure([
|
|
||||||
TypedPropertyRector::INLINE_PUBLIC => true,
|
|
||||||
]);
|
|
||||||
};
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
|
||||||
|
<file src="lib/AP.php">
|
||||||
|
<InvalidScalarArgument occurrences="1">
|
||||||
|
<code>$level</code>
|
||||||
|
</InvalidScalarArgument>
|
||||||
|
<UndefinedPropertyAssignment occurrences="3">
|
||||||
|
<code>$ap->groupInterface</code>
|
||||||
|
<code>$ap->groupInterface</code>
|
||||||
|
<code>$ap->groupInterface</code>
|
||||||
|
</UndefinedPropertyAssignment>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Migration/Version0003Date20200823023900.php">
|
||||||
|
<UndefinedDocblockClass occurrences="1">
|
||||||
|
<code>DBALException</code>
|
||||||
|
</UndefinedDocblockClass>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Migration/Version0003Date20200823023911.php">
|
||||||
|
<UndefinedClass occurrences="3">
|
||||||
|
<code>SchemaException</code>
|
||||||
|
<code>SchemaException</code>
|
||||||
|
<code>Type</code>
|
||||||
|
</UndefinedClass>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Model/ActivityPub/ACore.php">
|
||||||
|
<InvalidArgument occurrences="1">
|
||||||
|
<code>['a', 'p', 'span', 'br']</code>
|
||||||
|
</InvalidArgument>
|
||||||
|
<InvalidClass occurrences="1">
|
||||||
|
<code>Acore</code>
|
||||||
|
</InvalidClass>
|
||||||
|
<InvalidNullableReturnType occurrences="4">
|
||||||
|
<code>ACore</code>
|
||||||
|
<code>ACore</code>
|
||||||
|
<code>Document</code>
|
||||||
|
<code>LinkedDataSignature</code>
|
||||||
|
</InvalidNullableReturnType>
|
||||||
|
<InvalidPropertyAssignmentValue occurrences="1">
|
||||||
|
<code>$parent</code>
|
||||||
|
</InvalidPropertyAssignmentValue>
|
||||||
|
<NullableReturnStatement occurrences="4">
|
||||||
|
<code>$this->icon</code>
|
||||||
|
<code>$this->object</code>
|
||||||
|
<code>$this->parent</code>
|
||||||
|
<code>$this->signature</code>
|
||||||
|
</NullableReturnStatement>
|
||||||
|
<TypeDoesNotContainNull occurrences="1">
|
||||||
|
<code>$v === null</code>
|
||||||
|
</TypeDoesNotContainNull>
|
||||||
|
<TypeDoesNotContainType occurrences="2">
|
||||||
|
<code>$v === 0</code>
|
||||||
|
<code>$v === 0</code>
|
||||||
|
</TypeDoesNotContainType>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Model/ActivityPub/Object/Announce.php">
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>$object = $cache->getItem($this->getObjectId())</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Model/Instance.php">
|
||||||
|
<InvalidNullableReturnType occurrences="2">
|
||||||
|
<code>Person</code>
|
||||||
|
<code>string</code>
|
||||||
|
</InvalidNullableReturnType>
|
||||||
|
<NullableReturnStatement occurrences="2">
|
||||||
|
<code>$this->accountPrim</code>
|
||||||
|
<code>$this->contactAccount</code>
|
||||||
|
</NullableReturnStatement>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Model/LinkedDataSignature.php">
|
||||||
|
<UndefinedMethod occurrences="1">
|
||||||
|
<code>getPublicKey</code>
|
||||||
|
</UndefinedMethod>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Model/RequestQueue.php">
|
||||||
|
<InvalidNullableReturnType occurrences="1">
|
||||||
|
<code>InstancePath</code>
|
||||||
|
</InvalidNullableReturnType>
|
||||||
|
<NullableReturnStatement occurrences="1">
|
||||||
|
<code>$this->instance</code>
|
||||||
|
</NullableReturnStatement>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/CheckService.php">
|
||||||
|
<RedundantCast occurrences="1">
|
||||||
|
<code>(bool)($this->cache->get(self::CACHE_PREFIX . 'wellknown') === 'true')</code>
|
||||||
|
</RedundantCast>
|
||||||
|
<UndefinedClass occurrences="1">
|
||||||
|
<code>ClientException</code>
|
||||||
|
</UndefinedClass>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/CurlService.php">
|
||||||
|
<InvalidOperand occurrences="1">
|
||||||
|
<code>$this->configService->getAppValue(ConfigService::SOCIAL_MAX_SIZE)</code>
|
||||||
|
</InvalidOperand>
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>is_array($result)</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/FollowService.php">
|
||||||
|
<InvalidReturnStatement occurrences="2">
|
||||||
|
<code>$this->followsRequest->getFollowersByActorId($actor->getId())</code>
|
||||||
|
<code>$this->followsRequest->getFollowingByActorId($actor->getId())</code>
|
||||||
|
</InvalidReturnStatement>
|
||||||
|
<InvalidReturnType occurrences="2">
|
||||||
|
<code>Person[]</code>
|
||||||
|
<code>Person[]</code>
|
||||||
|
</InvalidReturnType>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/HashtagService.php">
|
||||||
|
<InvalidReturnStatement occurrences="1">
|
||||||
|
<code>$result</code>
|
||||||
|
</InvalidReturnStatement>
|
||||||
|
<InvalidReturnType occurrences="1">
|
||||||
|
<code>Stream[]</code>
|
||||||
|
</InvalidReturnType>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/PostService.php">
|
||||||
|
<InvalidNullableReturnType occurrences="1">
|
||||||
|
<code>ACore</code>
|
||||||
|
</InvalidNullableReturnType>
|
||||||
|
<NullableReturnStatement occurrences="1">
|
||||||
|
<code>$activity</code>
|
||||||
|
</NullableReturnStatement>
|
||||||
|
<UndefinedMethod occurrences="2">
|
||||||
|
<code>setAttributedTo</code>
|
||||||
|
<code>setContent</code>
|
||||||
|
</UndefinedMethod>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/SearchService.php">
|
||||||
|
<InvalidOperand occurrences="3">
|
||||||
|
<code>!$type</code>
|
||||||
|
<code>!$type</code>
|
||||||
|
<code>!$type</code>
|
||||||
|
</InvalidOperand>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/SignatureService.php">
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>$varr[0] !== null</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
<UndefinedInterfaceMethod occurrences="1">
|
||||||
|
<code>getAppDataDir</code>
|
||||||
|
</UndefinedInterfaceMethod>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/StreamService.php">
|
||||||
|
<InvalidReturnType occurrences="1">
|
||||||
|
<code>Note[]</code>
|
||||||
|
</InvalidReturnType>
|
||||||
|
</file>
|
||||||
|
<file src="lib/Service/TestService.php">
|
||||||
|
<TypeDoesNotContainNull occurrences="3">
|
||||||
|
<code>$host === null</code>
|
||||||
|
<code>$username === null</code>
|
||||||
|
<code>$username === null</code>
|
||||||
|
</TypeDoesNotContainNull>
|
||||||
|
</file>
|
||||||
|
</files>
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue