kopia lustrzana https://github.com/nextcloud/social
commit
a76f96ee95
|
@ -12,11 +12,13 @@ return [
|
|||
['name' => 'Navigation#navigate', 'url' => '/', 'verb' => 'GET'],
|
||||
['name' => 'Navigation#test', 'url' => '/test', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Navigation#timeline', 'url' => '/timeline/{path}', 'verb' => 'GET',
|
||||
'requirements' => ['path' => '.+'], 'defaults' => ['path' => '']
|
||||
[
|
||||
'name' => 'Navigation#timeline', 'url' => '/timeline/{path}', 'verb' => 'GET',
|
||||
'requirements' => ['path' => '.+'], 'defaults' => ['path' => '']
|
||||
],
|
||||
['name' => 'Navigation#account', 'url' => '/account/{path}', 'verb' => 'GET',
|
||||
'requirements' => ['path' => '.+'], 'defaults' => ['path' => '']
|
||||
[
|
||||
'name' => 'Navigation#account', 'url' => '/account/{path}', 'verb' => 'GET',
|
||||
'requirements' => ['path' => '.+'], 'defaults' => ['path' => '']
|
||||
],
|
||||
// ['name' => 'Navigation#public', 'url' => '/{username}', 'verb' => 'GET'],
|
||||
|
||||
|
@ -36,16 +38,21 @@ return [
|
|||
|
||||
['name' => 'SocialPub#displayPost', 'url' => '/@{username}/{postId}', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Local#streamHome', 'url' => '/api/v1/stream/home', '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'],
|
||||
['name' => 'Local#postCreate', 'url' => '/api/v1/post', 'verb' => 'POST'],
|
||||
['name' => 'Local#postDelete', 'url' => '/api/v1/post', 'verb' => 'DELETE'],
|
||||
['name' => 'Local#timeline', 'url' => '/api/v1/timeline', 'verb' => 'GET'],
|
||||
['name' => 'Local#direct', 'url' => '/api/v1/direct', 'verb' => 'PUT'],
|
||||
['name' => 'Local#accountsSearch', 'url' => '/api/v1/accounts/search', 'verb' => 'GET'],
|
||||
['name' => 'Local#accountFollow', 'url' => '/api/v1/account/follow', 'verb' => 'PUT'],
|
||||
['name' => 'Local#accountUnfollow', 'url' => '/api/v1/account/follow', 'verb' => 'DELETE'],
|
||||
['name' => 'Local#actorInfo', 'url' => '/api/v1/actor/info', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'Config#setCloudAddress', 'url' => '/api/v1/config/cloudAddress', 'verb' => 'POST'],
|
||||
[
|
||||
'name' => 'Config#setCloudAddress', 'url' => '/api/v1/config/cloudAddress',
|
||||
'verb' => 'POST'
|
||||
],
|
||||
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
@ -30,12 +30,11 @@ declare(strict_types=1);
|
|||
namespace OCA\Social\Controller;
|
||||
|
||||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use daita\MySmallPhpTools\Traits\Nextcloud\TNCDataResponse;
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use Exception;
|
||||
use OCA\Social\AppInfo\Application;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Exceptions\RequestException;
|
||||
use OCA\Social\Model\ActivityPub\ACore;
|
||||
use OCA\Social\Model\Post;
|
||||
use OCA\Social\Service\ActivityPub\FollowService;
|
||||
|
@ -45,7 +44,6 @@ use OCA\Social\Service\ActorService;
|
|||
use OCA\Social\Service\MiscService;
|
||||
use OCA\Social\Service\PostService;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
|
||||
|
@ -135,7 +133,7 @@ class LocalController extends Controller {
|
|||
$post->setType($this->get('type', $data, NoteService::TYPE_PUBLIC));
|
||||
|
||||
/** @var ACore $activity */
|
||||
$result = $this->postService->createPost($post, $activity);
|
||||
$this->postService->createPost($post, $activity);
|
||||
|
||||
return $this->directSuccess($activity->getObject());
|
||||
} catch (Exception $e) {
|
||||
|
@ -175,8 +173,6 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* Get timeline
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
|
@ -185,9 +181,11 @@ class LocalController extends Controller {
|
|||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function timeline($since = 0, $limit = 5): DataResponse {
|
||||
public function streamHome(): DataResponse {
|
||||
|
||||
try {
|
||||
$posts = $this->noteService->getTimeline((int)$since, (int)$limit);
|
||||
$actor = $this->actorService->getActorFromUserId($this->userId);
|
||||
$posts = $this->noteService->getHomeNotesForActor($actor);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
@ -197,16 +195,68 @@ class LocalController extends Controller {
|
|||
|
||||
|
||||
/**
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function direct(): DataResponse {
|
||||
public function streamDirect(): DataResponse {
|
||||
|
||||
try {
|
||||
$actor = $this->actorService->getActorFromUserId($this->userId);
|
||||
$posts = $this->noteService->getNotesForActor($actor);
|
||||
$posts = $this->noteService->getDirectNotesForActor($actor);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get timeline
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamTimeline(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$posts = $this->noteService->getLocalTimeline($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get timeline
|
||||
*
|
||||
* // TODO: Delete the NoCSRF check
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
* @NoSubAdminRequired
|
||||
*
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function streamFederated(int $since = 0, int $limit = 5): DataResponse {
|
||||
try {
|
||||
$posts = $this->noteService->getFederatedTimeline($since, $limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -84,12 +84,12 @@ class CoreRequestBuilder {
|
|||
* @param int $id
|
||||
*/
|
||||
protected function limitToId(IQueryBuilder &$qb, int $id) {
|
||||
$this->limitToDBField($qb, 'id', $id);
|
||||
$this->limitToDBFieldInt($qb, 'id', $id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit the request to the Id
|
||||
* Limit the request to the Id (string)
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $id
|
||||
|
@ -100,56 +100,37 @@ class CoreRequestBuilder {
|
|||
|
||||
|
||||
/**
|
||||
* Limit the request to the OwnerId
|
||||
* Limit the request to the UserId
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $userId
|
||||
*/
|
||||
protected function limitToUserId(IQueryBuilder &$qb, $userId) {
|
||||
protected function limitToUserId(IQueryBuilder &$qb, string $userId) {
|
||||
$this->limitToDBField($qb, 'user_id', $userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit the request to the OwnerId
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $userId
|
||||
*/
|
||||
protected function limitToPreferredUsername(IQueryBuilder &$qb, $userId) {
|
||||
$this->limitToDBField($qb, 'preferred_username', $userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the request to the OwnerId
|
||||
* Limit the request to the Preferred Username
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $username
|
||||
*/
|
||||
protected function searchInPreferredUsername(IQueryBuilder &$qb, $username) {
|
||||
$this->searchInDBField($qb, 'preferred_username', $username . '%');
|
||||
protected function limitToPreferredUsername(IQueryBuilder &$qb, string $username) {
|
||||
$this->limitToDBField($qb, 'preferred_username', $username);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit the request to the OwnerId
|
||||
* search using username
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param int $accountId
|
||||
* @param string $username
|
||||
*/
|
||||
protected function limitToAccountId(IQueryBuilder &$qb, int $accountId) {
|
||||
$this->limitToDBField($qb, 'account_id', $accountId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit the request to the ServiceId
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param int $serviceId
|
||||
*/
|
||||
protected function limitToServiceId(IQueryBuilder &$qb, int $serviceId) {
|
||||
$this->limitToDBField($qb, 'service_id', $serviceId);
|
||||
protected function searchInPreferredUsername(IQueryBuilder &$qb, string $username) {
|
||||
$dbConn = $this->dbConnection;
|
||||
$this->searchInDBField(
|
||||
$qb, 'preferred_username', $dbConn->escapeLikeParameter($username) . '%'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,9 +139,10 @@ class CoreRequestBuilder {
|
|||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $actorId
|
||||
* @param string $alias
|
||||
*/
|
||||
protected function limitToActorId(IQueryBuilder &$qb, string $actorId) {
|
||||
$this->limitToDBField($qb, 'actor_id', $actorId);
|
||||
protected function limitToActorId(IQueryBuilder &$qb, string $actorId, string $alias = '') {
|
||||
$this->limitToDBField($qb, 'actor_id', $actorId, true, $alias);
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,7 +186,8 @@ class CoreRequestBuilder {
|
|||
* @param string $account
|
||||
*/
|
||||
protected function searchInAccount(IQueryBuilder &$qb, string $account) {
|
||||
$this->searchInDBField($qb, 'account', $account . '%');
|
||||
$dbConn = $this->dbConnection;
|
||||
$this->searchInDBField($qb, 'account', $dbConn->escapeLikeParameter($account) . '%');
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,11 +219,22 @@ class CoreRequestBuilder {
|
|||
* @param IQueryBuilder $qb
|
||||
* @param string $address
|
||||
*/
|
||||
protected function limitToAddress(IQueryBuilder &$qb, $address) {
|
||||
protected function limitToAddress(IQueryBuilder &$qb, string $address) {
|
||||
$this->limitToDBField($qb, 'address', $address);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Limit the request to the instance
|
||||
*
|
||||
* @param IQueryBuilder $qb
|
||||
* @param bool $local
|
||||
*/
|
||||
protected function limitToLocal(IQueryBuilder &$qb, bool $local) {
|
||||
$this->limitToDBField($qb, 'local', ($local) ? '1' : '0');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $recipient
|
||||
|
@ -248,15 +242,32 @@ class CoreRequestBuilder {
|
|||
protected function limitToRecipient(IQueryBuilder &$qb, string $recipient) {
|
||||
$expr = $qb->expr();
|
||||
$orX = $expr->orX();
|
||||
$dbConn = $this->dbConnection;
|
||||
|
||||
$orX->add($expr->eq('to', $qb->createNamedParameter($recipient)));
|
||||
$orX->add($expr->like('to_array', $qb->createNamedParameter('%"' . $recipient . '"%')));
|
||||
$orX->add($expr->like('cc', $qb->createNamedParameter('%"' . $recipient . '"%')));
|
||||
$orX->add($expr->like('bcc', $qb->createNamedParameter('%"' . $recipient . '"%')));
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
'to_array',
|
||||
$qb->createNamedParameter('%"' . $dbConn->escapeLikeParameter($recipient) . '"%')
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
'cc',
|
||||
$qb->createNamedParameter('%"' . $dbConn->escapeLikeParameter($recipient) . '"%')
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
'bcc',
|
||||
$qb->createNamedParameter('%"' . $dbConn->escapeLikeParameter($recipient) . '"%')
|
||||
)
|
||||
);
|
||||
|
||||
$qb->andWhere($orX);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param int $since
|
||||
|
@ -280,13 +291,56 @@ class CoreRequestBuilder {
|
|||
$qb->orderBy('creation', 'desc');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $field
|
||||
* @param string|integer|array $values
|
||||
* @param bool $cs Case Sensitive
|
||||
* @param string $value
|
||||
* @param bool $cs - case sensitive
|
||||
* @param string $alias
|
||||
*/
|
||||
private function limitToDBField(IQueryBuilder &$qb, string $field, $values, bool $cs = true) {
|
||||
private function limitToDBField(
|
||||
IQueryBuilder &$qb, string $field, string $value, bool $cs = true, string $alias = ''
|
||||
) {
|
||||
$expr = $qb->expr();
|
||||
|
||||
$pf = '';
|
||||
if ($qb->getType() === QueryBuilder::SELECT) {
|
||||
$pf = (($alias === '') ? $this->defaultSelectAlias : $alias) . '.';
|
||||
}
|
||||
$field = $pf . $field;
|
||||
|
||||
if ($cs) {
|
||||
$qb->andWhere($expr->eq($field, $qb->createNamedParameter($value)));
|
||||
} else {
|
||||
$func = $qb->func();
|
||||
$qb->andWhere(
|
||||
$expr->eq($func->lower($field), $func->lower($qb->createNamedParameter($value)))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $field
|
||||
* @param int $value
|
||||
*/
|
||||
private function limitToDBFieldInt(IQueryBuilder &$qb, string $field, int $value) {
|
||||
$expr = $qb->expr();
|
||||
$pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->defaultSelectAlias . '.' : '';
|
||||
$field = $pf . $field;
|
||||
|
||||
$qb->andWhere($expr->eq($field, $qb->createNamedParameter($value)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $field
|
||||
* @param array $values
|
||||
*/
|
||||
private function limitToDBFieldArray(IQueryBuilder &$qb, string $field, array $values) {
|
||||
$expr = $qb->expr();
|
||||
$pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->defaultSelectAlias . '.' : '';
|
||||
$field = $pf . $field;
|
||||
|
@ -297,16 +351,13 @@ class CoreRequestBuilder {
|
|||
|
||||
$orX = $expr->orX();
|
||||
foreach ($values as $value) {
|
||||
if ($cs) {
|
||||
$orX->add($expr->eq($field, $qb->createNamedParameter($value)));
|
||||
} else {
|
||||
$orX->add($expr->iLike($field, $qb->createNamedParameter($value)));
|
||||
}
|
||||
$orX->add($expr->eq($field, $qb->createNamedParameter($value)));
|
||||
}
|
||||
|
||||
$qb->andWhere($orX);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
* @param string $field
|
||||
|
@ -314,6 +365,7 @@ class CoreRequestBuilder {
|
|||
*/
|
||||
private function searchInDBField(IQueryBuilder &$qb, string $field, string $value) {
|
||||
$expr = $qb->expr();
|
||||
|
||||
$pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->defaultSelectAlias . '.' : '';
|
||||
$field = $pf . $field;
|
||||
|
||||
|
|
|
@ -138,15 +138,42 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
|
||||
|
||||
/**
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
* @param string $actorId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPublicNotes(int $since = 0, int $limit = 5): array {
|
||||
public function getHomeNotesForActorId(string $actorId): array {
|
||||
$qb = $this->getNotesSelectSql();
|
||||
|
||||
$this->rightJoinFollowing($qb);
|
||||
$this->limitToActorId($qb, $actorId, 'f');
|
||||
// $this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
|
||||
$notes = [];
|
||||
$cursor = $qb->execute();
|
||||
while ($data = $cursor->fetch()) {
|
||||
$notes[] = $this->parseNotesSelectSql($data);
|
||||
}
|
||||
$cursor->closeCursor();
|
||||
|
||||
return $notes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
* @param bool $localOnly
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPublicNotes(int $since = 0, int $limit = 5, bool $localOnly = true): array {
|
||||
$qb = $this->getNotesSelectSql();
|
||||
$this->limitToRecipient($qb, ActivityService::TO_PUBLIC);
|
||||
$this->limitPaginate($qb, $since, $limit);
|
||||
if ($localOnly) {
|
||||
$this->limitToLocal($qb, true);
|
||||
}
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
|
||||
$notes = [];
|
||||
|
@ -159,12 +186,13 @@ class NotesRequest extends NotesRequestBuilder {
|
|||
return $notes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $actorId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNotesForActorId(string $actorId): array {
|
||||
public function getDirectNotesForActorId(string $actorId): array {
|
||||
$qb = $this->getNotesSelectSql();
|
||||
$this->limitToRecipient($qb, $actorId);
|
||||
$this->leftJoinCacheActors($qb, 'attributed_to');
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace OCA\Social\Db;
|
|||
|
||||
use daita\MySmallPhpTools\Traits\TArrayTools;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use OCA\Social\Exceptions\InvalidResourceException;
|
||||
use OCA\Social\Model\ActivityPub\Note;
|
||||
use OCA\Social\Model\InstancePath;
|
||||
|
@ -104,6 +105,53 @@ class NotesRequestBuilder extends CoreRequestBuilder {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param IQueryBuilder $qb
|
||||
*/
|
||||
protected function rightJoinFollowing(IQueryBuilder $qb) {
|
||||
if ($qb->getType() !== QueryBuilder::SELECT) {
|
||||
return;
|
||||
}
|
||||
|
||||
$expr = $qb->expr();
|
||||
$func = $qb->func();
|
||||
$pf = $this->defaultSelectAlias . '.';
|
||||
|
||||
$orX = $expr->orX();
|
||||
$orX->add($expr->eq($pf . 'to', 'f.follow_id'));
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
$pf . 'to_array', $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
$func->concat('f.follow_id', $qb->createNamedParameter('"%'))
|
||||
)
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
$pf . 'cc', $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
$func->concat('f.follow_id', $qb->createNamedParameter('"%'))
|
||||
)
|
||||
)
|
||||
);
|
||||
$orX->add(
|
||||
$expr->like(
|
||||
$pf . 'bcc', $func->concat(
|
||||
$qb->createNamedParameter('%"'),
|
||||
$func->concat('f.follow_id', $qb->createNamedParameter('"%'))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$qb->rightJoin(
|
||||
$this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'f',
|
||||
$orX
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
|
|
|
@ -287,19 +287,6 @@ class NoteService implements ICoreService {
|
|||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * @param Note $note
|
||||
// */
|
||||
// private function assignInstances(Note $note) {
|
||||
// $note->addInstancePath(new InstancePath($note->getTo()));
|
||||
// $all = array_merge($note->getToArray(), $note->getCcArray(), $note->getBccArray());
|
||||
// foreach ($all as $uri) {
|
||||
// $note->addInstancePath(new InstancePath($uri));
|
||||
// }
|
||||
// $note->addInstancePath(new InstancePath($note->getInReplyTo()));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* @param ACore $item
|
||||
*/
|
||||
|
@ -321,13 +308,12 @@ class NoteService implements ICoreService {
|
|||
|
||||
|
||||
/**
|
||||
* @param string $userId
|
||||
* @param Person $actor
|
||||
*
|
||||
* @return Note[]
|
||||
*/
|
||||
public function getTimeline(int $since = 0, int $limit = 5): array {
|
||||
return $this->notesRequest->getPublicNotes($since, $limit);
|
||||
// return $result;
|
||||
public function getHomeNotesForActor(Person $actor): array {
|
||||
return $this->notesRequest->getHomeNotesForActorId($actor->getId());
|
||||
}
|
||||
|
||||
|
||||
|
@ -336,19 +322,31 @@ class NoteService implements ICoreService {
|
|||
*
|
||||
* @return Note[]
|
||||
*/
|
||||
public function getNotesForActor(Person $actor): array {
|
||||
$privates = $this->getPrivateNotesForActor($actor);
|
||||
|
||||
return $privates;
|
||||
public function getDirectNotesForActor(Person $actor): array {
|
||||
return $this->notesRequest->getDirectNotesForActorId($actor->getId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Person $actor
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Note[]
|
||||
*/
|
||||
private function getPrivateNotesForActor(Person $actor): array {
|
||||
return $this->notesRequest->getNotesForActorId($actor->getId());
|
||||
public function getLocalTimeline(int $since = 0, int $limit = 5): array {
|
||||
return $this->notesRequest->getPublicNotes($since, $limit, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $since
|
||||
* @param int $limit
|
||||
*
|
||||
* @return Note[]
|
||||
*/
|
||||
public function getFederatedTimeline(int $since = 0, int $limit = 5): array {
|
||||
return $this->notesRequest->getPublicNotes($since, $limit, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ const actions = {
|
|||
if (typeof sinceTimestamp === 'undefined') {
|
||||
sinceTimestamp = Date.parse(state.since) / 1000
|
||||
}
|
||||
return axios.get(OC.generateUrl('apps/social/api/v1/timeline?limit=5&since=' + sinceTimestamp)).then((response) => {
|
||||
return axios.get(OC.generateUrl('apps/social/api/v1/stream/timeline?limit=5&since=' + sinceTimestamp)).then((response) => {
|
||||
if (response.status === -1) {
|
||||
throw response.message
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue