fill status.actor.avatar

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/1775/head
Maxence Lange 2023-06-09 11:49:37 -01:00
rodzic 5dab79c24c
commit 737ec9549f
5 zmienionych plików z 21 dodań i 15 usunięć

Wyświetl plik

@ -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 = '',
?SocialQueryBuilder $qb = null
): Stream {
$new = [];
foreach ($data as $k => $v) {
if (str_starts_with($k, $prefix)) {
@ -151,11 +155,12 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
$stream = new Stream();
$stream->importFromDatabase($new);
$stream->setExportFormat($qb?->getFormat() ?? 0);
if ($stream->getId() === '') {
throw new InvalidResourceException();
}
$actor = $this->parseLeftJoinCacheActors($data, $prefix . 'cacheactor_');
$actor = $this->parseLeftJoinCacheActors($data, $prefix . 'cacheactor_', $qb);
$stream->setActor($actor);
return $stream;
@ -168,7 +173,11 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
* @return Person
* @throws InvalidResourceException
*/
public function parseLeftJoinCacheActors(array $data, string $prefix = ''): Person {
public function parseLeftJoinCacheActors(
array $data,
string $prefix = '',
?SocialQueryBuilder $qb = null
): Person {
$new = [];
foreach ($data as $k => $v) {
@ -179,6 +188,7 @@ class SocialCrossQueryBuilder extends SocialCoreQueryBuilder {
$actor = new Person();
$actor->importFromDatabase($new);
$actor->setExportFormat($qb?->getFormat() ?? 0);
if (!AP::$activityPub->isActor($actor)) {
throw new InvalidResourceException();

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -217,7 +217,7 @@ class StreamRequestBuilder extends CoreRequestBuilder {
}
try {
$actor = $qb->parseLeftJoinCacheActors($data, 'cacheactor_');
$actor = $qb->parseLeftJoinCacheActors($data, 'cacheactor_', $qb);
$actor->setExportFormat($qb->getFormat());
$item->setCompleteDetails(true);
$item->setActor($actor);
@ -225,7 +225,8 @@ class StreamRequestBuilder extends CoreRequestBuilder {
}
try {
$object = $qb->parseLeftJoinStream($data, 'objectstream_');
$object = $qb->parseLeftJoinStream($data, 'objectstream_', $qb);
$object->setExportFormat($qb->getFormat());
$item->setObject($object);
} catch (InvalidResourceException $e) {
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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()) {