kopia lustrzana https://github.com/nextcloud/social
Merge pull request #1415 from nextcloud/cleanup/OC-servercontainer
Port away from private OC::$server->getpull/1422/head
commit
191683733d
|
@ -323,12 +323,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ChristophWurst/nextcloud_composer.git",
|
||||
"reference": "5e2c78469a4f669ed11016cf8a6668792efcbedf"
|
||||
"reference": "5e9719488fe558db974ef45f289a6911fe2c6850"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/5e2c78469a4f669ed11016cf8a6668792efcbedf",
|
||||
"reference": "5e2c78469a4f669ed11016cf8a6668792efcbedf",
|
||||
"url": "https://api.github.com/repos/ChristophWurst/nextcloud_composer/zipball/5e9719488fe558db974ef45f289a6911fe2c6850",
|
||||
"reference": "5e9719488fe558db974ef45f289a6911fe2c6850",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -341,7 +341,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "24.0.0-dev"
|
||||
"dev-master": "25.0.0-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -359,7 +359,7 @@
|
|||
"issues": "https://github.com/ChristophWurst/nextcloud_composer/issues",
|
||||
"source": "https://github.com/ChristophWurst/nextcloud_composer/tree/master"
|
||||
},
|
||||
"time": "2022-04-15T01:52:26+00:00"
|
||||
"time": "2022-05-11T02:03:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/package-versions-deprecated",
|
||||
|
@ -4999,5 +4999,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "7.4.0"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.2.0"
|
||||
}
|
||||
|
|
269
lib/AP.php
269
lib/AP.php
|
@ -32,7 +32,6 @@ declare(strict_types=1);
|
|||
namespace OCA\Social;
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use OC;
|
||||
use OCA\Social\Exceptions\ItemUnknownException;
|
||||
use OCA\Social\Exceptions\RedundancyLimitException;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
|
@ -84,6 +83,8 @@ use OCA\Social\Model\ActivityPub\Object\Tombstone;
|
|||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class AP
|
||||
|
@ -93,123 +94,92 @@ use OCP\AppFramework\QueryException;
|
|||
class AP {
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
public const REDUNDANCY_LIMIT = 10;
|
||||
|
||||
public AcceptInterface $acceptInterface;
|
||||
public AddInterface $addInterface;
|
||||
public AnnounceInterface $announceInterface;
|
||||
public BlockInterface $blockInterface;
|
||||
public CreateInterface $createInterface;
|
||||
public DeleteInterface $deleteInterface;
|
||||
public DocumentInterface $documentInterface;
|
||||
public FollowInterface $followInterface;
|
||||
public ImageInterface $imageInterface;
|
||||
public LikeInterface $likeInterface;
|
||||
public PersonInterface $personInterface;
|
||||
public NoteInterface $noteInterface;
|
||||
public GroupInterface $groupInterface;
|
||||
public OrganizationInterface $organizationInterface;
|
||||
public ApplicationInterface $applicationInterface;
|
||||
public RejectInterface $rejectInterface;
|
||||
public RemoveInterface $removeInterface;
|
||||
public ServiceInterface $serviceInterface;
|
||||
public UndoInterface $undoInterface;
|
||||
public UpdateInterface $updateInterface;
|
||||
public SocialAppNotificationInterface $notificationInterface;
|
||||
public ConfigService $configService;
|
||||
public static ?AP $activityPub = null;
|
||||
private SocialAppNotificationInterface $socialAppNotificationInterface;
|
||||
|
||||
/** @var AcceptInterface */
|
||||
public $acceptInterface;
|
||||
|
||||
/** @var AddInterface */
|
||||
public $addInterface;
|
||||
|
||||
/** @var AnnounceInterface */
|
||||
public $announceInterface;
|
||||
|
||||
/** @var BlockInterface */
|
||||
public $blockInterface;
|
||||
|
||||
/** @var CreateInterface */
|
||||
public $createInterface;
|
||||
|
||||
/** @var DeleteInterface */
|
||||
public $deleteInterface;
|
||||
|
||||
/** @var DocumentInterface */
|
||||
public $documentInterface;
|
||||
|
||||
/** @var FollowInterface */
|
||||
public $followInterface;
|
||||
|
||||
/** @var ImageInterface */
|
||||
public $imageInterface;
|
||||
|
||||
/** @var LikeInterface */
|
||||
public $likeInterface;
|
||||
|
||||
/** @var PersonInterface */
|
||||
public $personInterface;
|
||||
|
||||
/** @var NoteInterface */
|
||||
public $noteInterface;
|
||||
|
||||
/** @var RejectInterface */
|
||||
public $rejectInterface;
|
||||
|
||||
/** @var RemoveInterface */
|
||||
public $removeInterface;
|
||||
|
||||
/** @var ServiceInterface */
|
||||
public $serviceInterface;
|
||||
|
||||
/** @var UndoInterface */
|
||||
public $undoInterface;
|
||||
|
||||
/** @var UpdateInterface */
|
||||
public $updateInterface;
|
||||
|
||||
/** @var SocialAppNotificationInterface */
|
||||
public $notificationInterface;
|
||||
|
||||
/** @var ConfigService */
|
||||
public $configService;
|
||||
|
||||
|
||||
/** @var AP */
|
||||
public static $activityPub = null;
|
||||
|
||||
|
||||
/**
|
||||
* AP constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct(
|
||||
AcceptInterface $acceptInterface,
|
||||
AddInterface $addInterface,
|
||||
AnnounceInterface $announceInterface,
|
||||
BlockInterface $blockInterface,
|
||||
CreateInterface $createInterface,
|
||||
DeleteInterface $deleteInterface,
|
||||
DocumentInterface $documentInterface,
|
||||
FollowInterface $followInterface,
|
||||
ImageInterface $imageInterface,
|
||||
LikeInterface $likeInterface,
|
||||
NoteInterface $noteInterface,
|
||||
SocialAppNotificationInterface $socialAppNotificationInterface,
|
||||
PersonInterface $personInterface,
|
||||
ServiceInterface $serviceInterface,
|
||||
GroupInterface $groupInterface,
|
||||
OrganizationInterface $organizationInterface,
|
||||
ApplicationInterface $applicationInterface,
|
||||
RejectInterface $rejectInterface,
|
||||
RemoveInterface $removeInterface,
|
||||
UndoInterface $undoInterface,
|
||||
UpdateInterface $updateInterface,
|
||||
ConfigService $configService
|
||||
) {
|
||||
$this->acceptInterface = $acceptInterface;
|
||||
$this->addInterface = $addInterface;
|
||||
$this->announceInterface = $announceInterface;
|
||||
$this->blockInterface = $blockInterface;
|
||||
$this->createInterface = $createInterface;
|
||||
$this->deleteInterface = $deleteInterface;
|
||||
$this->documentInterface = $documentInterface;
|
||||
$this->followInterface = $followInterface;
|
||||
$this->imageInterface = $imageInterface;
|
||||
$this->likeInterface = $likeInterface;
|
||||
$this->noteInterface = $noteInterface;
|
||||
$this->socialAppNotificationInterface = $socialAppNotificationInterface;
|
||||
$this->personInterface = $personInterface;
|
||||
$this->serviceInterface = $serviceInterface;
|
||||
$this->groupInterface = $groupInterface;
|
||||
$this->organizationInterface = $organizationInterface;
|
||||
$this->applicationInterface = $applicationInterface;
|
||||
$this->rejectInterface = $rejectInterface;
|
||||
$this->removeInterface = $removeInterface;
|
||||
$this->undoInterface = $undoInterface;
|
||||
$this->updateInterface = $updateInterface;
|
||||
$this->configService = $configService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function init() {
|
||||
$ap = new AP();
|
||||
try {
|
||||
$ap->acceptInterface = OC::$server->query(AcceptInterface::class);
|
||||
$ap->addInterface = OC::$server->query(AddInterface::class);
|
||||
$ap->announceInterface = OC::$server->query(AnnounceInterface::class);
|
||||
$ap->blockInterface = OC::$server->query(BlockInterface::class);
|
||||
$ap->createInterface = OC::$server->query(CreateInterface::class);
|
||||
$ap->deleteInterface = OC::$server->query(DeleteInterface::class);
|
||||
$ap->documentInterface = OC::$server->query(DocumentInterface::class);
|
||||
$ap->followInterface = OC::$server->query(FollowInterface::class);
|
||||
$ap->imageInterface = OC::$server->query(ImageInterface::class);
|
||||
$ap->likeInterface = OC::$server->query(LikeInterface::class);
|
||||
$ap->noteInterface = OC::$server->query(NoteInterface::class);
|
||||
$ap->notificationInterface = OC::$server->query(SocialAppNotificationInterface::class);
|
||||
$ap->personInterface = OC::$server->query(PersonInterface::class);
|
||||
$ap->serviceInterface = OC::$server->query(ServiceInterface::class);
|
||||
$ap->groupInterface = OC::$server->query(GroupInterface::class);
|
||||
$ap->groupInterface = OC::$server->query(OrganizationInterface::class);
|
||||
$ap->groupInterface = OC::$server->query(ApplicationInterface::class);
|
||||
$ap->rejectInterface = OC::$server->query(RejectInterface::class);
|
||||
$ap->removeInterface = OC::$server->query(RemoveInterface::class);
|
||||
$ap->undoInterface = OC::$server->query(UndoInterface::class);
|
||||
$ap->updateInterface = OC::$server->query(UpdateInterface::class);
|
||||
|
||||
$ap->configService = OC::$server->query(ConfigService::class);
|
||||
|
||||
AP::$activityPub = $ap;
|
||||
AP::$activityPub = Server::get(AP::class);
|
||||
} catch (QueryException $e) {
|
||||
OC::$server->getLogger()
|
||||
->logException($e);
|
||||
Server::get(LoggerInterface::class)
|
||||
->errir($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param ACore $parent
|
||||
* @param int $level
|
||||
*
|
||||
* @return ACore
|
||||
* @throws RedundancyLimitException
|
||||
* @throws SocialAppConfigException
|
||||
* @throws ItemUnknownException
|
||||
|
@ -232,10 +202,6 @@ class AP {
|
|||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param ACore $item
|
||||
* @param int $level
|
||||
*
|
||||
* @throws RedundancyLimitException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -258,10 +224,6 @@ class AP {
|
|||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param ACore $item
|
||||
* @param int $level
|
||||
*
|
||||
* @throws RedundancyLimitException
|
||||
* @throws SocialAppConfigException
|
||||
*/
|
||||
|
@ -279,9 +241,6 @@ class AP {
|
|||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return ACore
|
||||
* @throws SocialAppConfigException
|
||||
* @throws ItemUnknownException
|
||||
*/
|
||||
|
@ -425,103 +384,75 @@ class AP {
|
|||
public function getInterfaceFromType(string $type): IActivityPubInterface {
|
||||
switch ($type) {
|
||||
case Accept::TYPE:
|
||||
$interface = $this->acceptInterface;
|
||||
break;
|
||||
return $this->acceptInterface;
|
||||
|
||||
case Add::TYPE:
|
||||
$interface = $this->addInterface;
|
||||
break;
|
||||
return $this->addInterface;
|
||||
|
||||
case Announce::TYPE:
|
||||
$interface = $this->announceInterface;
|
||||
break;
|
||||
return $this->announceInterface;
|
||||
|
||||
case Block::TYPE:
|
||||
$interface = $this->blockInterface;
|
||||
break;
|
||||
return $this->blockInterface;
|
||||
|
||||
case Create::TYPE:
|
||||
$interface = $this->createInterface;
|
||||
break;
|
||||
return $this->createInterface;
|
||||
|
||||
case Delete::TYPE:
|
||||
$interface = $this->deleteInterface;
|
||||
break;
|
||||
return $this->deleteInterface;
|
||||
|
||||
case Document::TYPE:
|
||||
$interface = $this->documentInterface;
|
||||
break;
|
||||
return $this->documentInterface;
|
||||
|
||||
case Follow::TYPE:
|
||||
$interface = $this->followInterface;
|
||||
break;
|
||||
return $this->followInterface;
|
||||
|
||||
case Image::TYPE:
|
||||
$interface = $this->imageInterface;
|
||||
break;
|
||||
return $this->imageInterface;
|
||||
|
||||
case Like::TYPE:
|
||||
$interface = $this->likeInterface;
|
||||
break;
|
||||
return $this->likeInterface;
|
||||
|
||||
case Note::TYPE:
|
||||
$interface = $this->noteInterface;
|
||||
break;
|
||||
return $this->noteInterface;
|
||||
|
||||
case SocialAppNotification::TYPE:
|
||||
$interface = $this->notificationInterface;
|
||||
break;
|
||||
return $this->notificationInterface;
|
||||
|
||||
case Person::TYPE:
|
||||
$interface = $this->personInterface;
|
||||
break;
|
||||
return $this->personInterface;
|
||||
|
||||
case Reject::TYPE:
|
||||
$interface = $this->rejectInterface;
|
||||
break;
|
||||
return $this->rejectInterface;
|
||||
|
||||
case Remove::TYPE:
|
||||
$interface = $this->removeInterface;
|
||||
break;
|
||||
return $this->removeInterface;
|
||||
|
||||
case Service::TYPE:
|
||||
$interface = $this->serviceInterface;
|
||||
break;
|
||||
return $this->serviceInterface;
|
||||
|
||||
case Undo::TYPE:
|
||||
$interface = $this->undoInterface;
|
||||
break;
|
||||
return $this->undoInterface;
|
||||
|
||||
case Update::TYPE:
|
||||
$interface = $this->updateInterface;
|
||||
break;
|
||||
return $this->updateInterface;
|
||||
|
||||
default:
|
||||
throw new ItemUnknownException();
|
||||
}
|
||||
|
||||
return $interface;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isActor(ACore $item): bool {
|
||||
$types =
|
||||
[
|
||||
Person::TYPE,
|
||||
Service::TYPE,
|
||||
Group::TYPE,
|
||||
Organization::TYPE,
|
||||
Application::TYPE
|
||||
];
|
||||
$types = [
|
||||
Person::TYPE,
|
||||
Service::TYPE,
|
||||
Group::TYPE,
|
||||
Organization::TYPE,
|
||||
Application::TYPE
|
||||
];
|
||||
|
||||
return (in_array($item->getType(), $types));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AP::init();
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace OCA\Social\Controller;
|
|||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OC;
|
||||
use OCP\AppFramework\Http;
|
||||
use OC\User\NoUserException;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
|
@ -55,6 +54,8 @@ use OCP\IInitialStateService;
|
|||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* Class NavigationController
|
||||
|
@ -119,7 +120,7 @@ class NavigationController extends Controller {
|
|||
'public' => false,
|
||||
'firstrun' => false,
|
||||
'setup' => false,
|
||||
'isAdmin' => OC::$server->getGroupManager()
|
||||
'isAdmin' => Server::get(IGroupManager::class)
|
||||
->isAdmin($this->userId),
|
||||
'cliUrl' => $this->getCliUrl()
|
||||
];
|
||||
|
|
|
@ -211,6 +211,7 @@ class OAuthController extends Controller {
|
|||
// TODO : finalize result if no redirect_url
|
||||
return new DataResponse(
|
||||
[
|
||||
'code' => $code,
|
||||
// 'access_token' => '',
|
||||
// "token_type" => "Bearer",
|
||||
// "scope" => "read write follow push",
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace OCA\Social\Cron;
|
|||
use Exception;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Service\AccountService;
|
||||
use OCA\Social\Service\CacheActorService;
|
||||
use OCA\Social\Service\DocumentService;
|
||||
|
@ -47,36 +46,26 @@ use OCP\AppFramework\QueryException;
|
|||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Cache extends TimedJob {
|
||||
private ?AccountService $accountService = null;
|
||||
private ?CacheActorService $cacheActorService = null;
|
||||
private ?DocumentService $documentService = null;
|
||||
private ?HashtagService $hashtagService = null;
|
||||
private AccountService $accountService;
|
||||
private CacheActorService $cacheActorService;
|
||||
private DocumentService $documentService;
|
||||
private HashtagService $hashtagService;
|
||||
|
||||
public function __construct(ITimeFactory $time) {
|
||||
public function __construct(ITimeFactory $time, AccountService $accountService, CacheActorService $cacheActorService, DocumentService $documentService, HashtagService $hashtagService) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 60); // 12 minutes
|
||||
$this->accountService = $accountService;
|
||||
$this->cacheActorService = $cacheActorService;
|
||||
$this->documentService = $documentService;
|
||||
$this->hashtagService = $hashtagService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $argument
|
||||
*
|
||||
* @throws QueryException
|
||||
*/
|
||||
protected function run($argument) {
|
||||
$app = \OC::$server->get(Application::class);
|
||||
$c = $app->getContainer();
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
private function manageCache() {
|
||||
try {
|
||||
$this->accountService->blindKeyRotation();
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace OCA\Social\Cron;
|
|||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCP\AppFramework\QueryException;
|
||||
|
||||
|
@ -43,11 +42,12 @@ use OCP\AppFramework\QueryException;
|
|||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Chunk extends TimedJob {
|
||||
private ?ConfigService $configService = null;
|
||||
private ConfigService $configService;
|
||||
|
||||
public function __construct(ITimeFactory $time) {
|
||||
public function __construct(ITimeFactory $time, ConfigService $configService) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 3600); // 12 hours
|
||||
$this->configService = $configService;
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,11 +57,6 @@ class Chunk extends TimedJob {
|
|||
* @throws QueryException
|
||||
*/
|
||||
protected function run($argument) {
|
||||
$app = \OC::$server->query(Application::class);
|
||||
$c = $app->getContainer();
|
||||
|
||||
$this->configService = $c->query(ConfigService::class);
|
||||
|
||||
$size = (int)$this->configService->getAppValue(ConfigService::DATABASE_CHUNK_SIZE);
|
||||
$this->morphChunks($size);
|
||||
}
|
||||
|
@ -70,6 +65,6 @@ class Chunk extends TimedJob {
|
|||
/**
|
||||
* @param int $size
|
||||
*/
|
||||
private function morphChunks(int $size) {
|
||||
private function morphChunks(int $size): void {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace OCA\Social\Cron;
|
|||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use OCA\Social\Service\ActivityService;
|
||||
use OCA\Social\Service\RequestQueueService;
|
||||
|
@ -46,16 +45,19 @@ use OCP\AppFramework\QueryException;
|
|||
* @package OCA\Social\Cron
|
||||
*/
|
||||
class Queue extends TimedJob {
|
||||
private ?ActivityService $activityService = null;
|
||||
private ?RequestQueueService $requestQueueService = null;
|
||||
private ?StreamQueueService $streamQueueService = null;
|
||||
private ActivityService $activityService;
|
||||
private RequestQueueService $requestQueueService;
|
||||
private StreamQueueService $streamQueueService;
|
||||
|
||||
/**
|
||||
* Cache constructor.
|
||||
*/
|
||||
public function __construct(ITimeFactory $time) {
|
||||
public function __construct(ITimeFactory $time, RequestQueueService $requestQueueService, StreamQueueService $streamQueueService, ActivityService $activityService) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(12 * 60); // 12 minutes
|
||||
$this->requestQueueService = $requestQueueService;
|
||||
$this->streamQueueService = $streamQueueService;
|
||||
$this->activityService = $activityService;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,14 +67,6 @@ class Queue extends TimedJob {
|
|||
* @throws QueryException
|
||||
*/
|
||||
protected function run($argument) {
|
||||
/** @var Application $app */
|
||||
$app = \OC::$server->get(Application::class);
|
||||
$c = $app->getContainer();
|
||||
|
||||
$this->requestQueueService = $c->get(RequestQueueService::class);
|
||||
$this->streamQueueService = $c->get(StreamQueueService::class);
|
||||
$this->activityService = $c->get(ActivityService::class);
|
||||
|
||||
$this->manageRequestQueue();
|
||||
$this->manageStreamQueue();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ use daita\MySmallPhpTools\Traits\TArrayTools;
|
|||
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\Instance;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
|
||||
/**
|
||||
* Class InstancesRequest
|
||||
|
@ -54,9 +55,20 @@ class InstancesRequest extends InstancesRequestBuilder {
|
|||
// $instance->setCreation($now->getTimestamp());
|
||||
|
||||
$qb = $this->getInstanceInsertSql();
|
||||
$qb->setValue('uri', $qb->createNamedParameter($instance->getUri()));
|
||||
|
||||
$qb->execute();
|
||||
$qb->setValue('uri', $qb->createNamedParameter($instance->getUri()))
|
||||
->setValue('local', $qb->createNamedParameter($instance->isLocal()), IQueryBuilder::PARAM_BOOL)
|
||||
->setValue('title', $qb->createNamedParameter($instance->getTitle()))
|
||||
->setValue('version', $qb->createNamedParameter($instance->getVersion()))
|
||||
->setValue('short_description', $qb->createNamedParameter($instance->getShortDescription()))
|
||||
->setValue('description', $qb->createNamedParameter($instance->getDescription()))
|
||||
->setValue('email', $qb->createNamedParameter($instance->getEmail()))
|
||||
->setValue('urls', $qb->createNamedParameter(json_encode($instance->getUrls())))
|
||||
->setValue('stats', $qb->createNamedParameter(json_encode($instance->getStats())))
|
||||
->setValue('usage', $qb->createNamedParameter(json_encode($instance->getUsage())))
|
||||
->setValue('image', $qb->createNamedParameter($instance->getImage()))
|
||||
->setValue('languages', $qb->createNamedParameter(json_encode($instance->getImage())))
|
||||
->setValue('account_prim', $qb->createNamedParameter($instance->getAccountPrim() ? $this->prim($instance->getAccountPrim()) : null));
|
||||
$qb->executeStatement();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
|
|||
|
||||
$expr = $this->expr();
|
||||
if ($link !== '') {
|
||||
$this->innerJoin(
|
||||
$this->leftJoin(
|
||||
$this->getDefaultSelectAlias(), CoreRequestBuilder::TABLE_CACHE_ACTORS, $pf,
|
||||
$expr->eq('ca.id_prim', $link)
|
||||
);
|
||||
|
|
|
@ -34,7 +34,9 @@ namespace OCA\Social\Db;
|
|||
use daita\MySmallPhpTools\Traits\TStringTools;
|
||||
use OCA\Social\Model\ActivityPub\Object\Note;
|
||||
use OCA\Social\Model\ActivityPub\Stream;
|
||||
use OCP\Server;
|
||||
use OCP\DB\Exception as DBException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class StreamTagsRequest
|
||||
|
@ -58,7 +60,7 @@ class StreamTagsRequest extends StreamTagsRequestBuilder {
|
|||
try {
|
||||
$qb->executeStatement();
|
||||
} catch (DBException $e) {
|
||||
\OC::$server->getLogger()
|
||||
Server::get(LoggerInterface::class)
|
||||
->log(1, 'Social - Duplicate hashtag on Stream ' . json_encode($stream));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,18 +246,10 @@ class Instance implements IQueryRow, JsonSerializable {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountPrim(): string {
|
||||
public function getAccountPrim(): ?string {
|
||||
return $this->accountPrim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prim
|
||||
*
|
||||
* @return Instance
|
||||
*/
|
||||
public function setAccountPrim(string $prim): self {
|
||||
$this->accountPrim = $prim;
|
||||
|
||||
|
|
|
@ -36,37 +36,40 @@ use OCA\Social\Db\InstancesRequest;
|
|||
use OCA\Social\Exceptions\InstanceDoesNotExistException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\Instance;
|
||||
use OCP\IConfig;
|
||||
|
||||
class InstanceService {
|
||||
use TArrayTools;
|
||||
|
||||
|
||||
private $instancesRequest;
|
||||
|
||||
private InstancesRequest $instancesRequest;
|
||||
private ConfigService $configService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
private IConfig $config;
|
||||
|
||||
public function __construct(
|
||||
InstancesRequest $instancesRequest, ConfigService $configService, MiscService $miscService
|
||||
InstancesRequest $instancesRequest,
|
||||
ConfigService $configService,
|
||||
MiscService $miscService,
|
||||
IConfig $config
|
||||
) {
|
||||
$this->instancesRequest = $instancesRequest;
|
||||
$this->configService = $configService;
|
||||
$this->miscService = $miscService;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function createLocal(): void {
|
||||
public function createLocal(): Instance {
|
||||
$instance = new Instance();
|
||||
$instance->setLocal(true)
|
||||
->setVersion($this->config->getAppValue('social', 'installed_version', '0.0'))
|
||||
->setApprovalRequired(false)
|
||||
->setDescription($this->config->getAppValue('theming', 'slogan', 'a safe home for your data'))
|
||||
->setTitle($this->config->getAppValue('theming', 'name', 'Nextcloud Social'));
|
||||
$this->instancesRequest->save($instance);
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $format
|
||||
*
|
||||
* @return Instance
|
||||
* @throws InstanceDoesNotExistException
|
||||
*/
|
||||
public function getLocal(int $format = ACore::FORMAT_LOCAL): Instance {
|
||||
|
@ -75,8 +78,6 @@ class InstanceService {
|
|||
} catch (InstanceDoesNotExistException $e) {
|
||||
}
|
||||
|
||||
$this->createLocal();
|
||||
|
||||
return $this->instancesRequest->getLocal($format);
|
||||
return $this->createLocal();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,18 +53,12 @@ class PushService {
|
|||
use TAsync;
|
||||
|
||||
private DetailsService $detailsService;
|
||||
|
||||
private StreamService $streamService;
|
||||
|
||||
private MiscService $miscService;
|
||||
|
||||
|
||||
/**
|
||||
* PushService constructor.
|
||||
*
|
||||
* @param DetailsService $detailsService
|
||||
* @param StreamService $streamService
|
||||
* @param MiscService $miscService
|
||||
*/
|
||||
public function __construct(
|
||||
DetailsService $detailsService, StreamService $streamService, MiscService $miscService
|
||||
|
|
|
@ -42,7 +42,6 @@ use daita\MySmallPhpTools\Traits\TArrayTools;
|
|||
use DateTime;
|
||||
use Exception;
|
||||
use JsonLdException;
|
||||
use OC;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Db\ActorsRequest;
|
||||
use OCA\Social\Exceptions\ActorDoesNotExistException;
|
||||
|
@ -59,11 +58,13 @@ use OCA\Social\Model\ActivityPub\ACore;
|
|||
use OCA\Social\Model\ActivityPub\Actor\Person;
|
||||
use OCA\Social\Model\LinkedDataSignature;
|
||||
use OCA\Social\Model\RequestQueue;
|
||||
use OCP\Files\AppData\IAppDataFactory;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\NotPermittedException;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
use OCP\Files\SimpleFS\ISimpleFolder;
|
||||
use OCP\IRequest;
|
||||
use OCP\Server;
|
||||
use stdClass;
|
||||
|
||||
class SignatureService {
|
||||
|
@ -573,7 +574,7 @@ class SignatureService {
|
|||
private static function getContextCacheFolder(): ISimpleFolder {
|
||||
$path = 'context';
|
||||
|
||||
$appData = OC::$server->getAppDataDir(Application::APP_NAME);
|
||||
$appData = Server::get(IAppDataFactory::class)->get(Application::APP_NAME);
|
||||
try {
|
||||
$folder = $appData->getFolder($path);
|
||||
} catch (NotFoundException $e) {
|
||||
|
|
|
@ -31,20 +31,20 @@ namespace OCA\Social;
|
|||
|
||||
use OCA\Social\Exceptions\SocialAppConfigException;
|
||||
use Exception;
|
||||
use OC;
|
||||
use OCP\Server;
|
||||
use OCA\Social\Service\ConfigService;
|
||||
use OCA\Social\Service\FediverseService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
try {
|
||||
$fediverseService = OC::$server->query(FediverseService::class);
|
||||
$fediverseService = Server::get(FediverseService::class);
|
||||
/** @var ConfigService $configService */
|
||||
$configService = OC::$server->query(ConfigService::class);
|
||||
$configService = Server::get(ConfigService::class);
|
||||
$fediverseService->jailed();
|
||||
} catch (Exception $e) {
|
||||
OC::$server->getLogger()
|
||||
->log(1, 'Exception on hostmeta - ' . $e->getMessage());
|
||||
Server::get(LoggerInterface::class)->log(1, 'Exception on hostmeta - ' . $e->getMessage());
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
|
||||
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
|
||||
<file src="lib/AP.php">
|
||||
<InvalidScalarArgument occurrences="1">
|
||||
<code>$level</code>
|
||||
</InvalidScalarArgument>
|
||||
<UndefinedPropertyAssignment occurrences="3">
|
||||
<code>$ap->groupInterface</code>
|
||||
<code>$ap->groupInterface</code>
|
||||
<code>$ap->groupInterface</code>
|
||||
</UndefinedPropertyAssignment>
|
||||
</file>
|
||||
<file src="lib/Db/CoreRequestBuilder.php">
|
||||
<UndefinedVariable occurrences="1">
|
||||
<code>$schema</code>
|
||||
</UndefinedVariable>
|
||||
</file>
|
||||
<file src="lib/Migration/Version0003Date20200823023900.php">
|
||||
<UndefinedDocblockClass occurrences="1">
|
||||
|
@ -137,9 +137,9 @@
|
|||
<RedundantCondition occurrences="1">
|
||||
<code>$varr[0] !== null</code>
|
||||
</RedundantCondition>
|
||||
<UndefinedInterfaceMethod occurrences="1">
|
||||
<code>getAppDataDir</code>
|
||||
</UndefinedInterfaceMethod>
|
||||
<UndefinedClass occurrences="1">
|
||||
<code>IFactory</code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/Service/StreamService.php">
|
||||
<InvalidReturnType occurrences="1">
|
||||
|
|
Ładowanie…
Reference in New Issue