summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Db/SocialCrossQueryBuilder.php25
-rw-r--r--lib/Db/StreamRequest.php1
-rw-r--r--lib/Db/StreamRequestBuilder.php5
-rw-r--r--lib/Model/ActivityPub/ACore.php4
-rw-r--r--lib/Model/ActivityPub/Stream.php10
-rw-r--r--lib/Service/AccountService.php4
-rw-r--r--lib/Service/ActorService.php10
7 files changed, 38 insertions, 21 deletions
diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php
index a90fb7b0..86932c93 100644
--- a/lib/Db/SocialCrossQueryBuilder.php
+++ b/lib/Db/SocialCrossQueryBuilder.php
@@ -141,7 +141,11 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @return Stream
* @throws InvalidResourceException
*/
- public function parseLeftJoinStream(array $data, string $prefix = ''): Stream {
+ public function parseLeftJoinStream(
+ array $data,
+ string $prefix = '',
+ int $exportFormat = 0
+ ): Stream {
$new = [];
foreach ($data as $k => $v) {
if (str_starts_with($k, $prefix)) {
@@ -149,13 +153,15 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
}
}
- $stream = new Stream();
- $stream->importFromDatabase($new);
- if ($stream->getId() === '') {
+ if (($new['nid'] ?? '') === '') {
throw new InvalidResourceException();
}
- $actor = $this->parseLeftJoinCacheActors($data, $prefix . 'cacheactor_');
+ $stream = new Stream();
+ $stream->importFromDatabase($new);
+ $stream->setExportFormat($exportFormat);
+
+ $actor = $this->parseLeftJoinCacheActors($data, $prefix . 'cacheactor_', $exportFormat);
$stream->setActor($actor);
return $stream;
@@ -168,7 +174,11 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @return Person
* @throws InvalidResourceException
*/
- public function parseLeftJoinCacheActors(array $data, string $prefix = ''): Person {
+ public function parseLeftJoinCacheActors(
+ array $data,
+ string $prefix = '',
+ int $exportFormat = 0
+ ): Person {
$new = [];
foreach ($data as $k => $v) {
@@ -179,9 +189,10 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
$actor = new Person();
$actor->importFromDatabase($new);
+ $actor->setExportFormat($exportFormat);
if (!AP::$activityPub->isActor($actor)) {
- throw new InvalidResourceException();
+ throw new InvalidResourceException('actor not actor');
}
try {
diff --git a/lib/Db/StreamRequest.php b/lib/Db/StreamRequest.php
index 7b6b0e9f..ac673985 100644
--- a/lib/Db/StreamRequest.php
+++ b/lib/Db/StreamRequest.php
@@ -594,6 +594,7 @@ class StreamRequest extends StreamRequestBuilder {
$qb->limitToDest($actor->getId(), 'notif', '', 'sd');
$qb->linkToCacheActors('ca', 's.attributed_to_prim');
$qb->leftJoinStreamAction();
+ $qb->leftJoinObjectStatus();
return $this->getStreamsFromRequest($qb);
}
diff --git a/lib/Db/StreamRequestBuilder.php b/lib/Db/StreamRequestBuilder.php
index 32d47f4a..8071e733 100644
--- a/lib/Db/StreamRequestBuilder.php
+++ b/lib/Db/StreamRequestBuilder.php
@@ -36,6 +36,7 @@ use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Exceptions\StreamNotFoundException;
+use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Object\Announce;
use OCA\Social\Model\ActivityPub\Stream;
use OCA\Social\Model\InstancePath;
@@ -217,7 +218,7 @@ class StreamRequestBuilder extends CoreRequestBuilder {
}
try {
- $actor = $qb->parseLeftJoinCacheActors($data, 'cacheactor_');
+ $actor = $qb->parseLeftJoinCacheActors($data, 'cacheactor_', $qb->getFormat());
$actor->setExportFormat($qb->getFormat());
$item->setCompleteDetails(true);
$item->setActor($actor);
@@ -225,7 +226,7 @@ class StreamRequestBuilder extends CoreRequestBuilder {
}
try {
- $object = $qb->parseLeftJoinStream($data, 'objectstream_');
+ $object = $qb->parseLeftJoinStream($data, 'objectstream_', ACore::FORMAT_LOCAL);
$item->setObject($object);
} catch (InvalidResourceException $e) {
}
diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php
index da06209a..63fc65cb 100644
--- a/lib/Model/ActivityPub/ACore.php
+++ b/lib/Model/ActivityPub/ACore.php
@@ -652,7 +652,9 @@ class ACore extends Item implements JsonSerializable, IQueryRow {
* @return $this
*/
public function setExportFormat(int $format): self {
- $this->format = $format;
+ if ($format > 0) {
+ $this->format = $format;
+ }
return $this;
}
diff --git a/lib/Model/ActivityPub/Stream.php b/lib/Model/ActivityPub/Stream.php
index fbcaf200..b79496e9 100644
--- a/lib/Model/ActivityPub/Stream.php
+++ b/lib/Model/ActivityPub/Stream.php
@@ -680,19 +680,11 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
$type = '';
}
- $status = null;
- $statusPost = $this->getDetails('post');
- if (sizeof($statusPost) > 0) {
- $status = new Stream();
- $status->importFromLocal($statusPost);
- $status->setExportFormat(self::FORMAT_LOCAL);
- }
-
$result = [
'id' => (string)$this->getNid(),
'type' => $type,
'created_at' => date('Y-m-d\TH:i:s', $this->getPublishedTime()) . '.000Z',
- 'status' => $status,
+ 'status' => $this->getObject(),
];
if ($this->hasActor()) {
diff --git a/lib/Service/AccountService.php b/lib/Service/AccountService.php
index a462962b..1fbfed90 100644
--- a/lib/Service/AccountService.php
+++ b/lib/Service/AccountService.php
@@ -318,7 +318,7 @@ class AccountService {
}
$this->addLocalActorDetailCount($actor);
- $this->actorService->cacheLocalActor($actor);
+ $this->actorService->cacheLocalActorDetails($actor);
}
@@ -348,7 +348,7 @@ class AccountService {
*
* @throws NoUserException
*/
- private function updateCacheLocalActorName(Person &$actor) {
+ private function updateCacheLocalActorName(Person $actor) {
$user = $this->userManager->get($actor->getUserId());
if ($user === null) {
throw new NoUserException();
diff --git a/lib/Service/ActorService.php b/lib/Service/ActorService.php
index 17cad663..3a84f27c 100644
--- a/lib/Service/ActorService.php
+++ b/lib/Service/ActorService.php
@@ -106,6 +106,16 @@ class ActorService {
*
* @throws ItemAlreadyExistsException
*/
+ public function cacheLocalActorDetails(Person $actor) {
+ $this->cacheActorsRequest->updateDetails($actor);
+ }
+
+
+ /**
+ * @param Person $actor
+ *
+ * @throws ItemAlreadyExistsException
+ */
public function save(Person $actor) {
$this->cacheDocumentIfNeeded($actor);
$this->cacheActorsRequest->save($actor);