Merge pull request #1704 from nextcloud/enh/noid/update-action-cache

update action cache
pull/1711/head
Maxence Lange 2023-04-03 08:56:42 -01:00 zatwierdzone przez GitHub
commit 91a793c9f9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 37 dodań i 3 usunięć

Wyświetl plik

@ -332,6 +332,23 @@ class StreamRequest extends StreamRequestBuilder {
}
/**
* @param string $id
*
* @return int
*/
public function countRepliesTo(string $id): int {
$qb = $this->countNotesSelectSql();
$qb->limitToInReplyTo($id, true);
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor->closeCursor();
return $this->getInt('count', $data, 0);
}
/**
* @param string $actorId
*

Wyświetl plik

@ -90,6 +90,7 @@ class NoteInterface extends AbstractActivityPubInterface implements IActivityPub
$this->streamRequest->getStreamById($note->getId());
} catch (StreamNotFoundException $e) {
$this->streamRequest->save($note);
$this->updateDetails($note);
$this->pushService->onNewStream($note->getId());
}
}
@ -98,4 +99,20 @@ class NoteInterface extends AbstractActivityPubInterface implements IActivityPub
/** @var Note $item */
$this->streamRequest->deleteById($item->getId(), Note::TYPE);
}
public function updateDetails(Note $stream): void {
if ($stream->getInReplyTo() === '') {
return;
}
try {
$orig = $this->streamRequest->getStreamById($stream->getInReplyTo());
$count = $this->streamRequest->countRepliesTo($stream->getInReplyTo());
$orig->setDetailInt('replies', $count);
$this->streamRequest->update($orig);
} catch (StreamNotFoundException $e) {
}
}
}

Wyświetl plik

@ -635,9 +635,9 @@ class Stream extends ACore implements IQueryRow, JsonSerializable {
"in_reply_to_id" => null,
"in_reply_to_account_id" => null,
'mentions' => $this->getMentions(),
'replies_count' => 0,
'reblogs_count' => 0,
'favourites_count' => 0,
'replies_count' => $this->getDetailInt('replies'),
'reblogs_count' => $this->getDetailInt('boosts'),
'favourites_count' => $this->getDetailInt('likes'),
'favourited' => $favorited,
'reblogged' => $reblogged,
'muted' => false,