kopia lustrzana https://github.com/nextcloud/social
rodzic
be80ca5d0f
commit
9e20993c4d
|
@ -0,0 +1,31 @@
|
|||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
xml-linters:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: info.xml lint
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Download schema
|
||||
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
|
||||
|
||||
- name: Lint info.xml
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: ./appinfo/info.xml
|
||||
xml-schema-file: ./info.xsd
|
|
@ -0,0 +1,36 @@
|
|||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: php-cs
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: "7.4"
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer i
|
||||
|
||||
- name: Lint
|
||||
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
|
|
@ -0,0 +1,48 @@
|
|||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
php-lint:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ["7.4", "8.0"]
|
||||
|
||||
name: php-lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
coverage: none
|
||||
|
||||
- name: Lint
|
||||
run: composer run lint
|
||||
|
||||
summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: php-lint
|
||||
|
||||
if: always()
|
||||
|
||||
name: php-lint-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
|
|
@ -6,3 +6,5 @@ img/twemoji/
|
|||
|
||||
cypress/screenshots
|
||||
cypress/snapshots
|
||||
|
||||
.php-cs-fixer.cache
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once './vendor/autoload.php';
|
||||
|
||||
use Nextcloud\CodingStandard\Config;
|
||||
|
||||
$config = new Config();
|
||||
$config
|
||||
->getFinder()
|
||||
->notPath('build')
|
||||
->notPath('l10n')
|
||||
->notPath('src')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__);
|
||||
return $config;
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,19 +31,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\AppInfo;
|
||||
|
||||
|
||||
use OCA\Social\Service\CurlService;
|
||||
|
||||
|
||||
return [
|
||||
'routes' => [
|
||||
['name' => 'Navigation#navigate', 'url' => '/', 'verb' => 'GET'],
|
||||
['name' => 'Config#local', 'url' => '/local/', 'verb' => 'GET'],
|
||||
['name' => 'Config#remote', 'url' => '/test/{account}/', 'verb' => 'GET'],
|
||||
[
|
||||
'name' => 'Navigation#timeline', 'url' => '/timeline/{path}', 'verb' => 'GET',
|
||||
'name' => 'Navigation#timeline', 'url' => '/timeline/{path}', 'verb' => 'GET',
|
||||
'requirements' => ['path' => '.+'],
|
||||
'defaults' => ['path' => '']
|
||||
'defaults' => ['path' => '']
|
||||
],
|
||||
['name' => 'Navigation#documentGet', 'url' => '/document/get', 'verb' => 'GET'],
|
||||
['name' => 'Navigation#documentGetPublic', 'url' => '/document/public', 'verb' => 'GET'],
|
||||
|
|
|
@ -29,8 +29,20 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"jakub-onderka/php-parallel-lint": "^1.0",
|
||||
"phpunit/phpunit": "^6.4",
|
||||
"rector/rector": "^0.12.20"
|
||||
"rector/rector": "^0.12.20",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"nextcloud/coding-standard": "^1.0.0",
|
||||
"christophwurst/nextcloud": "dev-master",
|
||||
"vimeo/psalm": "^4.22.0"
|
||||
},
|
||||
"scripts": {
|
||||
"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:fix": "php-cs-fixer fix",
|
||||
"psalm": "psalm --threads=1",
|
||||
"psalm:update-baseline": "psalm --threads=1 --update-baseline",
|
||||
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
|
||||
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
|
Plik diff jest za duży
Load Diff
10
lib/AP.php
10
lib/AP.php
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OC;
|
||||
use OCA\Social\Exceptions\ItemUnknownException;
|
||||
|
@ -85,19 +85,16 @@ use OCA\Social\Model\ActivityPub\Stream;
|
|||
use OCA\Social\Service\ConfigService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
|
||||
/**
|
||||
* Class AP
|
||||
*
|
||||
* @package OCA\Social
|
||||
*/
|
||||
class AP {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
const REDUNDANCY_LIMIT = 10;
|
||||
public const REDUNDANCY_LIMIT = 10;
|
||||
|
||||
|
||||
/** @var AcceptInterface */
|
||||
|
@ -304,7 +301,6 @@ class AP {
|
|||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function getItemFromType(string $type): ACore {
|
||||
|
||||
switch ($type) {
|
||||
case Accept::TYPE:
|
||||
$item = new Accept();
|
||||
|
@ -525,9 +521,7 @@ class AP {
|
|||
|
||||
return (in_array($item->getType(), $types));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
AP::init();
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\AppInfo;
|
||||
|
||||
|
||||
use Closure;
|
||||
use OC\DB\SchemaWrapper;
|
||||
use OCA\Social\Notification\Notifier;
|
||||
|
@ -55,7 +55,7 @@ require_once __DIR__ . '/../../vendor/autoload.php';
|
|||
* @package OCA\Social\AppInfo
|
||||
*/
|
||||
class Application extends App implements IBootstrap {
|
||||
const APP_NAME = 'social';
|
||||
public const APP_NAME = 'social';
|
||||
|
||||
public function __construct(array $params = []) {
|
||||
parent::__construct(self::APP_NAME, $params);
|
||||
|
@ -113,6 +113,4 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
$configService->setAppValue('update_checked', '0.3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Service\AccountService;
|
||||
|
@ -43,7 +43,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class AccountCreate extends Base {
|
||||
private IUserManager $userManager;
|
||||
private AccountService $accountService;
|
||||
|
@ -90,4 +89,3 @@ class AccountCreate extends Base {
|
|||
$this->accountService->createActor($userId, $handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Service\AccountService;
|
||||
|
@ -43,7 +43,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class AccountFollowing extends Base {
|
||||
private AccountService $accountService;
|
||||
private CacheActorService $cacheActorService;
|
||||
|
@ -93,6 +92,4 @@ class AccountFollowing extends Base {
|
|||
$this->followService->followAccount($actor, $account);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,19 +31,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\DocumentService;
|
||||
use OCA\Social\Service\HashtagService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class CacheRefresh extends Base {
|
||||
private AccountService $accountService;
|
||||
private CacheActorService $cacheActorService;
|
||||
|
@ -71,7 +68,6 @@ class CacheRefresh extends Base {
|
|||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$result = $this->accountService->blindKeyRotation();
|
||||
$output->writeLn($result . ' key pairs refreshed');
|
||||
|
||||
|
@ -91,4 +87,3 @@ class CacheRefresh extends Base {
|
|||
$output->writeLn($result . ' hashtags updated');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
|
@ -49,46 +49,19 @@ use Symfony\Component\Console\Input\InputOption;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
|
||||
class CheckInstall extends Base {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
private IUserManager $userManager;
|
||||
|
||||
private StreamRequest $streamRequest;
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private StreamDestRequest $streamDestRequest;
|
||||
|
||||
private StreamTagsRequest $streamTagsRequest;
|
||||
|
||||
private CheckService $checkService;
|
||||
|
||||
/** @var */
|
||||
private $configService;
|
||||
|
||||
private ConfigService $configService;
|
||||
private PushService $pushService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* CacheUpdate constructor.
|
||||
*
|
||||
* @param IUserManager $userManager
|
||||
* @param StreamRequest $streamRequest
|
||||
* @param StreamDestRequest $streamDestRequest
|
||||
* @param StreamTagsRequest $streamTagsRequest
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param CheckService $checkService
|
||||
* @param ConfigService $configService
|
||||
* @param PushService $pushService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IUserManager $userManager, StreamRequest $streamRequest, StreamDestRequest $streamDestRequest,
|
||||
StreamTagsRequest $streamTagsRequest, CacheActorService $cacheActorService,
|
||||
|
@ -108,10 +81,6 @@ class CheckInstall extends Base {
|
|||
$this->pushService = $pushService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure() {
|
||||
parent::configure();
|
||||
$this->setName('social:check:install')
|
||||
|
@ -126,9 +95,6 @@ class CheckInstall extends Base {
|
|||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
@ -150,7 +116,6 @@ class CheckInstall extends Base {
|
|||
$output->writeln(json_encode($this->configService->getConfig(), JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
|
@ -210,10 +175,6 @@ class CheckInstall extends Base {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function regenerateIndex(OutputInterface $output) {
|
||||
$streams = $this->streamRequest->getAll();
|
||||
$progressBar = new ProgressBar($output, count($streams));
|
||||
|
@ -232,6 +193,4 @@ class CheckInstall extends Base {
|
|||
$progressBar->finish();
|
||||
$output->writeln('');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\CacheItemNotFoundException;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\AP;
|
||||
|
@ -41,18 +41,11 @@ use OCA\Social\Model\ActivityPub\Stream;
|
|||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class ExtendedBase extends Base {
|
||||
|
||||
protected ?OutputInterface $output = null;
|
||||
|
||||
protected bool $asJson = false;
|
||||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
*/
|
||||
protected function outputActor(Person $actor) {
|
||||
protected function outputActor(Person $actor): void {
|
||||
if ($this->asJson) {
|
||||
$this->output->writeln(json_encode($actor, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
@ -60,7 +53,6 @@ class ExtendedBase extends Base {
|
|||
$this->output->writeln('<info>Account</info>: ' . $actor->getAccount());
|
||||
$this->output->writeln('<info>Id</info>: ' . $actor->getId());
|
||||
$this->output->writeln('');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,5 +120,4 @@ class ExtendedBase extends Base {
|
|||
);
|
||||
$this->output->writeln('type: <info>' . $stream->getType() . '</info>');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,59 +31,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\UnauthorizedFediverseException;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\FediverseService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class Fediverse
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class Fediverse extends Base {
|
||||
|
||||
|
||||
private FediverseService $fediverseService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
private ?OutputInterface $output = null;
|
||||
|
||||
|
||||
/**
|
||||
* CacheUpdate constructor.
|
||||
*
|
||||
* @param FediverseService $fediverseService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
FediverseService $fediverseService, ConfigService $configService,
|
||||
MiscService $miscService
|
||||
) {
|
||||
public function __construct(FediverseService $fediverseService) {
|
||||
parent::__construct();
|
||||
|
||||
$this->fediverseService = $fediverseService;
|
||||
$this->configService = $configService;
|
||||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure() {
|
||||
parent::configure();
|
||||
$this->setName('social:fediverse')
|
||||
|
@ -95,11 +66,7 @@ class Fediverse extends Base {
|
|||
->setDescription('Allow or deny access to the fediverse');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
@ -143,14 +110,10 @@ class Fediverse extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
private function typeAccess(string $type) {
|
||||
private function typeAccess(string $type): bool {
|
||||
if ($type === '') {
|
||||
return false;
|
||||
}
|
||||
|
@ -160,12 +123,7 @@ class Fediverse extends Base {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $allKnownAddress
|
||||
*/
|
||||
private function listAddresses(bool $allKnownAddress = false) {
|
||||
|
||||
private function listAddresses(bool $allKnownAddress = false): void {
|
||||
if ($allKnownAddress) {
|
||||
$this->output->writeln('- Known address:');
|
||||
foreach ($this->fediverseService->getKnownAddresses() as $address) {
|
||||
|
@ -177,35 +135,26 @@ class Fediverse extends Base {
|
|||
foreach ($this->fediverseService->getListedAddresses() as $address) {
|
||||
$this->output->writeln(' <info>' . $address . '</info>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function addAddress(string $address) {
|
||||
private function addAddress(string $address): void {
|
||||
$this->fediverseService->addAddress($address);
|
||||
$this->output->writeln('<info>' . $address . '</info> added to the list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function removeAddress(string $address) {
|
||||
private function removeAddress(string $address): void {
|
||||
$this->fediverseService->removeAddress($address);
|
||||
$this->output->writeln('<info>' . $address . '</info> removed from the list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
private function testAddress(string $address) {
|
||||
|
@ -217,15 +166,8 @@ class Fediverse extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function resetAddresses() {
|
||||
$this->fediverseService->resetAddresses();
|
||||
$this->output->writeln('list is now empty');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
|
@ -46,58 +46,47 @@ use Symfony\Component\Console\Input\InputOption;
|
|||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
|
||||
class MigrateAlpha3 extends Base {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
private IDBConnection $dbConnection;
|
||||
|
||||
private CoreRequestBuilder $coreRequestBuilder;
|
||||
|
||||
private CheckService $checkService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
private array $done = [];
|
||||
|
||||
|
||||
public array $tables = [
|
||||
'social_a2_actions' => [
|
||||
'social_a2_actions' => [
|
||||
['id_prim'],
|
||||
'social_3_action',
|
||||
[
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'object_id_prim' => 'PRIM:object_id'
|
||||
]
|
||||
],
|
||||
'social_a2_actors' => [['user_id'], 'social_3_actor', []],
|
||||
'social_a2_cache_actors' => [['id_prim'], 'social_3_cache_actor', []],
|
||||
'social_a2_actors' => [['user_id'], 'social_3_actor', []],
|
||||
'social_a2_cache_actors' => [['id_prim'], 'social_3_cache_actor', []],
|
||||
'social_a2_cache_documts' => [['id_prim'], 'social_3_cache_doc', []],
|
||||
'social_a2_follows' => [
|
||||
'social_a2_follows' => [
|
||||
['id_prim'],
|
||||
'social_3_follow',
|
||||
[
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'object_id_prim' => 'PRIM:object_id',
|
||||
'follow_id_prim' => 'PRIM:follow_id'
|
||||
]
|
||||
],
|
||||
|
||||
'social_a2_hashtags' => [['hashtag'], 'social_3_hashtag', []],
|
||||
'social_a2_hashtags' => [['hashtag'], 'social_3_hashtag', []],
|
||||
'social_a2_request_queue' => [['id'], 'social_3_req_queue', []],
|
||||
'social_a2_stream' => [
|
||||
'social_a2_stream' => [
|
||||
['id_prim'],
|
||||
'social_3_stream',
|
||||
[
|
||||
'object_id_prim' => 'PRIM:object_id',
|
||||
'in_reply_to_prim' => 'PRIM:in_reply_to',
|
||||
'object_id_prim' => 'PRIM:object_id',
|
||||
'in_reply_to_prim' => 'PRIM:in_reply_to',
|
||||
'attributed_to_prim' => 'PRIM:attributed_to',
|
||||
'filter_duplicate' => 'COPY:hidden_on_timeline',
|
||||
'filter_duplicate' => 'COPY:hidden_on_timeline',
|
||||
'hidden_on_timeline' => 'REMOVED:'
|
||||
]
|
||||
],
|
||||
|
@ -105,24 +94,14 @@ class MigrateAlpha3 extends Base {
|
|||
['id'],
|
||||
'social_3_stream_act',
|
||||
[
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'actor_id_prim' => 'PRIM:actor_id',
|
||||
'stream_id_prim' => 'PRIM:stream_id',
|
||||
'_function_' => 'migrateTableStreamAction'
|
||||
'_function_' => 'migrateTableStreamAction'
|
||||
]
|
||||
],
|
||||
'social_a2_stream_queue' => [['id'], 'social_3_stream_queue', []]
|
||||
'social_a2_stream_queue' => [['id'], 'social_3_stream_queue', []]
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* CacheUpdate constructor.
|
||||
*
|
||||
* @param IDBConnection $dbConnection
|
||||
* @param CoreRequestBuilder $coreRequestBuilder
|
||||
* @param CheckService $checkService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IDBConnection $dbConnection, CoreRequestBuilder $coreRequestBuilder, CheckService $checkService,
|
||||
ConfigService $configService, MiscService $miscService
|
||||
|
@ -135,10 +114,6 @@ class MigrateAlpha3 extends Base {
|
|||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure() {
|
||||
parent::configure();
|
||||
$this->setName('social:migrate:alpha3')
|
||||
|
@ -153,9 +128,6 @@ class MigrateAlpha3 extends Base {
|
|||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
@ -216,8 +188,6 @@ class MigrateAlpha3 extends Base {
|
|||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function confirmExecute(InputInterface $input, OutputInterface $output): bool {
|
||||
$helper = $this->getHelper('question');
|
||||
|
@ -234,11 +204,7 @@ class MigrateAlpha3 extends Base {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
* @param array $tables
|
||||
*/
|
||||
private function migrateTables(OutputInterface $output, array $tables) {
|
||||
private function migrateTables(OutputInterface $output, array $tables): void {
|
||||
foreach ($tables as $table) {
|
||||
try {
|
||||
$this->migrateTable($output, $table);
|
||||
|
@ -250,15 +216,9 @@ class MigrateAlpha3 extends Base {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param OutputInterface $output
|
||||
* @param string $table
|
||||
*/
|
||||
private function migrateTable(OutputInterface $output, string $table) {
|
||||
private function migrateTable(OutputInterface $output, string $table): void {
|
||||
$output->writeln('');
|
||||
$output->writeln('Retrieving data from \'' . $table . '\'.');
|
||||
$fullContent = $this->getContentFromTable($table);
|
||||
|
@ -282,12 +242,6 @@ class MigrateAlpha3 extends Base {
|
|||
$this->done[] = $table;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getContentFromTable(string $table): array {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
|
||||
|
@ -304,13 +258,6 @@ class MigrateAlpha3 extends Base {
|
|||
return $entries;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param $entry
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function migrateEntry(string $table, $entry): bool {
|
||||
if (!$this->checkUnique($table, $entry)) {
|
||||
return false;
|
||||
|
@ -333,7 +280,7 @@ class MigrateAlpha3 extends Base {
|
|||
if ($this->get($k, $entry, '') !== '') {
|
||||
$this->manageDefault($qb, $this->get($k, $destDefault), $entry);
|
||||
$value = $entry[$k];
|
||||
} else if (array_key_exists($k, $destDefault)) {
|
||||
} elseif (array_key_exists($k, $destDefault)) {
|
||||
$value = $this->manageDefault($qb, $destDefault[$k], $entry);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
@ -354,13 +301,6 @@ class MigrateAlpha3 extends Base {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
* @param $entry
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkUnique(string $table, $entry): bool {
|
||||
list($unique, $destTable) = $this->tables[$table];
|
||||
|
||||
|
@ -375,7 +315,7 @@ class MigrateAlpha3 extends Base {
|
|||
}
|
||||
$qb->andWhere($andX);
|
||||
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
$data = $cursor->fetch();
|
||||
$cursor->closeCursor();
|
||||
|
||||
|
@ -388,10 +328,6 @@ class MigrateAlpha3 extends Base {
|
|||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $default
|
||||
* @param array $entry
|
||||
*
|
||||
* @return IParameter|string
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -423,11 +359,6 @@ class MigrateAlpha3 extends Base {
|
|||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
private function dropDeprecatedTables(InputInterface $input, OutputInterface $output) {
|
||||
$helper = $this->getHelper('question');
|
||||
$output->writeln('');
|
||||
|
@ -445,20 +376,11 @@ class MigrateAlpha3 extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $table
|
||||
*/
|
||||
private function dropTable(string $table) {
|
||||
private function dropTable(string $table): void {
|
||||
$this->dbConnection->dropTable($table);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param array $entry
|
||||
*/
|
||||
public function migrateTableStreamAction(IQueryBuilder $qb, array $entry) {
|
||||
public function migrateTableStreamAction(IQueryBuilder $qb, array $entry): void {
|
||||
$values = json_decode($entry['values'], true);
|
||||
if ($values === null) {
|
||||
return;
|
||||
|
@ -470,6 +392,4 @@ class MigrateAlpha3 extends Base {
|
|||
$qb->setValue('liked', $qb->createNamedParameter($liked));
|
||||
$qb->setValue('boosted', $qb->createNamedParameter($boosted));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Service\AccountService;
|
||||
|
@ -42,14 +42,12 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class NoteBoost
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class NoteBoost extends Base {
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
@ -115,6 +113,4 @@ class NoteBoost extends Base {
|
|||
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
||||
echo 'token: ' . $token . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Model\Post;
|
||||
|
@ -45,15 +45,12 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class NoteCreate
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class NoteCreate extends Base {
|
||||
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private ActivityService $activityService;
|
||||
|
@ -125,7 +122,6 @@ class NoteCreate extends Base {
|
|||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$userId = $input->getArgument('userid');
|
||||
$content = $input->getArgument('content');
|
||||
$to = $input->getOption('to');
|
||||
|
@ -146,6 +142,4 @@ class NoteCreate extends Base {
|
|||
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
||||
echo 'token: ' . $token . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Service\AccountService;
|
||||
|
@ -42,15 +42,12 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class NoteLike
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class NoteLike extends Base {
|
||||
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
@ -116,6 +113,4 @@ class NoteLike extends Base {
|
|||
echo 'object: ' . json_encode($activity, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
||||
echo 'token: ' . $token . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
|
@ -41,10 +41,7 @@ use OCA\Social\Service\StreamQueueService;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class QueueProcess extends Base {
|
||||
|
||||
|
||||
private ActivityService $activityService;
|
||||
|
||||
private StreamQueueService $streamQueueService;
|
||||
|
@ -95,7 +92,6 @@ class QueueProcess extends Base {
|
|||
* @param OutputInterface $output
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$output->writeLn('processing requests queue');
|
||||
$this->processRequestQueue($output);
|
||||
|
||||
|
@ -156,5 +152,4 @@ class QueueProcess extends Base {
|
|||
|
||||
$output->writeLn('done');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -39,10 +40,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
class QueueStatus extends Base {
|
||||
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private RequestQueueService $requestQueueService;
|
||||
|
@ -88,7 +86,6 @@ class QueueStatus extends Base {
|
|||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$token = $input->getOption('token');
|
||||
|
||||
if ($token === null) {
|
||||
|
@ -100,8 +97,5 @@ class QueueStatus extends Base {
|
|||
foreach ($requests as $request) {
|
||||
$output->writeLn(json_encode($request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\Core\Command\Base;
|
||||
use OCA\Social\Db\CoreRequestBuilder;
|
||||
|
@ -43,10 +43,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
|
||||
class Reset extends Base {
|
||||
|
||||
|
||||
private CoreRequestBuilder $coreRequestBuilder;
|
||||
|
||||
private CheckService $checkService;
|
||||
|
@ -95,7 +92,6 @@ class Reset extends Base {
|
|||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$helper = $this->getHelper('question');
|
||||
$output->writeln(
|
||||
'<error>Beware, this operation will delete all content from the Social App.</error>'
|
||||
|
@ -192,6 +188,4 @@ class Reset extends Base {
|
|||
$this->configService->unsetCoreValue('public_host-meta-json');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
|
@ -43,15 +43,12 @@ use Symfony\Component\Console\Input\InputOption;
|
|||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamDetails
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class StreamDetails extends ExtendedBase {
|
||||
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private DetailsService $detailsService;
|
||||
|
@ -121,14 +118,14 @@ class StreamDetails extends ExtendedBase {
|
|||
|
||||
$this->output->writeln('<comment>Affected Timelines</comment>:');
|
||||
$home = array_map(
|
||||
function(Person $item): string {
|
||||
function (Person $item): string {
|
||||
return $item->getUserId();
|
||||
}, $details->getHomeViewers()
|
||||
);
|
||||
|
||||
$this->output->writeln('* <info>Home</info>: ' . json_encode($home, JSON_PRETTY_PRINT));
|
||||
$direct = array_map(
|
||||
function(Person $item): string {
|
||||
function (Person $item): string {
|
||||
return $item->getUserId();
|
||||
}, $details->getDirectViewers()
|
||||
);
|
||||
|
@ -137,6 +134,4 @@ class StreamDetails extends ExtendedBase {
|
|||
$this->output->writeln('* <info>Public</info>: ' . ($details->isPublic() ? 'true' : 'false'));
|
||||
$this->output->writeln('* <info>Federated</info>: ' . ($details->isFederated() ? 'true' : 'false'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Command;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OCA\Social\Db\StreamRequest;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
|
@ -44,14 +44,12 @@ use Symfony\Component\Console\Input\InputOption;
|
|||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class Stream
|
||||
*
|
||||
* @package OCA\Social\Command
|
||||
*/
|
||||
class Timeline extends ExtendedBase {
|
||||
|
||||
private IUserManager $userManager;
|
||||
|
||||
private StreamRequest $streamRequest;
|
||||
|
@ -178,6 +176,4 @@ class Timeline extends ExtendedBase {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\nc20\TNC20Logger;
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TAsync;
|
||||
|
@ -59,55 +59,24 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
||||
class ActivityPubController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
use TStringTools;
|
||||
use TAsync;
|
||||
use TNC20Logger;
|
||||
|
||||
use TNC20Logger;
|
||||
|
||||
private SocialPubController $socialPubController;
|
||||
|
||||
private FediverseService $fediverseService;
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private SignatureService $signatureService;
|
||||
|
||||
private StreamQueueService $streamQueueService;
|
||||
|
||||
private ImportService $importService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private FollowService $followService;
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityPubController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param SocialPubController $socialPubController
|
||||
* @param FediverseService $fediverseService
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param SignatureService $signatureService
|
||||
* @param StreamQueueService $streamQueueService
|
||||
* @param ImportService $importService
|
||||
* @param AccountService $accountService
|
||||
* @param FollowService $followService
|
||||
* @param StreamService $streamService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, SocialPubController $socialPubController, FediverseService $fediverseService,
|
||||
CacheActorService $cacheActorService, SignatureService $signatureService,
|
||||
|
@ -465,5 +434,3 @@ use TNC20Logger;
|
|||
return substr($header, 0, $pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
|
@ -55,58 +55,27 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
|
||||
|
||||
/**
|
||||
* Class ApiController
|
||||
*
|
||||
* @package OCA\Social\Controller
|
||||
*/
|
||||
class ApiController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
private IUserSession $userSession;
|
||||
|
||||
private InstanceService $instanceService;
|
||||
|
||||
private ClientService $clientService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private FollowService $followService;
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
private string $bearer = '';
|
||||
|
||||
private ?SocialClient $client = null;
|
||||
|
||||
private ?Person $viewer = null;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityStreamController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param IUserSession $userSession
|
||||
* @param InstanceService $instanceService
|
||||
* @param ClientService $clientService
|
||||
* @param AccountService $accountService
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param FollowService $followService
|
||||
* @param StreamService $streamService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, IUserSession $userSession, InstanceService $instanceService,
|
||||
ClientService $clientService, AccountService $accountService, CacheActorService $cacheActorService,
|
||||
|
@ -148,14 +117,14 @@ class ApiController extends Controller {
|
|||
if ($this->client === null) {
|
||||
return new DataResponse(
|
||||
[
|
||||
'name' => 'Nextcloud Social',
|
||||
'name' => 'Nextcloud Social',
|
||||
'website' => 'https://github.com/nextcloud/social/'
|
||||
], Http::STATUS_OK
|
||||
);
|
||||
} else {
|
||||
return new DataResponse(
|
||||
[
|
||||
'name' => $this->client->getAppName(),
|
||||
'name' => $this->client->getAppName(),
|
||||
'website' => $this->client->getAppWebsite()
|
||||
], Http::STATUS_OK
|
||||
);
|
||||
|
@ -163,7 +132,6 @@ class ApiController extends Controller {
|
|||
} catch (Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,7 +303,4 @@ class ApiController extends Controller {
|
|||
private function error(string $error): DataResponse {
|
||||
return new DataResponse(['error' => $error], Http::STATUS_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
|
@ -37,20 +38,13 @@ use OCP\AppFramework\Http;
|
|||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
||||
class ConfigController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
private TestService $testService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
public function __construct(
|
||||
string $appName, IRequest $request, TestService $testService,
|
||||
ConfigService $configService, MiscService $miscService
|
||||
|
@ -62,11 +56,6 @@ class ConfigController extends Controller {
|
|||
$this->miscService = $miscService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cloudAddress
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function setCloudAddress(string $cloudAddress): DataResponse {
|
||||
$this->configService->setCloudUrl($cloudAddress);
|
||||
|
||||
|
@ -79,8 +68,6 @@ class ConfigController extends Controller {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function local(): DataResponse {
|
||||
$setup = false;
|
||||
|
@ -93,7 +80,7 @@ class ConfigController extends Controller {
|
|||
return $this->success(
|
||||
[
|
||||
'version' => $this->configService->getAppValue('installed_version'),
|
||||
'setup' => $setup
|
||||
'setup' => $setup
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -104,10 +91,6 @@ class ConfigController extends Controller {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $account
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function remote(string $account): DataResponse {
|
||||
if ($account === '' || $this->configService->getSystemValue('social.tests') === '') {
|
||||
|
@ -122,7 +105,7 @@ class ConfigController extends Controller {
|
|||
|
||||
$tests = new SimpleDataStore(
|
||||
[
|
||||
'account' => $account,
|
||||
'account' => $account,
|
||||
'endpoint' => $this->configService->getSystemValue('social.tests')
|
||||
]
|
||||
);
|
||||
|
@ -134,6 +117,4 @@ class ConfigController extends Controller {
|
|||
|
||||
return $this->success([$tests]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
|
@ -59,66 +59,31 @@ use OCP\AppFramework\Http\FileDisplayResponse;
|
|||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
||||
/**
|
||||
* Class LocalController
|
||||
*
|
||||
* @package OCA\Social\Controller
|
||||
*/
|
||||
class LocalController extends Controller {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
private string $userId;
|
||||
|
||||
private ?string $userId = null;
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private HashtagService $hashtagService;
|
||||
|
||||
private FollowService $followService;
|
||||
|
||||
private BoostService $boostService;
|
||||
|
||||
private LikeService $likeService;
|
||||
|
||||
private PostService $postService;
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private SearchService $searchService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private DocumentService $documentService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
private ?Person $viewer = null;
|
||||
|
||||
|
||||
/**
|
||||
* LocalController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param string $userId
|
||||
* @param AccountService $accountService
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param HashtagService $hashtagService
|
||||
* @param FollowService $followService
|
||||
* @param PostService $postService
|
||||
* @param StreamService $streamService
|
||||
* @param SearchService $searchService
|
||||
* @param BoostService $boostService
|
||||
* @param LikeService $likeService
|
||||
* @param DocumentService $documentService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, $userId, AccountService $accountService, CacheActorService $cacheActorService,
|
||||
IRequest $request, ?string $userId, AccountService $accountService, CacheActorService $cacheActorService,
|
||||
HashtagService $hashtagService,
|
||||
FollowService $followService, PostService $postService, StreamService $streamService,
|
||||
SearchService $searchService,
|
||||
|
@ -146,10 +111,6 @@ class LocalController extends Controller {
|
|||
* Create a new post.
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postCreate(array $data): DataResponse {
|
||||
try {
|
||||
|
@ -168,7 +129,7 @@ class LocalController extends Controller {
|
|||
|
||||
return $this->success(
|
||||
[
|
||||
'post' => $activity->getObject(),
|
||||
'post' => $activity->getObject(),
|
||||
'token' => $token
|
||||
]
|
||||
);
|
||||
|
@ -179,15 +140,11 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* get info about a post (limited to viewer rights).
|
||||
* Get info about a post (limited to viewer rights).
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postGet(string $id): DataResponse {
|
||||
try {
|
||||
|
@ -202,16 +159,10 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* get replies about a post (limited to viewer rights).
|
||||
* Get replies about a post (limited to viewer rights).
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $id
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postReplies(string $id, int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -254,10 +205,6 @@ class LocalController extends Controller {
|
|||
* Create a new boost.
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $postId
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postBoost(string $postId): DataResponse {
|
||||
try {
|
||||
|
@ -280,10 +227,6 @@ class LocalController extends Controller {
|
|||
* Delete a boost.
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $postId
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postUnboost(string $postId): DataResponse {
|
||||
try {
|
||||
|
@ -306,10 +249,6 @@ class LocalController extends Controller {
|
|||
* Like a post.
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $postId
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postLike(string $postId): DataResponse {
|
||||
try {
|
||||
|
@ -318,7 +257,7 @@ class LocalController extends Controller {
|
|||
|
||||
return $this->success(
|
||||
[
|
||||
'like' => $announce,
|
||||
'like' => $announce,
|
||||
'token' => $token
|
||||
]
|
||||
);
|
||||
|
@ -329,13 +268,9 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* unlike a post.
|
||||
* Unlike a post.
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $postId
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function postUnlike(string $postId): DataResponse {
|
||||
try {
|
||||
|
@ -344,7 +279,7 @@ class LocalController extends Controller {
|
|||
|
||||
return $this->success(
|
||||
[
|
||||
'like' => $like,
|
||||
'like' => $like,
|
||||
'token' => $token
|
||||
]
|
||||
);
|
||||
|
@ -357,13 +292,8 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamHome($since = 0, int $limit = 5): DataResponse {
|
||||
public function streamHome(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->streamService->getStreamHome($since, $limit);
|
||||
|
@ -378,13 +308,8 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamNotifications($since = 0, int $limit = 5): DataResponse {
|
||||
public function streamNotifications(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer(true);
|
||||
$posts = $this->streamService->getStreamNotifications($since, $limit);
|
||||
|
@ -399,14 +324,8 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamAccount(string $username, $since = 0, int $limit = 5): DataResponse {
|
||||
public function streamAccount(string $username, int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$this->initViewer();
|
||||
|
||||
|
@ -423,11 +342,6 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamDirect(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -446,11 +360,6 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamTimeline(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -468,12 +377,6 @@ class LocalController extends Controller {
|
|||
* Get timeline
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $hashtag
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamTag(string $hashtag, int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -491,11 +394,6 @@ class LocalController extends Controller {
|
|||
* Get timeline
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamFederated(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -513,11 +411,6 @@ class LocalController extends Controller {
|
|||
* Get liked post
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamLiked(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
|
@ -533,10 +426,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $account
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function actionFollow(string $account): DataResponse {
|
||||
try {
|
||||
|
@ -553,10 +442,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $account
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function actionUnfollow(string $account): DataResponse {
|
||||
try {
|
||||
|
@ -590,8 +475,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function currentFollowers(): DataResponse {
|
||||
try {
|
||||
|
@ -609,8 +492,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function currentFollowing(): DataResponse {
|
||||
try {
|
||||
|
@ -629,10 +510,6 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountInfo(string $username): DataResponse {
|
||||
try {
|
||||
|
@ -651,35 +528,8 @@ class LocalController extends Controller {
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountFollowers(string $username): DataResponse {
|
||||
try {
|
||||
$this->initViewer();
|
||||
|
||||
$actor = $this->cacheActorService->getFromLocalAccount($username);
|
||||
$followers = $this->followService->getFollowers($actor);
|
||||
|
||||
return $this->success($followers);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function accountFollowing(string $username): DataResponse {
|
||||
|
||||
try {
|
||||
$this->initViewer();
|
||||
|
||||
|
@ -695,10 +545,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $account
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function globalAccountInfo(string $account): DataResponse {
|
||||
try {
|
||||
|
@ -715,10 +561,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function globalActorInfo(string $id): DataResponse {
|
||||
try {
|
||||
|
@ -735,10 +577,6 @@ class LocalController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function globalActorAvatar(string $id): Response {
|
||||
try {
|
||||
|
@ -764,10 +602,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function globalAccountsSearch(string $search): DataResponse {
|
||||
|
@ -801,10 +635,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function globalTagsSearch(string $search): DataResponse {
|
||||
|
@ -834,14 +664,10 @@ class LocalController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/** // TODO - remove this tag
|
||||
*
|
||||
/**
|
||||
* TODO - remove this tag
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return DataResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
public function search(string $search): DataResponse {
|
||||
|
@ -851,7 +677,7 @@ class LocalController extends Controller {
|
|||
$result = [
|
||||
'accounts' => $this->searchService->searchAccounts($search),
|
||||
'hashtags' => $this->searchService->searchHashtags($search),
|
||||
'content' => $this->searchService->searchStreamContent($search)
|
||||
'content' => $this->searchService->searchStreamContent($search)
|
||||
];
|
||||
|
||||
return $this->success($result);
|
||||
|
@ -860,10 +686,6 @@ class LocalController extends Controller {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param array $documents
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function documentsCache(array $documents): DataResponse {
|
||||
try {
|
||||
|
@ -884,9 +706,6 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bool $exception
|
||||
*
|
||||
* @throws AccountDoesNotExistException
|
||||
*/
|
||||
private function initViewer(bool $exception = false) {
|
||||
|
@ -912,6 +731,4 @@ class LocalController extends Controller {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
|
@ -56,7 +56,6 @@ use OCP\IL10N;
|
|||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
|
||||
/**
|
||||
* Class NavigationController
|
||||
*
|
||||
|
@ -116,12 +115,12 @@ class NavigationController extends Controller {
|
|||
*/
|
||||
public function navigate(string $path = ''): TemplateResponse {
|
||||
$serverData = [
|
||||
'public' => false,
|
||||
'public' => false,
|
||||
'firstrun' => false,
|
||||
'setup' => false,
|
||||
'isAdmin' => OC::$server->getGroupManager()
|
||||
'setup' => false,
|
||||
'isAdmin' => OC::$server->getGroupManager()
|
||||
->isAdmin($this->userId),
|
||||
'cliUrl' => $this->getCliUrl()
|
||||
'cliUrl' => $this->getCliUrl()
|
||||
];
|
||||
|
||||
try {
|
||||
|
@ -250,7 +249,6 @@ class NavigationController extends Controller {
|
|||
$file = $this->documentService->getFromCache($id, $mime);
|
||||
|
||||
return new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $mime]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
|
@ -266,7 +264,6 @@ class NavigationController extends Controller {
|
|||
* @return Response
|
||||
*/
|
||||
public function documentGetPublic(string $id): Response {
|
||||
|
||||
try {
|
||||
$mime = '';
|
||||
$file = $this->documentService->getFromCache($id, $mime, true);
|
||||
|
@ -287,7 +284,6 @@ class NavigationController extends Controller {
|
|||
* @return Response
|
||||
*/
|
||||
public function resizedGet(string $id): Response {
|
||||
|
||||
try {
|
||||
$mime = '';
|
||||
$file = $this->documentService->getResizedFromCache($id, $mime);
|
||||
|
@ -308,7 +304,6 @@ class NavigationController extends Controller {
|
|||
* @return Response
|
||||
*/
|
||||
public function resizedGetPublic(string $id): Response {
|
||||
|
||||
try {
|
||||
$mime = '';
|
||||
$file = $this->documentService->getResizedFromCache($id, $mime, true);
|
||||
|
@ -318,6 +313,4 @@ class NavigationController extends Controller {
|
|||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
|
@ -51,43 +51,18 @@ use OCP\IRequest;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\IUserSession;
|
||||
|
||||
|
||||
class OAuthController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
private IUserSession $userSession;
|
||||
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
private InstanceService $instanceService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private ClientService $clientService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* ActivityStreamController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param IUserSession $userSession
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param InstanceService $instanceService
|
||||
* @param AccountService $accountService
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param ClientService $clientService
|
||||
* @param ConfigService $configService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, IUserSession $userSession, IURLGenerator $urlGenerator,
|
||||
InstanceService $instanceService, AccountService $accountService,
|
||||
|
@ -113,13 +88,11 @@ class OAuthController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function nodeinfo(): Response {
|
||||
public function nodeinfo(): DataResponse {
|
||||
$nodeInfo = [
|
||||
'links' => [
|
||||
'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
|
||||
'rel' => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
|
||||
'href' => $this->urlGenerator->linkToRouteAbsolute('social.OAuth.nodeinfo2')
|
||||
]
|
||||
];
|
||||
|
@ -131,10 +104,8 @@ class OAuthController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function nodeinfo2() {
|
||||
public function nodeinfo2(): Response {
|
||||
try {
|
||||
$local = $this->instanceService->getLocal();
|
||||
$name = $local->getTitle();
|
||||
|
@ -150,15 +121,15 @@ class OAuthController extends Controller {
|
|||
}
|
||||
|
||||
$nodeInfo = [
|
||||
"version" => "2.0",
|
||||
"software" => [
|
||||
"name" => $name,
|
||||
"version" => "2.0",
|
||||
"software" => [
|
||||
"name" => $name,
|
||||
"version" => $version
|
||||
],
|
||||
"protocols" => [
|
||||
"protocols" => [
|
||||
"activitypub"
|
||||
],
|
||||
"usage" => $usage,
|
||||
"usage" => $usage,
|
||||
"openRegistrations" => $openReg
|
||||
];
|
||||
|
||||
|
@ -169,18 +140,11 @@ class OAuthController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $website
|
||||
* @param string $redirect_uris
|
||||
* @param string $scopes
|
||||
* @param string $client_name
|
||||
*
|
||||
* @return Response
|
||||
* @throws ClientException
|
||||
*/
|
||||
public function apps(
|
||||
string $client_name = '', string $redirect_uris = '', string $website = '', string $scopes = 'read'
|
||||
): Response {
|
||||
): DataResponse {
|
||||
// TODO: manage array from request
|
||||
if (!is_array($redirect_uris)) {
|
||||
$redirect_uris = [$redirect_uris];
|
||||
|
@ -196,11 +160,11 @@ class OAuthController extends Controller {
|
|||
|
||||
return new DataResponse(
|
||||
[
|
||||
'id' => $client->getId(),
|
||||
'name' => $client->getAppName(),
|
||||
'website' => $client->getAppWebsite(),
|
||||
'scopes' => implode(' ', $client->getAppScopes()),
|
||||
'client_id' => $client->getAppClientId(),
|
||||
'id' => $client->getId(),
|
||||
'name' => $client->getAppName(),
|
||||
'website' => $client->getAppWebsite(),
|
||||
'scopes' => implode(' ', $client->getAppScopes()),
|
||||
'client_id' => $client->getAppClientId(),
|
||||
'client_secret' => $client->getAppClientSecret()
|
||||
], Http::STATUS_OK
|
||||
);
|
||||
|
@ -210,13 +174,6 @@ class OAuthController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $client_id
|
||||
* @param string $redirect_uri
|
||||
* @param string $response_type
|
||||
* @param string $scope
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function authorize(
|
||||
string $client_id, string $redirect_uri, string $response_type, string $scope = 'read'
|
||||
|
@ -253,10 +210,10 @@ class OAuthController extends Controller {
|
|||
// TODO : finalize result if no redirect_url
|
||||
return new DataResponse(
|
||||
[
|
||||
// 'access_token' => '',
|
||||
// "token_type" => "Bearer",
|
||||
// "scope" => "read write follow push",
|
||||
// "created_at" => 1573979017
|
||||
// 'access_token' => '',
|
||||
// "token_type" => "Bearer",
|
||||
// "scope" => "read write follow push",
|
||||
// "created_at" => 1573979017
|
||||
], Http::STATUS_OK
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
|
@ -270,28 +227,19 @@ class OAuthController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $client_id
|
||||
* @param string $client_secret
|
||||
* @param string $redirect_uri
|
||||
* @param string $grant_type
|
||||
* @param string $scope
|
||||
* @param string $code
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function token(
|
||||
string $client_id, string $client_secret, string $redirect_uri, string $grant_type,
|
||||
string $scope = 'read', string $code = ''
|
||||
) {
|
||||
): DataResponse {
|
||||
try {
|
||||
$client = $this->clientService->getFromClientId($client_id);
|
||||
$this->clientService->confirmData(
|
||||
$client,
|
||||
[
|
||||
'client_secret' => $client_secret,
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'auth_scopes' => $scope
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'auth_scopes' => $scope
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -302,7 +250,7 @@ class OAuthController extends Controller {
|
|||
|
||||
$this->clientService->confirmData($client, ['code' => $code]);
|
||||
$this->clientService->generateToken($client);
|
||||
} else if ($grant_type === 'client_credentials') {
|
||||
} elseif ($grant_type === 'client_credentials') {
|
||||
// TODO: manage client_credentials
|
||||
} else {
|
||||
return new DataResponse(
|
||||
|
@ -319,9 +267,9 @@ class OAuthController extends Controller {
|
|||
return new DataResponse(
|
||||
[
|
||||
"access_token" => $client->getToken(),
|
||||
"token_type" => 'Bearer',
|
||||
"scope" => $scope,
|
||||
"created_at" => $client->getCreation()
|
||||
"token_type" => 'Bearer',
|
||||
"scope" => $scope,
|
||||
"created_at" => $client->getCreation()
|
||||
], Http::STATUS_OK
|
||||
);
|
||||
} catch (ClientNotFoundException $e) {
|
||||
|
@ -330,6 +278,4 @@ class OAuthController extends Controller {
|
|||
return new DataResponse(['error' => $e->getMessage()], Http::STATUS_UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\ArrayNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
|
@ -47,40 +47,19 @@ use OCP\AppFramework\Http\Response;
|
|||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IInitialStateService;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
|
||||
|
||||
class OStatusController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private CurlService $curlService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
private IUserManager $userSession;
|
||||
private IUserSession $userSession;
|
||||
private IInitialStateService $initialStateService;
|
||||
|
||||
|
||||
/**
|
||||
* OStatusController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param IInitialStateService $initialStateService
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param AccountService $accountService
|
||||
* @param CurlService $curlService
|
||||
* @param MiscService $miscService
|
||||
* @param IUserSession $userSession
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, IInitialStateService $initialStateService, CacheActorService $cacheActorService, AccountService $accountService,
|
||||
CurlService $curlService, MiscService $miscService, IUserSession $userSession
|
||||
|
@ -99,14 +78,9 @@ class OStatusController extends Controller {
|
|||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function subscribe(string $uri): Response {
|
||||
try {
|
||||
|
||||
try {
|
||||
$actor = $this->cacheActorService->getFromAccount($uri);
|
||||
} catch (InvalidResourceException $e) {
|
||||
|
@ -138,10 +112,6 @@ class OStatusController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $local
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function followRemote(string $local): Response {
|
||||
try {
|
||||
|
@ -163,14 +133,8 @@ class OStatusController extends Controller {
|
|||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $local
|
||||
* @param string $account
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getLink(string $local, string $account): Response {
|
||||
|
||||
try {
|
||||
$following = $this->accountService->getActor($local);
|
||||
$result = $this->curlService->webfingerAccount($account);
|
||||
|
@ -192,6 +156,4 @@ class OStatusController extends Controller {
|
|||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TAsync;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
|
@ -40,32 +40,18 @@ use OCA\Social\Service\RequestQueueService;
|
|||
use OCP\AppFramework\Controller;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
||||
/**
|
||||
* Class QueueController
|
||||
*
|
||||
* @package OCA\Social\Controller
|
||||
*/
|
||||
class QueueController extends Controller {
|
||||
|
||||
|
||||
use TAsync;
|
||||
|
||||
private RequestQueueService $requestQueueService;
|
||||
|
||||
private ActivityService $activityService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* QueueController constructor.
|
||||
*
|
||||
* @param IRequest $request
|
||||
* @param RequestQueueService $requestQueueService
|
||||
* @param ActivityService $activityService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
IRequest $request, RequestQueueService $requestQueueService, ActivityService $activityService,
|
||||
MiscService $miscService
|
||||
|
@ -81,8 +67,6 @@ class QueueController extends Controller {
|
|||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
public function asyncForRequest(string $token) {
|
||||
$requests = $this->requestQueueService->getRequestFromToken($token, RequestQueue::STATUS_STANDBY);
|
||||
|
@ -102,6 +86,4 @@ class QueueController extends Controller {
|
|||
// or it will feed the logs.
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
|
@ -39,7 +39,6 @@ use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
|||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Exceptions\StreamNotFoundException;
|
||||
use OCA\Social\Exceptions\UrlCloudException;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
|
@ -53,47 +52,24 @@ use OCP\IInitialStateService;
|
|||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialPubController
|
||||
*
|
||||
* @package OCA\Social\Controller
|
||||
*/
|
||||
class SocialPubController extends Controller {
|
||||
|
||||
|
||||
use TNCDataResponse;
|
||||
|
||||
|
||||
private string $userId;
|
||||
|
||||
private ?string $userId = null;
|
||||
private IL10N $l10n;
|
||||
|
||||
private NavigationController $navigationController;
|
||||
|
||||
private AccountService $accountService;
|
||||
|
||||
private CacheActorService $cacheActorService;
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private ConfigService $configService;
|
||||
|
||||
|
||||
/**
|
||||
* SocialPubController constructor.
|
||||
*
|
||||
* @param $userId
|
||||
* @param IRequest $request
|
||||
* @param IL10N $l10n
|
||||
* @param NavigationController $navigationController
|
||||
* @param CacheActorService $cacheActorService
|
||||
* @param AccountService $accountService
|
||||
* @param StreamService $streamService
|
||||
* @param ConfigService $configService
|
||||
*/
|
||||
public function __construct(
|
||||
$userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
||||
?string $userId, IInitialStateService $initialStateService, IRequest $request, IL10N $l10n, NavigationController $navigationController,
|
||||
CacheActorService $cacheActorService, AccountService $accountService, StreamService $streamService,
|
||||
ConfigService $configService
|
||||
) {
|
||||
|
@ -111,13 +87,10 @@ class SocialPubController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* @param $username
|
||||
*
|
||||
* @return Response
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
private function renderPage($username): Response {
|
||||
private function renderPage(string $username): Response {
|
||||
if ($this->userId) {
|
||||
return $this->navigationController->navigate('');
|
||||
}
|
||||
|
@ -148,15 +121,12 @@ class SocialPubController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* return webpage content for human navigation.
|
||||
* Return webpage content for human navigation.
|
||||
* Should return information about a Social account, based on username.
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return Response
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -166,15 +136,11 @@ class SocialPubController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* return webpage content for human navigation.
|
||||
* Return webpage content for human navigation.
|
||||
* Should return followers of a Social account, based on username.
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return TemplateResponse
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -184,15 +150,11 @@ class SocialPubController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* return webpage content for human navigation.
|
||||
* Return webpage content for human navigation.
|
||||
* Should return following of a Social account, based on username.
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return TemplateResponse
|
||||
* @throws UrlCloudException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -206,11 +168,6 @@ class SocialPubController extends Controller {
|
|||
*
|
||||
* @NoCSRFRequired
|
||||
* @PublicPage
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $token
|
||||
*
|
||||
* @return TemplateResponse
|
||||
* @throws SocialAppConfigException
|
||||
* @throws StreamNotFoundException
|
||||
*/
|
||||
|
@ -225,17 +182,14 @@ class SocialPubController extends Controller {
|
|||
|
||||
$stream = $this->streamService->getStreamById($postId, true);
|
||||
$data = [
|
||||
'id' => $postId,
|
||||
'id' => $postId,
|
||||
'application' => 'Social'
|
||||
];
|
||||
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream );
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'item', $stream);
|
||||
$this->initialStateService->provideInitialState(Application::APP_NAME, 'serverData', [
|
||||
'public' => ($this->userId === null),
|
||||
]);
|
||||
return new TemplateResponse(Application::APP_NAME, 'main', $data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,9 +31,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Cron;
|
||||
|
||||
|
||||
use Exception;
|
||||
use OC\BackgroundJob\TimedJob;
|
||||
use OC\AppFramework\Utility\TimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
|
@ -40,28 +41,19 @@ use OCA\Social\Service\DocumentService;
|
|||
use OCA\Social\Service\HashtagService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
|
||||
/**
|
||||
* Class Cache
|
||||
*
|
||||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Cache extends TimedJob {
|
||||
|
||||
|
||||
private ?AccountService $accountService = null;
|
||||
|
||||
private ?CacheActorService $cacheActorService = null;
|
||||
|
||||
private ?DocumentService $documentService = null;
|
||||
|
||||
private ?HashtagService $hashtagService = null;
|
||||
|
||||
|
||||
/**
|
||||
* Cache constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct(TimeFactory $time) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 60); // 12 minutes
|
||||
}
|
||||
|
||||
|
@ -72,13 +64,13 @@ class Cache extends TimedJob {
|
|||
* @throws QueryException
|
||||
*/
|
||||
protected function run($argument) {
|
||||
$app = \OC::$server->query(Application::class);
|
||||
$app = \OC::$server->get(Application::class);
|
||||
$c = $app->getContainer();
|
||||
|
||||
$this->accountService = $c->query(AccountService::class);
|
||||
$this->cacheActorService = $c->query(CacheActorService::class);
|
||||
$this->documentService = $c->query(DocumentService::class);
|
||||
$this->hashtagService = $c->query(HashtagService::class);
|
||||
$this->accountService = $c->get(AccountService::class);
|
||||
$this->cacheActorService = $c->get(CacheActorService::class);
|
||||
$this->documentService = $c->get(DocumentService::class);
|
||||
$this->hashtagService = $c->get(HashtagService::class);
|
||||
|
||||
$this->manageCache();
|
||||
}
|
||||
|
@ -110,6 +102,4 @@ class Cache extends TimedJob {
|
|||
} catch (Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,31 +31,24 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Cron;
|
||||
|
||||
|
||||
use OC\BackgroundJob\TimedJob;
|
||||
use OC\AppFramework\Utility\TimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
|
||||
/**
|
||||
* Class Queue
|
||||
*
|
||||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Chunk extends TimedJob {
|
||||
|
||||
private ?ConfigService $configService = null;
|
||||
|
||||
private ?MiscService $miscService = null;
|
||||
|
||||
|
||||
/**
|
||||
* Cache constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->setInterval(12 * 3600); // 12 heures
|
||||
public function __construct(TimeFactory $time) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 3600); // 12 hours
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,8 +73,5 @@ class Chunk extends TimedJob {
|
|||
* @param int $size
|
||||
*/
|
||||
private function morphChunks(int $size) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,8 +31,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Cron;
|
||||
|
||||
|
||||
use OC\BackgroundJob\TimedJob;
|
||||
use OC\AppFramework\Utility\TimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
|
@ -40,28 +41,22 @@ use OCA\Social\Service\RequestQueueService;
|
|||
use OCA\Social\Service\StreamQueueService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
|
||||
/**
|
||||
* Class Queue
|
||||
*
|
||||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Queue extends TimedJob {
|
||||
|
||||
|
||||
private ?ActivityService $activityService = null;
|
||||
|
||||
private ?RequestQueueService $requestQueueService = null;
|
||||
|
||||
private ?StreamQueueService $streamQueueService = null;
|
||||
|
||||
private ?MiscService $miscService = null;
|
||||
|
||||
|
||||
/**
|
||||
* Cache constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct(TimeFactory $time) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 60); // 12 minutes
|
||||
}
|
||||
|
||||
|
@ -72,13 +67,14 @@ class Queue extends TimedJob {
|
|||
* @throws QueryException
|
||||
*/
|
||||
protected function run($argument) {
|
||||
$app = \OC::$server->query(Application::class);
|
||||
/** @var Application $app */
|
||||
$app = \OC::$server->get(Application::class);
|
||||
$c = $app->getContainer();
|
||||
|
||||
$this->requestQueueService = $c->query(RequestQueueService::class);
|
||||
$this->streamQueueService = $c->query(StreamQueueService::class);
|
||||
$this->activityService = $c->query(ActivityService::class);
|
||||
$this->miscService = $c->query(MiscService::class);
|
||||
$this->requestQueueService = $c->get(RequestQueueService::class);
|
||||
$this->streamQueueService = $c->get(StreamQueueService::class);
|
||||
$this->activityService = $c->get(ActivityService::class);
|
||||
$this->miscService = $c->get(MiscService::class);
|
||||
|
||||
$this->manageRequestQueue();
|
||||
$this->manageStreamQueue();
|
||||
|
@ -98,7 +94,6 @@ class Queue extends TimedJob {
|
|||
} catch (SocialAppConfigException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +105,4 @@ class Queue extends TimedJob {
|
|||
$this->streamQueueService->manageStreamQueue($item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
@ -39,24 +39,18 @@ use OCA\Social\Model\ActivityPub\ACore;
|
|||
use OCA\Social\Model\ActivityPub\Object\Like;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class ActionsRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class ActionsRequest extends ActionsRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
/**
|
||||
* Insert a new Note in the database.
|
||||
*
|
||||
* @param ACore $like
|
||||
*/
|
||||
public function save(ACore $like) {
|
||||
public function save(ACore $like): void {
|
||||
$qb = $this->getActionsInsertSql();
|
||||
$qb->setValue('id', $qb->createNamedParameter($like->getId()))
|
||||
->setValue('actor_id', $qb->createNamedParameter($like->getActorId()))
|
||||
|
@ -169,6 +163,4 @@ class ActionsRequest extends ActionsRequestBuilder {
|
|||
//
|
||||
// $qb->execute();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,21 +31,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\ActionDoesNotExistException;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
|
||||
|
||||
/**
|
||||
* Class ActionsRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class ActionsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
protected function getActionsInsertSql(): SocialQueryBuilder {
|
||||
|
@ -164,6 +162,4 @@ class ActionsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,29 +30,21 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use OCA\Social\Exceptions\ActorDoesNotExistException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\MiscService;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class ActorsRequest extends ActorsRequestBuilder {
|
||||
|
||||
|
||||
/**
|
||||
* create a new Person in the database.
|
||||
*
|
||||
* @param Person $actor
|
||||
*
|
||||
* Create a new Person in the database.
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
public function create(Person $actor) {
|
||||
|
||||
public function create(Person $actor): void {
|
||||
$actor->setId($this->configService->getSocialUrl() . '@' . $actor->getPreferredUsername());
|
||||
$qb = $this->getActorsInsertSql();
|
||||
|
||||
|
@ -71,26 +64,18 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
|
||||
);
|
||||
|
||||
$qb->execute();
|
||||
$qb->executeStatement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
*/
|
||||
public function update(Person $actor) {
|
||||
public function update(Person $actor): void {
|
||||
$qb = $this->getActorsUpdateSql();
|
||||
$qb->set('avatar_version', $qb->createNamedParameter($actor->getAvatarVersion()));
|
||||
$this->limitToIdString($qb, $actor->getId());
|
||||
|
||||
$qb->execute();
|
||||
$qb->executeStatement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
*/
|
||||
public function refreshKeys(Person $actor) {
|
||||
public function refreshKeys(Person $actor): void {
|
||||
$qb = $this->getActorsUpdateSql();
|
||||
$qb->set('public_key', $qb->createNamedParameter($actor->getPublicKey()))
|
||||
->set('private_key', $qb->createNamedParameter($actor->getPrivateKey()));
|
||||
|
@ -105,16 +90,13 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
|
||||
$this->limitToIdString($qb, $actor->getId());
|
||||
|
||||
$qb->execute();
|
||||
$qb->executeStatement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return Actor from database based on the username
|
||||
* Return Actor from database based on the username
|
||||
*
|
||||
* @param string $username
|
||||
*
|
||||
* @return Person
|
||||
* @throws ActorDoesNotExistException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -122,7 +104,7 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$qb = $this->getActorsSelectSql();
|
||||
$this->limitToPreferredUsername($qb, $username);
|
||||
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
$data = $cursor->fetch();
|
||||
$cursor->closeCursor();
|
||||
|
||||
|
@ -134,9 +116,6 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return Person
|
||||
* @throws ActorDoesNotExistException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -144,7 +123,7 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$qb = $this->getActorsSelectSql();
|
||||
$this->limitToIdString($qb, $id);
|
||||
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
$data = $cursor->fetch();
|
||||
$cursor->closeCursor();
|
||||
|
||||
|
@ -169,7 +148,7 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$qb = $this->getActorsSelectSql();
|
||||
$this->limitToUserId($qb, $userId);
|
||||
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
$data = $cursor->fetch();
|
||||
$cursor->closeCursor();
|
||||
|
||||
|
@ -189,7 +168,7 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$qb = $this->getActorsSelectSql();
|
||||
|
||||
$accounts = [];
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
while ($data = $cursor->fetch()) {
|
||||
$accounts[] = $this->parseActorsSelectSql($data);
|
||||
}
|
||||
|
@ -200,8 +179,6 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
*
|
||||
* @return Person[]
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -210,7 +187,7 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
$this->searchInPreferredUsername($qb, $search);
|
||||
|
||||
$accounts = [];
|
||||
$cursor = $qb->execute();
|
||||
$cursor = $qb->executeQuery();
|
||||
while ($data = $cursor->fetch()) {
|
||||
$accounts[] = $this->parseActorsSelectSql($data);
|
||||
}
|
||||
|
@ -218,6 +195,4 @@ class ActorsRequest extends ActorsRequestBuilder {
|
|||
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,15 +30,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class ActorsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -130,6 +128,4 @@ class ActorsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $actor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Exception;
|
||||
|
@ -38,9 +38,7 @@ use OCA\Social\Model\ActivityPub\Actor\Person;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class CacheActorsRequest extends CacheActorsRequestBuilder {
|
||||
|
||||
|
||||
const CACHE_TTL = 60 * 24; // 1d
|
||||
public const CACHE_TTL = 60 * 24; // 1d
|
||||
|
||||
|
||||
/**
|
||||
|
@ -111,7 +109,6 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
|||
* @return int
|
||||
*/
|
||||
public function update(Person $actor): int {
|
||||
|
||||
$qb = $this->getCacheActorsUpdateSql();
|
||||
$qb->set('following', $qb->createNamedParameter($actor->getFollowing()))
|
||||
->set('followers', $qb->createNamedParameter($actor->getFollowers()))
|
||||
|
@ -252,6 +249,4 @@ class CacheActorsRequest extends CacheActorsRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\CacheActorDoesNotExistException;
|
||||
|
@ -38,8 +38,6 @@ use OCA\Social\Model\ActivityPub\Actor\Person;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class CacheActorsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -182,6 +180,4 @@ class CacheActorsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
$actor->setViewerLink($link);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use OCA\Social\Exceptions\CacheDocumentDoesNotExistException;
|
||||
|
@ -37,9 +37,7 @@ use OCA\Social\Model\ActivityPub\Object\Document;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
|
||||
|
||||
|
||||
const CACHING_TIMEOUT = 5; // 5 min
|
||||
public const CACHING_TIMEOUT = 5; // 5 min
|
||||
|
||||
|
||||
/**
|
||||
|
@ -245,7 +243,4 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,14 +30,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Model\ActivityPub\Object\Document;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class CacheDocumentsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -112,6 +110,4 @@ class CacheDocumentsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $document;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
@ -39,15 +39,12 @@ use OCA\Social\Model\Client\SocialClient;
|
|||
use OCA\Social\Service\ClientService;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class ClientAppRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class ClientRequest extends ClientRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -166,6 +163,4 @@ class ClientRequest extends ClientRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,22 +31,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OCA\Social\Exceptions\ClientNotFoundException;
|
||||
use OCA\Social\Model\Client\SocialClient;
|
||||
|
||||
|
||||
/**
|
||||
* Class ClientRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class ClientRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -154,6 +151,4 @@ class ClientRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
|
@ -49,34 +49,32 @@ use OCP\IDBConnection;
|
|||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class CoreRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class CoreRequestBuilder {
|
||||
public const TABLE_REQUEST_QUEUE = 'social_3_req_queue';
|
||||
public const TABLE_INSTANCE = 'social_3_instance';
|
||||
|
||||
const TABLE_REQUEST_QUEUE = 'social_3_req_queue';
|
||||
const TABLE_INSTANCE = 'social_3_instance';
|
||||
public const TABLE_ACTORS = 'social_3_actor';
|
||||
public const TABLE_STREAM = 'social_3_stream';
|
||||
public const TABLE_STREAM_DEST = 'social_3_stream_dest';
|
||||
public const TABLE_STREAM_TAGS = 'social_3_stream_tag';
|
||||
public const TABLE_STREAM_QUEUE = 'social_3_stream_queue';
|
||||
public const TABLE_STREAM_ACTIONS = 'social_3_stream_act';
|
||||
|
||||
const TABLE_ACTORS = 'social_3_actor';
|
||||
const TABLE_STREAM = 'social_3_stream';
|
||||
const TABLE_STREAM_DEST = 'social_3_stream_dest';
|
||||
const TABLE_STREAM_TAGS = 'social_3_stream_tag';
|
||||
const TABLE_STREAM_QUEUE = 'social_3_stream_queue';
|
||||
const TABLE_STREAM_ACTIONS = 'social_3_stream_act';
|
||||
public const TABLE_HASHTAGS = 'social_3_hashtag';
|
||||
public const TABLE_FOLLOWS = 'social_3_follow';
|
||||
public const TABLE_ACTIONS = 'social_3_action';
|
||||
|
||||
const TABLE_HASHTAGS = 'social_3_hashtag';
|
||||
const TABLE_FOLLOWS = 'social_3_follow';
|
||||
const TABLE_ACTIONS = 'social_3_action';
|
||||
public const TABLE_CACHE_ACTORS = 'social_3_cache_actor';
|
||||
public const TABLE_CACHE_DOCUMENTS = 'social_3_cache_doc';
|
||||
|
||||
const TABLE_CACHE_ACTORS = 'social_3_cache_actor';
|
||||
const TABLE_CACHE_DOCUMENTS = 'social_3_cache_doc';
|
||||
|
||||
const TABLE_CLIENT = 'social_3_client';
|
||||
const TABLE_CLIENT_AUTH = 'social_3_client_auth';
|
||||
const TABLE_CLIENT_TOKEN = 'social_3_client_token';
|
||||
public const TABLE_CLIENT = 'social_3_client';
|
||||
public const TABLE_CLIENT_AUTH = 'social_3_client_auth';
|
||||
public const TABLE_CLIENT_TOKEN = 'social_3_client_token';
|
||||
|
||||
|
||||
private array $tables = [
|
||||
|
@ -728,7 +726,6 @@ class CoreRequestBuilder {
|
|||
$orX->add($expr->gte($field, $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)));
|
||||
|
||||
$qb->andWhere($orX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1224,6 +1221,4 @@ class CoreRequestBuilder {
|
|||
$qb->where($this->exprLimitToDBField($qb, 'class', 'OCA\Social\Cron\Queue', true, true));
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
@ -39,15 +39,12 @@ use OCA\Social\Model\ActivityPub\Actor\Person;
|
|||
use OCA\Social\Model\ActivityPub\Object\Follow;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class FollowsRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class FollowsRequest extends FollowsRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -259,7 +256,6 @@ class FollowsRequest extends FollowsRequestBuilder {
|
|||
$this->leftJoinAccounts($qb, 'actor_id');
|
||||
|
||||
return $this->getFollowsFromRequest($qb);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,6 +304,4 @@ class FollowsRequest extends FollowsRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\FollowNotFoundException;
|
||||
|
@ -38,15 +38,12 @@ use OCA\Social\Exceptions\InvalidResourceException;
|
|||
use OCA\Social\Model\ActivityPub\Object\Follow;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class FollowsRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class FollowsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -187,6 +184,4 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $follow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,19 +31,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\HashtagDoesNotExistException;
|
||||
|
||||
|
||||
/**
|
||||
* Class HashtagsRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class HashtagsRequest extends HashtagsRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -136,7 +133,4 @@ class HashtagsRequest extends HashtagsRequestBuilder {
|
|||
|
||||
return $hashtags;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,19 +31,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class HashtagsRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class HashtagsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -112,9 +109,7 @@ class HashtagsRequestBuilder extends CoreRequestBuilder {
|
|||
public function parseHashtagsSelectSql(array $data): array {
|
||||
return [
|
||||
'hashtag' => $this->get('hashtag', $data, ''),
|
||||
'trend' => $this->getArray('trend', $data, [])
|
||||
'trend' => $this->getArray('trend', $data, [])
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,21 +31,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\Instance;
|
||||
|
||||
|
||||
/**
|
||||
* Class InstancesRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class InstancesRequest extends InstancesRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -77,6 +74,4 @@ class InstancesRequest extends InstancesRequestBuilder {
|
|||
|
||||
return $this->getInstanceFromRequest($qb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
||||
|
@ -39,8 +39,6 @@ use OCA\Social\Model\Instance;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class InstancesRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -166,6 +164,4 @@ class InstancesRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,13 +31,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use OCA\Social\Exceptions\QueueStatusException;
|
||||
use OCA\Social\Model\RequestQueue;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class RequestQueueRequest
|
||||
*
|
||||
|
@ -206,6 +205,4 @@ class RequestQueueRequest extends RequestQueueRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,14 +30,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Model\RequestQueue;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class RequestQueueRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -112,6 +110,4 @@ class RequestQueueRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $queue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Db\ExtendedQueryBuilder;
|
||||
use OC\SystemConfig;
|
||||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
|
@ -39,7 +39,6 @@ use OCP\IDBConnection;
|
|||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialCoreQueryBuilder
|
||||
*
|
||||
|
@ -105,4 +104,3 @@ class SocialCoreQueryBuilder extends ExtendedQueryBuilder {
|
|||
return hash('sha512', $id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use OCA\Social\AP;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
|
@ -39,7 +39,6 @@ use OCA\Social\Model\ActivityPub\Object\Document;
|
|||
use OCA\Social\Model\ActivityPub\Object\Image;
|
||||
use OCP\DB\QueryBuilder\ICompositeExpression;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialCrossQueryBuilder
|
||||
*
|
||||
|
@ -368,6 +367,4 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
|
|||
|
||||
return $andX;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,10 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialFiltersQueryBuilder
|
||||
*
|
||||
|
@ -64,6 +61,4 @@ class SocialFiltersQueryBuilder extends SocialLimitsQueryBuilder {
|
|||
|
||||
$this->andWhere($filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
|
@ -39,7 +39,6 @@ use OCA\Social\Model\ActivityPub\ACore;
|
|||
use OCA\Social\Model\Client\Options\TimelineOptions;
|
||||
use OCP\DB\QueryBuilder\ICompositeExpression;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialLimitsQueryBuilder
|
||||
*
|
||||
|
@ -466,6 +465,4 @@ class SocialLimitsQueryBuilder extends SocialCrossQueryBuilder {
|
|||
|
||||
$this->andWhere($orX);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,15 +31,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
/**
|
||||
* Class SocialQueryBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class SocialQueryBuilder extends SocialFiltersQueryBuilder {
|
||||
|
||||
|
||||
private int $format = 1;
|
||||
|
||||
|
||||
|
@ -101,7 +99,4 @@ class SocialQueryBuilder extends SocialFiltersQueryBuilder {
|
|||
$dbConn = $this->getConnection();
|
||||
$this->searchInDBField('account', $dbConn->escapeLikeParameter($account) . '%');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,11 +31,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use OCA\Social\Exceptions\StreamActionDoesNotExistException;
|
||||
use OCA\Social\Model\StreamAction;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamActionsRequest
|
||||
*
|
||||
|
@ -133,6 +132,4 @@ class StreamActionsRequest extends StreamActionsRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,20 +30,16 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Model\StreamAction;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamActionsRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class StreamActionsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -115,6 +112,4 @@ class StreamActionsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $action;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Exception;
|
||||
|
@ -43,7 +43,6 @@ use OCP\IDBConnection;
|
|||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamDestRequest
|
||||
*
|
||||
|
@ -185,6 +184,4 @@ class StreamDestRequest extends StreamDestRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,19 +30,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamDestRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class StreamDestRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -118,7 +115,4 @@ class StreamDestRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,13 +31,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use DateTime;
|
||||
use OCA\Social\Exceptions\QueueStatusException;
|
||||
use OCA\Social\Model\StreamQueue;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamQueueRequest
|
||||
*
|
||||
|
@ -184,6 +183,4 @@ class StreamQueueRequest extends StreamQueueRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,14 +30,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCA\Social\Model\StreamQueue;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
class StreamQueueRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -111,6 +109,4 @@ class StreamQueueRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $queue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,7 +30,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\DateTimeException;
|
||||
use daita\MySmallPhpTools\Model\Cache;
|
||||
use DateTime;
|
||||
|
@ -50,7 +50,6 @@ use OCP\IDBConnection;
|
|||
use OCP\IURLGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamRequest
|
||||
*
|
||||
|
@ -684,7 +683,6 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
* @return IQueryBuilder
|
||||
*/
|
||||
public function saveStream(Stream $stream): IQueryBuilder {
|
||||
|
||||
try {
|
||||
$dTime = new DateTime();
|
||||
$dTime->setTimestamp($stream->getPublishedTime());
|
||||
|
@ -763,6 +761,4 @@ class StreamRequest extends StreamRequestBuilder {
|
|||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,7 +31,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Exceptions\CacheItemNotFoundException;
|
||||
use daita\MySmallPhpTools\Exceptions\RowNotFoundException;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
|
@ -43,15 +43,12 @@ use OCA\Social\Model\ActivityPub\Object\Announce;
|
|||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class StreamRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -247,6 +244,4 @@ class StreamRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -30,21 +31,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamTagsRequest
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class StreamTagsRequest extends StreamTagsRequestBuilder {
|
||||
|
||||
|
||||
use TStringTools;
|
||||
|
||||
|
||||
|
@ -58,7 +55,6 @@ class StreamTagsRequest extends StreamTagsRequestBuilder {
|
|||
|
||||
/** @var Note $stream */
|
||||
foreach ($stream->getHashTags() as $hashtag) {
|
||||
|
||||
$qb = $this->getStreamTagsInsertSql();
|
||||
$streamId = $qb->prim($stream->getId());
|
||||
$qb->setValue('stream_id', $qb->createNamedParameter($streamId));
|
||||
|
@ -82,6 +78,4 @@ class StreamTagsRequest extends StreamTagsRequestBuilder {
|
|||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
|
@ -29,19 +30,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Social\Db;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* Class StreamDestRequestBuilder
|
||||
*
|
||||
* @package OCA\Social\Db
|
||||
*/
|
||||
class StreamTagsRequestBuilder extends CoreRequestBuilder {
|
||||
|
||||
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
|
@ -101,6 +98,4 @@ class StreamTagsRequestBuilder extends CoreRequestBuilder {
|
|||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class AccountAlreadyExistsException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
class AccountDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ActionDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ActivityCantBeVerifiedException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ActivityPubFormatException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ActorDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class CacheActorDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class CacheContentException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class CacheContentMimeTypeException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class CacheDocumentDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ClientException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ClientNotFoundException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class EmptyQueueException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class FollowNotFoundException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class FollowSameAccountException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class HashtagDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class HostMetaException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class InstanceDoesNotExistException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class InvalidOriginException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class InvalidResourceEntryException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class InvalidResourceException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ItemAlreadyExistsException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ItemNotFoundException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class ItemUnknownException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class LinkedDataSignatureMissingException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class NoHighPriorityRequestException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class QueueStatusException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class RealTokenException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,7 @@
|
|||
|
||||
namespace OCA\Social\Exceptions;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
class RedundancyLimitException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Ładowanie…
Reference in New Issue