kopia lustrzana https://github.com/nextcloud/social
Merge pull request #181 from nextcloud/notifications-stream
adding route and content to the Notification Streampull/195/head
commit
7a3d006dab
|
@ -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'],
|
||||
|
|
|
@ -211,6 +211,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
|
|
|
@ -186,10 +186,42 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should returns:
|
||||
* * Public/Unlisted/Followers-only post where current $actor is tagged,
|
||||
* - Events: (not yet)
|
||||
* - people liking or re-posting your posts (not yet)
|
||||
* - someone wants to follow you (not yet)
|
||||
* - someone is following you (not yet)
|
||||
*
|
||||
* @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.
|
||||
* - to followers-only if follower is logged.
|
||||
* - to followers-only if follower is logged. (not yet (check ?))
|
||||
*
|
||||
* @param string $actorId
|
||||
* @param int $since
|
||||
|
@ -218,7 +250,7 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
/**
|
||||
* Should returns:
|
||||
* * Private message.
|
||||
* - group messages.
|
||||
* - group messages. (not yet)
|
||||
*
|
||||
* @param Person $actor
|
||||
* @param int $since
|
||||
|
@ -249,7 +281,7 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
|
||||
/**
|
||||
* Should returns:
|
||||
* - All local public/federated posts
|
||||
* * All local public/federated posts
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
|
|
|
@ -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