Merge pull request #1781 from nextcloud/fix/noid/update-stream-details

update stream details
pull/1783/head
Maxence Lange 2023-06-14 08:40:47 -01:00 zatwierdzone przez GitHub
commit 3cdaba3824
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 12 dodań i 8 usunięć

Wyświetl plik

@ -105,7 +105,6 @@ class StreamRequest extends StreamRequestBuilder {
public function update(Stream $stream, bool $generateDest = false): void { public function update(Stream $stream, bool $generateDest = false): void {
$qb = $this->getStreamUpdateSql(); $qb = $this->getStreamUpdateSql();
$qb->set('details', $qb->createNamedParameter(json_encode($stream->getDetailsAll())));
$qb->set('to', $qb->createNamedParameter($stream->getTo())); $qb->set('to', $qb->createNamedParameter($stream->getTo()));
$qb->set( $qb->set(
'cc', $qb->createNamedParameter(json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES)) 'cc', $qb->createNamedParameter(json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES))
@ -121,6 +120,15 @@ class StreamRequest extends StreamRequestBuilder {
} }
} }
public function updateDetails(Stream $stream): void {
$qb = $this->getStreamUpdateSql();
$qb->set('details', $qb->createNamedParameter(json_encode($stream->getDetailsAll())));
$qb->limitToIdPrim($qb->prim($stream->getId()));
$qb->executeStatement();
}
public function updateCache(Stream $stream, Cache $cache): void { public function updateCache(Stream $stream, Cache $cache): void {
$qb = $this->getStreamUpdateSql(); $qb = $this->getStreamUpdateSql();
$qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES))); $qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES)));

Wyświetl plik

@ -305,7 +305,7 @@ class AnnounceInterface extends AbstractActivityPubInterface implements IActivit
'boosts', $this->actionsRequest->countActions($post->getId(), Announce::TYPE) 'boosts', $this->actionsRequest->countActions($post->getId(), Announce::TYPE)
); );
$this->streamRequest->update($post, true); $this->streamRequest->updateDetails($post);
} }
/** /**

Wyświetl plik

@ -172,15 +172,11 @@ class LikeInterface extends AbstractActivityPubInterface implements IActivityPub
} }
private function updateDetails(Stream $post): void { private function updateDetails(Stream $post): void {
// if (!$post->isLocal()) {
// return;
// }
$post->setDetailInt( $post->setDetailInt(
'likes', $this->actionsRequest->countActions($post->getId(), Like::TYPE) 'likes', $this->actionsRequest->countActions($post->getId(), Like::TYPE)
); );
$this->streamRequest->update($post, true); $this->streamRequest->updateDetails($post);
} }

Wyświetl plik

@ -127,7 +127,7 @@ class NoteInterface extends AbstractActivityPubInterface implements IActivityPub
$count = $this->streamRequest->countRepliesTo($stream->getInReplyTo()); $count = $this->streamRequest->countRepliesTo($stream->getInReplyTo());
$orig->setDetailInt('replies', $count); $orig->setDetailInt('replies', $count);
$this->streamRequest->update($orig); $this->streamRequest->updateDetails($orig);
} catch (StreamNotFoundException $e) { } catch (StreamNotFoundException $e) {
} }
} }