summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2023-06-14 08:40:18 -0100
committerGitHub <noreply@github.com>2023-06-14 08:40:18 -0100
commit63027824d574ad9f46557b4e03e93e0be95a0b08 (patch)
treeb9e6c977e812c1755e6a5492b68c4ae53355cf56
parent28e64fb04b4283dbd0b4e5dba743d24f3010648e (diff)
parenta9a4629c8b59d95f9fbc1bfc6ab2af76885491bc (diff)
Merge pull request #1775 from nextcloud/fix/noid/missing-actor-avatar-on-objectstream
fill status.actor.avatar
-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
5 files changed, 26 insertions, 19 deletions
diff --git a/lib/Db/SocialCrossQueryBuilder.php b/lib/Db/SocialCrossQueryBuilder.php
index 41e33fb9..713b479c 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 bd29ba6b..a5f38dcf 100644
--- a/lib/Db/StreamRequest.php
+++ b/lib/Db/StreamRequest.php
@@ -586,6 +586,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 620c07c8..ee1b5862 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 d4df8866..03714965 100644
--- a/lib/Model/ActivityPub/Stream.php
+++ b/lib/Model/ActivityPub/Stream.php
@@ -684,19 +684,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()) {