kopia lustrzana https://github.com/nextcloud/social
				
				
				
			adding route and content to the Notification Stream
							rodzic
							
								
									b534b11664
								
							
						
					
					
						commit
						8df77ff380
					
				|  | @ -65,6 +65,7 @@ return [ | |||
| 		['name' => 'SocialPub#displayPost', 'url' => '/@{username}/{postId}', 'verb' => 'GET'], | ||||
| 
 | ||||
| 		['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', 'verb' => 'GET'], | ||||
| 		['name' => 'Local#streamNotifications', 'url' => '/api/v1/stream/notifications', 'verb' => 'GET'], | ||||
| 		['name' => 'Local#streamTimeline', 'url' => '/api/v1/stream/timeline', 'verb' => 'GET'], | ||||
| 		['name' => 'Local#streamFederated', 'url' => '/api/v1/stream/federated', 'verb' => 'GET'], | ||||
| 		['name' => 'Local#streamDirect', 'url' => '/api/v1/stream/direct', 'verb' => 'GET'], | ||||
|  |  | |||
|  | @ -217,6 +217,31 @@ class LocalController extends Controller { | |||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @NoCSRFRequired | ||||
| 	 * @NoAdminRequired | ||||
| 	 * @NoSubAdminRequired | ||||
| 	 * | ||||
| 	 * @param int $since | ||||
| 	 * @param int $limit | ||||
| 	 * | ||||
| 	 * @return DataResponse | ||||
| 	 */ | ||||
| 	public function streamNotifications($since = 0, int $limit = 5): DataResponse { | ||||
| 		try { | ||||
| 			$this->initViewer(true); | ||||
| 			$posts = $this->noteService->getStreamNotifications($this->viewer, $since, $limit); | ||||
| 
 | ||||
| 			return $this->success($posts); | ||||
| 		} catch (Exception $e) { | ||||
| 			return $this->fail($e); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * // TODO: Delete the NoCSRF check
 | ||||
| 	 * | ||||
|  |  | |||
|  | @ -185,6 +185,38 @@ class NotesRequest extends NotesRequestBuilder { | |||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Should returns: | ||||
| 	 *  - Public/Unlisted/Followers-only post where current $actor is tagged, | ||||
| 	 *  - Events: | ||||
| 	 *    - people liking or re-posting your posts | ||||
| 	 *    - someone wants to follow you | ||||
| 	 *    - someone is following you | ||||
| 	 * | ||||
| 	 * @param Person $actor | ||||
| 	 * @param int $since | ||||
| 	 * @param int $limit | ||||
| 	 * | ||||
| 	 * @return array | ||||
| 	 */ | ||||
| 	public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array { | ||||
| 		$qb = $this->getNotesSelectSql(); | ||||
| 
 | ||||
| 		$this->limitPaginate($qb, $since, $limit); | ||||
| 		$this->limitToRecipient($qb, $actor->getId(), false); | ||||
| 		$this->leftJoinCacheActors($qb, 'attributed_to'); | ||||
| 
 | ||||
| 		$notes = []; | ||||
| 		$cursor = $qb->execute(); | ||||
| 		while ($data = $cursor->fetch()) { | ||||
| 			$notes[] = $this->parseNotesSelectSql($data); | ||||
| 		} | ||||
| 		$cursor->closeCursor(); | ||||
| 
 | ||||
| 		return $notes; | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Should returns: | ||||
| 	 *  * public message from actorId. | ||||
|  |  | |||
|  | @ -361,6 +361,18 @@ class NoteService implements ICoreService { | |||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @param Person $actor | ||||
| 	 * @param int $since | ||||
| 	 * @param int $limit | ||||
| 	 * | ||||
| 	 * @return Note[] | ||||
| 	 */ | ||||
| 	public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array { | ||||
| 		return $this->notesRequest->getStreamNotifications($actor, $since, $limit); | ||||
| 	} | ||||
| 
 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * @param string $actorId | ||||
| 	 * @param int $since | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Maxence Lange
						Maxence Lange