adding route and content to the Notification Stream

pull/181/head
Maxence Lange 2018-12-08 11:41:56 -01:00
rodzic b534b11664
commit 8df77ff380
4 zmienionych plików z 70 dodań i 0 usunięć

Wyświetl plik

@ -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'],

Wyświetl plik

@ -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
*

Wyświetl plik

@ -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.

Wyświetl plik

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