kopia lustrzana https://github.com/nextcloud/social
				
				
				
			update action cache
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/1704/head
							rodzic
							
								
									1ca33be580
								
							
						
					
					
						commit
						9ce28af659
					
				|  | @ -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 | ||||
| 	 * | ||||
|  |  | |||
|  | @ -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) { | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -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, | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Maxence Lange
						Maxence Lange