Notes -> Stream

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/524/head
Maxence Lange 2019-05-16 16:46:06 -01:00
rodzic 7d5ea91b58
commit d16537b403
17 zmienionych plików z 269 dodań i 283 usunięć

Wyświetl plik

@ -35,6 +35,7 @@ use DateInterval;
use DateTime; use DateTime;
use Doctrine\DBAL\Query\QueryBuilder; use Doctrine\DBAL\Query\QueryBuilder;
use Exception; use Exception;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Document; use OCA\Social\Model\ActivityPub\Object\Document;
@ -587,10 +588,15 @@ class CoreRequestBuilder {
* @param int $timestamp * @param int $timestamp
* @param string $field * @param string $field
* *
* @throws Exception * @throws DateTimeException
*/ */
protected function limitToSince(IQueryBuilder $qb, int $timestamp, string $field) { protected function limitToSince(IQueryBuilder $qb, int $timestamp, string $field) {
$dTime = new DateTime(); try {
$dTime = new DateTime();
} catch (Exception $e) {
throw new DateTimeException();
}
$dTime->setTimestamp($timestamp); $dTime->setTimestamp($timestamp);
$expr = $qb->expr(); $expr = $qb->expr();

Wyświetl plik

@ -34,7 +34,8 @@ use daita\MySmallPhpTools\Model\Cache;
use DateTime; use DateTime;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Exception; use Exception;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Note; use OCA\Social\Model\ActivityPub\Object\Note;
@ -44,11 +45,17 @@ use OCA\Social\Service\MiscService;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection; use OCP\IDBConnection;
class NotesRequest extends NotesRequestBuilder {
/**
* Class StreamRequest
*
* @package OCA\Social\Db
*/
class StreamRequest extends StreamRequestBuilder {
/** /**
* NotesRequest constructor. * StreamRequest constructor.
* *
* @param IDBConnection $connection * @param IDBConnection $connection
* @param ConfigService $configService * @param ConfigService $configService
@ -63,8 +70,6 @@ class NotesRequest extends NotesRequestBuilder {
/** /**
* @param Stream $stream * @param Stream $stream
*
* @throws Exception
*/ */
public function save(Stream $stream) { public function save(Stream $stream) {
$qb = $this->saveStream($stream); $qb = $this->saveStream($stream);
@ -85,51 +90,12 @@ class NotesRequest extends NotesRequestBuilder {
} }
//
//
// /**
// * Insert a new Note in the database.
// *
// * @param SocialAppNotification $notification
// *
// * @throws Exception
// */
// public function saveNotification(SocialAppNotification $notification) {
// $qb = $this->getNotesInsertSql();
// $qb->setValue('id', $qb->createNamedParameter($notification->getId()))
// ->setValue('type', $qb->createNamedParameter($notification->getType()))
// ->setValue('to', $qb->createNamedParameter($notification->getTo()))
// ->setValue('to_array', $qb->createNamedParameter(''))
// ->setValue('cc', $qb->createNamedParameter(''))
// ->setValue('bcc', $qb->createNamedParameter(''))
// ->setValue('content', $qb->createNamedParameter(''))
// ->setValue('summary', $qb->createNamedParameter($notification->getSummary()))
// ->setValue('published', $qb->createNamedParameter($notification->getPublished()))
// ->setValue(
// 'published_time',
// $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
// )
// ->setValue('attributed_to', $qb->createNamedParameter($notification->getAttributedTo()))
// ->setValue('in_reply_to', $qb->createNamedParameter(''))
// ->setValue('source', $qb->createNamedParameter($notification->getSource()))
// ->setValue('instances', $qb->createNamedParameter(''))
// ->setValue('local', $qb->createNamedParameter(($notification->isLocal()) ? '1' : '0'))
// ->setValue(
// 'creation',
// $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE)
// );
//
// $qb->execute();
// }
/** /**
* @param Stream $stream * @param Stream $stream
* @param Cache $cache * @param Cache $cache
*/ */
public function updateCache(Stream $stream, Cache $cache) { public function updateCache(Stream $stream, Cache $cache) {
$qb = $this->getNotesUpdateSql(); $qb = $this->getStreamUpdateSql();
$qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES))); $qb->set('cache', $qb->createNamedParameter(json_encode($cache, JSON_UNESCAPED_SLASHES)));
$this->limitToIdString($qb, $stream->getId()); $this->limitToIdString($qb, $stream->getId());
@ -146,14 +112,14 @@ class NotesRequest extends NotesRequestBuilder {
* @param bool $asViewer * @param bool $asViewer
* *
* @return Stream * @return Stream
* @throws NoteNotFoundException * @throws StreamNotFoundException
*/ */
public function getNoteById(string $id, bool $asViewer = false): Stream { public function getStreamById(string $id, bool $asViewer = false): Stream {
if ($id === '') { if ($id === '') {
throw new NoteNotFoundException(); throw new StreamNotFoundException();
}; };
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitToIdString($qb, $id); $this->limitToIdString($qb, $id);
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
@ -167,17 +133,16 @@ class NotesRequest extends NotesRequestBuilder {
$cursor->closeCursor(); $cursor->closeCursor();
if ($data === false) { if ($data === false) {
throw new NoteNotFoundException('Post not found'); throw new StreamNotFoundException('Stream not found');
} }
try { try {
/** @var Note $note */ $stream = $this->parseStreamSelectSql($data);
$note = $this->parseNotesSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
throw new NoteNotFoundException('Malformed Post'); throw new StreamNotFoundException('Malformed Stream');
} }
return $note; return $stream;
} }
@ -185,15 +150,15 @@ class NotesRequest extends NotesRequestBuilder {
* @param string $id * @param string $id
* *
* @return Stream * @return Stream
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws Exception * @throws Exception
*/ */
public function getNoteByActivityId(string $id): Stream { public function getStreamByActivityId(string $id): Stream {
if ($id === '') { if ($id === '') {
throw new NoteNotFoundException(); throw new StreamNotFoundException();
}; };
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitToActivityId($qb, $id); $this->limitToActivityId($qb, $id);
$cursor = $qb->execute(); $cursor = $qb->execute();
@ -201,10 +166,10 @@ class NotesRequest extends NotesRequestBuilder {
$cursor->closeCursor(); $cursor->closeCursor();
if ($data === false) { if ($data === false) {
throw new NoteNotFoundException('Post not found'); throw new StreamNotFoundException('Stream not found');
} }
return $this->parseNotesSelectSql($data); return $this->parseStreamSelectSql($data);
} }
@ -215,14 +180,14 @@ class NotesRequest extends NotesRequestBuilder {
* @param string $objectId * @param string $objectId
* *
* @return Stream * @return Stream
* @throws NoteNotFoundException * @throws StreamNotFoundException
*/ */
public function getNoteByObjectId(Person $actor, string $type, string $objectId): Stream { public function getStreamByObjectId(Person $actor, string $type, string $objectId): Stream {
if ($objectId === '') { if ($objectId === '') {
throw new NoteNotFoundException('missing objectId'); throw new StreamNotFoundException('missing objectId');
}; };
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitToObjectId($qb, $objectId); $this->limitToObjectId($qb, $objectId);
$this->limitToType($qb, $type); $this->limitToType($qb, $type);
$this->limitToAttributedTo($qb, $actor->getId()); $this->limitToAttributedTo($qb, $actor->getId());
@ -232,13 +197,13 @@ class NotesRequest extends NotesRequestBuilder {
$cursor->closeCursor(); $cursor->closeCursor();
if ($data === false) { if ($data === false) {
throw new NoteNotFoundException( throw new StreamNotFoundException(
'StreamByObjectId not found - ' . $actor->getId() . ' - ' . $type . ' - ' 'StreamByObjectId not found - ' . $actor->getId() . ' - ' . $type . ' - '
. $objectId . $objectId
); );
} }
return $this->parseNotesSelectSql($data); return $this->parseStreamSelectSql($data);
} }
@ -273,25 +238,24 @@ class NotesRequest extends NotesRequestBuilder {
* @throws Exception * @throws Exception
*/ */
public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->joinFollowing($qb, $actor); $this->joinFollowing($qb, $actor);
// $this->limitToType($qb, Note::TYPE);
$this->limitPaginate($qb, $since, $limit); $this->limitPaginate($qb, $since, $limit);
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb); $this->leftJoinStreamAction($qb);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
try { try {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -311,24 +275,24 @@ class NotesRequest extends NotesRequestBuilder {
* @throws Exception * @throws Exception
*/ */
public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit); $this->limitPaginate($qb, $since, $limit);
$this->limitToRecipient($qb, $actor->getId(), false); $this->limitToRecipient($qb, $actor->getId(), false);
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb); $this->leftJoinStreamAction($qb);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
try { try {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -345,26 +309,25 @@ class NotesRequest extends NotesRequestBuilder {
* @throws Exception * @throws Exception
*/ */
public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array { public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit); $this->limitPaginate($qb, $since, $limit);
// $this->limitToType($qb, Note::TYPE);
$this->limitToAttributedTo($qb, $actorId); $this->limitToAttributedTo($qb, $actorId);
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC); $this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC);
$this->leftJoinStreamAction($qb); $this->leftJoinStreamAction($qb);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
try { try {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -381,27 +344,26 @@ class NotesRequest extends NotesRequestBuilder {
* @throws Exception * @throws Exception
*/ */
public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit); $this->limitPaginate($qb, $since, $limit);
// $this->limitToType($qb, Note::TYPE);
$this->limitToRecipient($qb, $actor->getId(), true); $this->limitToRecipient($qb, $actor->getId(), true);
$this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC); $this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC);
$this->filterToRecipient($qb, $actor->getFollowers()); $this->filterToRecipient($qb, $actor->getFollowers());
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
try { try {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -418,9 +380,8 @@ class NotesRequest extends NotesRequestBuilder {
*/ */
public function getStreamTimeline(int $since = 0, int $limit = 5, bool $localOnly = true public function getStreamTimeline(int $since = 0, int $limit = 5, bool $localOnly = true
): array { ): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitPaginate($qb, $since, $limit); $this->limitPaginate($qb, $since, $limit);
// $this->limitToType($qb, Note::TYPE);
if ($localOnly) { if ($localOnly) {
$this->limitToLocal($qb, true); $this->limitToLocal($qb, true);
@ -432,17 +393,17 @@ class NotesRequest extends NotesRequestBuilder {
// TODO: to: = real public, cc: = unlisted !? // TODO: to: = real public, cc: = unlisted !?
$this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']); $this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
try { try {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} catch (Exception $e) { } catch (Exception $e) {
} }
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -462,7 +423,7 @@ class NotesRequest extends NotesRequestBuilder {
*/ */
public function getStreamTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5 public function getStreamTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5
): array { ): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$on = $this->exprJoinFollowing($qb, $actor); $on = $this->exprJoinFollowing($qb, $actor);
$on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false)); $on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false));
@ -475,36 +436,37 @@ class NotesRequest extends NotesRequestBuilder {
$this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinCacheActors($qb, 'attributed_to');
$this->leftJoinStreamAction($qb); $this->leftJoinStreamAction($qb);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
/** /**
* @param int $since * @param int $since
* *
* @return Note[] * @return Stream[]
* @throws Exception * @throws DateTimeException
*/ */
public function getNotesSince(int $since): array { public function getNoteSince(int $since): array {
$qb = $this->getNotesSelectSql(); $qb = $this->getStreamSelectSql();
$this->limitToSince($qb, $since, 'published_time'); $this->limitToSince($qb, $since, 'published_time');
$this->limitToType($qb, Note::TYPE);
$this->leftJoinStreamAction($qb); $this->leftJoinStreamAction($qb);
$notes = []; $streams = [];
$cursor = $qb->execute(); $cursor = $qb->execute();
while ($data = $cursor->fetch()) { while ($data = $cursor->fetch()) {
$notes[] = $this->parseNotesSelectSql($data); $streams[] = $this->parseStreamSelectSql($data);
} }
$cursor->closeCursor(); $cursor->closeCursor();
return $notes; return $streams;
} }
@ -512,8 +474,8 @@ class NotesRequest extends NotesRequestBuilder {
* @param string $id * @param string $id
* @param string $type * @param string $type
*/ */
public function deleteNoteById(string $id, string $type = '') { public function deleteStreamById(string $id, string $type = '') {
$qb = $this->getNotesDeleteSql(); $qb = $this->getStreamDeleteSql();
$this->limitToIdString($qb, $id); $this->limitToIdString($qb, $id);
if ($type !== '') { if ($type !== '') {
@ -528,7 +490,7 @@ class NotesRequest extends NotesRequestBuilder {
* @param string $actorId * @param string $actorId
*/ */
public function deleteByAuthor(string $actorId) { public function deleteByAuthor(string $actorId) {
$qb = $this->getNotesDeleteSql(); $qb = $this->getStreamDeleteSql();
$this->limitToAttributedTo($qb, $actorId); $this->limitToAttributedTo($qb, $actorId);
$qb->execute(); $qb->execute();
@ -536,68 +498,69 @@ class NotesRequest extends NotesRequestBuilder {
/** /**
* Insert a new Note in the database. * Insert a new Stream in the database.
* *
* @param Stream $note * @param Stream $stream
* *
* @return IQueryBuilder * @return IQueryBuilder
*/ */
public function saveStream(Stream $note): IQueryBuilder { public function saveStream(Stream $stream): IQueryBuilder {
try { try {
$dTime = new DateTime(); $dTime = new DateTime();
$dTime->setTimestamp($note->getPublishedTime()); $dTime->setTimestamp($stream->getPublishedTime());
} catch (Exception $e) { } catch (Exception $e) {
} }
$cache = '[]'; $cache = '[]';
if ($note->gotCache()) { if ($stream->gotCache()) {
$cache = json_encode($note->getCache(), JSON_UNESCAPED_SLASHES); $cache = json_encode($stream->getCache(), JSON_UNESCAPED_SLASHES);
} }
$attributedTo = $note->getAttributedTo(); $attributedTo = $stream->getAttributedTo();
if ($attributedTo === '' && $note->isLocal()) { if ($attributedTo === '' && $stream->isLocal()) {
$attributedTo = $note->getActor() $attributedTo = $stream->getActor()
->getId(); ->getId();
} }
$qb = $this->getNotesInsertSql(); $qb = $this->getStreamInsertSql();
$qb->setValue('id', $qb->createNamedParameter($note->getId())) $qb->setValue('id', $qb->createNamedParameter($stream->getId()))
->setValue('type', $qb->createNamedParameter($note->getType())) ->setValue('type', $qb->createNamedParameter($stream->getType()))
->setValue('to', $qb->createNamedParameter($note->getTo())) ->setValue('to', $qb->createNamedParameter($stream->getTo()))
->setValue( ->setValue(
'to_array', $qb->createNamedParameter( 'to_array', $qb->createNamedParameter(
json_encode($note->getToArray(), JSON_UNESCAPED_SLASHES) json_encode($stream->getToArray(), JSON_UNESCAPED_SLASHES)
) )
) )
->setValue( ->setValue(
'cc', $qb->createNamedParameter( 'cc', $qb->createNamedParameter(
json_encode($note->getCcArray(), JSON_UNESCAPED_SLASHES) json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES)
) )
) )
->setValue( ->setValue(
'bcc', $qb->createNamedParameter( 'bcc', $qb->createNamedParameter(
json_encode($note->getBccArray()), JSON_UNESCAPED_SLASHES json_encode($stream->getBccArray()), JSON_UNESCAPED_SLASHES
) )
) )
->setValue('content', $qb->createNamedParameter($note->getContent())) ->setValue('content', $qb->createNamedParameter($stream->getContent()))
->setValue('summary', $qb->createNamedParameter($note->getSummary())) ->setValue('summary', $qb->createNamedParameter($stream->getSummary()))
->setValue('published', $qb->createNamedParameter($note->getPublished())) ->setValue('published', $qb->createNamedParameter($stream->getPublished()))
->setValue('attributed_to', $qb->createNamedParameter($attributedTo)) ->setValue('attributed_to', $qb->createNamedParameter($attributedTo))
->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo())) ->setValue('in_reply_to', $qb->createNamedParameter($stream->getInReplyTo()))
->setValue('source', $qb->createNamedParameter($note->getSource())) ->setValue('source', $qb->createNamedParameter($stream->getSource()))
->setValue('object_id', $qb->createNamedParameter($note->getObjectId())) ->setValue('activity_id', $qb->createNamedParameter($stream->getActivityId()))
->setValue('object_id', $qb->createNamedParameter($stream->getObjectId()))
->setValue('cache', $qb->createNamedParameter($cache)) ->setValue('cache', $qb->createNamedParameter($cache))
->setValue( ->setValue(
'instances', $qb->createNamedParameter( 'instances', $qb->createNamedParameter(
json_encode($note->getInstancePaths(), JSON_UNESCAPED_SLASHES) json_encode($stream->getInstancePaths(), JSON_UNESCAPED_SLASHES)
) )
) )
->setValue('local', $qb->createNamedParameter(($note->isLocal()) ? '1' : '0')); ->setValue('local', $qb->createNamedParameter(($stream->isLocal()) ? '1' : '0'));
try { try {
$dTime = new DateTime(); $dTime = new DateTime();
$dTime->setTimestamp($note->getPublishedTime()); $dTime->setTimestamp($stream->getPublishedTime());
$qb->setValue( $qb->setValue(
'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE) 'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE)
) )
@ -608,7 +571,7 @@ class NotesRequest extends NotesRequestBuilder {
} catch (Exception $e) { } catch (Exception $e) {
} }
$this->generatePrimaryKey($qb, $note->getId()); $this->generatePrimaryKey($qb, $stream->getId());
return $qb; return $qb;
} }

Wyświetl plik

@ -35,6 +35,7 @@ use Doctrine\DBAL\Query\QueryBuilder;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Model\ActivityPub\Stream; use OCA\Social\Model\ActivityPub\Stream;
use OCA\Social\Model\InstancePath; use OCA\Social\Model\InstancePath;
use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\DB\QueryBuilder\ICompositeExpression;
@ -42,11 +43,11 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
/** /**
* Class NotesRequestBuilder * Class StreamRequestBuilder
* *
* @package OCA\Social\Db * @package OCA\Social\Db
*/ */
class NotesRequestBuilder extends CoreRequestBuilder { class StreamRequestBuilder extends CoreRequestBuilder {
use TArrayTools; use TArrayTools;
@ -57,7 +58,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
* *
* @return IQueryBuilder * @return IQueryBuilder
*/ */
protected function getNotesInsertSql(): IQueryBuilder { protected function getStreamInsertSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->insert(self::TABLE_STREAMS); $qb->insert(self::TABLE_STREAMS);
@ -70,7 +71,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
* *
* @return IQueryBuilder * @return IQueryBuilder
*/ */
protected function getNotesUpdateSql(): IQueryBuilder { protected function getStreamUpdateSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->update(self::TABLE_STREAMS); $qb->update(self::TABLE_STREAMS);
@ -83,21 +84,21 @@ class NotesRequestBuilder extends CoreRequestBuilder {
* *
* @return IQueryBuilder * @return IQueryBuilder
*/ */
protected function getNotesSelectSql(): IQueryBuilder { protected function getStreamSelectSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
/** @noinspection PhpMethodParametersCountMismatchInspection */ /** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->selectDistinct('sn.id') $qb->selectDistinct('s.id')
->addSelect( ->addSelect(
'sn.type', 'sn.to', 'sn.to_array', 'sn.cc', 'sn.bcc', 'sn.content', 's.type', 's.to', 's.to_array', 's.cc', 's.bcc', 's.content',
'sn.summary', 'sn.attachments', 'sn.published', 'sn.published_time', 'sn.cache', 's.summary', 's.attachments', 's.published', 's.published_time', 's.cache',
'sn.object_id', 's.object_id',
'sn.attributed_to', 'sn.in_reply_to', 'sn.source', 'sn.local', 'sn.instances', 's.attributed_to', 's.in_reply_to', 's.source', 's.local', 's.instances',
'sn.creation' 's.creation'
) )
->from(self::TABLE_STREAMS, 'sn'); ->from(self::TABLE_STREAMS, 's');
$this->defaultSelectAlias = 'sn'; $this->defaultSelectAlias = 's';
return $qb; return $qb;
} }
@ -111,9 +112,11 @@ class NotesRequestBuilder extends CoreRequestBuilder {
protected function countNotesSelectSql(): IQueryBuilder { protected function countNotesSelectSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->selectAlias($qb->createFunction('COUNT(*)'), 'count') $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
->from(self::TABLE_STREAMS, 'sn'); ->from(self::TABLE_STREAMS, 's');
$this->defaultSelectAlias = 'sn'; $this->limitToType($qb, Note::TYPE);
$this->defaultSelectAlias = 's';
return $qb; return $qb;
} }
@ -124,7 +127,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
* *
* @return IQueryBuilder * @return IQueryBuilder
*/ */
protected function getNotesDeleteSql(): IQueryBuilder { protected function getStreamDeleteSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder(); $qb = $this->dbConnection->getQueryBuilder();
$qb->delete(self::TABLE_STREAMS); $qb->delete(self::TABLE_STREAMS);
@ -155,7 +158,6 @@ class NotesRequestBuilder extends CoreRequestBuilder {
} }
$on = $this->exprJoinFollowing($qb, $actor); $on = $this->exprJoinFollowing($qb, $actor);
$qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on); $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on);
} }
@ -163,7 +165,6 @@ class NotesRequestBuilder extends CoreRequestBuilder {
/** /**
* @param IQueryBuilder $qb * @param IQueryBuilder $qb
* @param Person $actor * @param Person $actor
*
* @param bool $followers * @param bool $followers
* *
* @return ICompositeExpression * @return ICompositeExpression
@ -362,7 +363,7 @@ class NotesRequestBuilder extends CoreRequestBuilder {
* *
* @return Stream * @return Stream
*/ */
protected function parseNotesSelectSql($data): Stream { protected function parseStreamSelectSql($data): Stream {
$item = new Stream(); $item = new Stream();
$item->importFromDatabase($data); $item->importFromDatabase($data);

Wyświetl plik

@ -0,0 +1,10 @@
<?php
namespace OCA\Social\Exceptions;
use Exception;
class DateTimeException extends Exception {
}

Wyświetl plik

@ -1,8 +0,0 @@
<?php
namespace OCA\Social\Exceptions;
class NoteNotFoundException extends \Exception {
}

Wyświetl plik

@ -0,0 +1,8 @@
<?php
namespace OCA\Social\Exceptions;
class StreamNotFoundException extends \Exception {
}

Wyświetl plik

@ -33,7 +33,7 @@ namespace OCA\Social\Interfaces\Actor;
use daita\MySmallPhpTools\Traits\TArrayTools; use daita\MySmallPhpTools\Traits\TArrayTools;
use OCA\Social\Db\CacheActorsRequest; use OCA\Social\Db\CacheActorsRequest;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\CacheActorDoesNotExistException; use OCA\Social\Exceptions\CacheActorDoesNotExistException;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\ItemNotFoundException; use OCA\Social\Exceptions\ItemNotFoundException;
@ -60,8 +60,8 @@ class PersonInterface implements IActivityPubInterface {
/** @var CacheActorsRequest */ /** @var CacheActorsRequest */
private $cacheActorsRequest; private $cacheActorsRequest;
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var ActorService */ /** @var ActorService */
private $actorService; private $actorService;
@ -77,17 +77,17 @@ class PersonInterface implements IActivityPubInterface {
* UndoService constructor. * UndoService constructor.
* *
* @param CacheActorsRequest $cacheActorsRequest * @param CacheActorsRequest $cacheActorsRequest
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param ActorService $actorService * @param ActorService $actorService
* @param ConfigService $configService * @param ConfigService $configService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
CacheActorsRequest $cacheActorsRequest, NotesRequest $notesRequest, CacheActorsRequest $cacheActorsRequest, StreamRequest $streamRequest,
ActorService $actorService, ConfigService $configService, MiscService $miscService ActorService $actorService, ConfigService $configService, MiscService $miscService
) { ) {
$this->cacheActorsRequest = $cacheActorsRequest; $this->cacheActorsRequest = $cacheActorsRequest;
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->actorService = $actorService; $this->actorService = $actorService;
$this->configService = $configService; $this->configService = $configService;
$this->miscService = $miscService; $this->miscService = $miscService;
@ -161,7 +161,7 @@ class PersonInterface implements IActivityPubInterface {
public function delete(ACore $item) { public function delete(ACore $item) {
/** @var Person $item */ /** @var Person $item */
$this->cacheActorsRequest->deleteFromId($item->getId()); $this->cacheActorsRequest->deleteFromId($item->getId());
$this->notesRequest->deleteByAuthor($item->getId()); $this->streamRequest->deleteByAuthor($item->getId());
} }

Wyświetl plik

@ -31,7 +31,7 @@ declare(strict_types=1);
namespace OCA\Social\Interfaces\Internal; namespace OCA\Social\Interfaces\Internal;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\ItemNotFoundException; use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Interfaces\IActivityPubInterface; use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
@ -44,8 +44,8 @@ use OCA\Social\Service\MiscService;
class SocialAppNotificationInterface implements IActivityPubInterface { class SocialAppNotificationInterface implements IActivityPubInterface {
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var CurlService */ /** @var CurlService */
private $curlService; private $curlService;
@ -60,16 +60,16 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
/** /**
* NoteInterface constructor. * NoteInterface constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param CurlService $curlService * @param CurlService $curlService
* @param ConfigService $configService * @param ConfigService $configService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, CurlService $curlService, ConfigService $configService, StreamRequest $streamRequest, CurlService $curlService, ConfigService $configService,
MiscService $miscService MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->curlService = $curlService; $this->curlService = $curlService;
$this->configService = $configService; $this->configService = $configService;
$this->miscService = $miscService; $this->miscService = $miscService;
@ -111,7 +111,7 @@ class SocialAppNotificationInterface implements IActivityPubInterface {
} }
$this->miscService->log('Generating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1); $this->miscService->log('Generating notification: ' . json_encode($notification, JSON_UNESCAPED_SLASHES), 1);
$this->notesRequest->save($notification); $this->streamRequest->save($notification);
} }

Wyświetl plik

@ -32,10 +32,10 @@ namespace OCA\Social\Interfaces\Object;
use Exception; use Exception;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\ItemNotFoundException; use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Interfaces\IActivityPubInterface; use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Activity\Undo; use OCA\Social\Model\ActivityPub\Activity\Undo;
@ -54,8 +54,8 @@ use OCA\Social\Service\StreamQueueService;
class AnnounceInterface implements IActivityPubInterface { class AnnounceInterface implements IActivityPubInterface {
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var StreamQueueService */ /** @var StreamQueueService */
private $streamQueueService; private $streamQueueService;
@ -67,14 +67,15 @@ class AnnounceInterface implements IActivityPubInterface {
/** /**
* AnnounceInterface constructor. * AnnounceInterface constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param StreamQueueService $streamQueueService * @param StreamQueueService $streamQueueService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, StreamQueueService $streamQueueService, MiscService $miscService StreamRequest $streamRequest, StreamQueueService $streamQueueService,
MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->streamQueueService = $streamQueueService; $this->streamQueueService = $streamQueueService;
$this->miscService = $miscService; $this->miscService = $miscService;
} }
@ -136,11 +137,11 @@ class AnnounceInterface implements IActivityPubInterface {
public function save(ACore $item) { public function save(ACore $item) {
/** @var Announce $item */ /** @var Announce $item */
try { try {
$this->notesRequest->getNoteById($item->getId()); $this->streamRequest->getStreamById($item->getId());
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
$objectId = $item->getObjectId(); $objectId = $item->getObjectId();
$item->addCacheItem($objectId); $item->addCacheItem($objectId);
$this->notesRequest->save($item); $this->streamRequest->save($item);
$this->streamQueueService->generateStreamQueue( $this->streamQueueService->generateStreamQueue(
$item->getRequestToken(), StreamQueue::TYPE_CACHE, $item->getId() $item->getRequestToken(), StreamQueue::TYPE_CACHE, $item->getId()
@ -153,13 +154,7 @@ class AnnounceInterface implements IActivityPubInterface {
* @param ACore $item * @param ACore $item
*/ */
public function delete(ACore $item) { public function delete(ACore $item) {
try { $this->streamRequest->deleteStreamById($item->getId(), Announce::TYPE);
// $stream = $this->notesRequest->getNoteById($item->getId());
// if ($stream->getType() === Announce::TYPE) {
$this->notesRequest->deleteNoteById($item->getId(), Announce::TYPE);
// }
} catch (NoteNotFoundException $e) {
}
} }
} }

Wyświetl plik

@ -31,10 +31,10 @@ declare(strict_types=1);
namespace OCA\Social\Interfaces\Object; namespace OCA\Social\Interfaces\Object;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\ItemNotFoundException; use OCA\Social\Exceptions\ItemNotFoundException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Interfaces\IActivityPubInterface; use OCA\Social\Interfaces\IActivityPubInterface;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Activity\Create; use OCA\Social\Model\ActivityPub\Activity\Create;
@ -47,8 +47,8 @@ use OCA\Social\Service\MiscService;
class NoteInterface implements IActivityPubInterface { class NoteInterface implements IActivityPubInterface {
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var CurlService */ /** @var CurlService */
private $curlService; private $curlService;
@ -63,16 +63,16 @@ class NoteInterface implements IActivityPubInterface {
/** /**
* NoteInterface constructor. * NoteInterface constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param CurlService $curlService * @param CurlService $curlService
* @param ConfigService $configService * @param ConfigService $configService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, CurlService $curlService, ConfigService $configService, StreamRequest $streamRequest, CurlService $curlService, ConfigService $configService,
MiscService $miscService MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->curlService = $curlService; $this->curlService = $curlService;
$this->configService = $configService; $this->configService = $configService;
$this->miscService = $miscService; $this->miscService = $miscService;
@ -101,8 +101,8 @@ class NoteInterface implements IActivityPubInterface {
*/ */
public function getItemById(string $id): ACore { public function getItemById(string $id): ACore {
try { try {
return $this->notesRequest->getNoteById($id); return $this->streamRequest->getStreamById($id);
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
throw new ItemNotFoundException(); throw new ItemNotFoundException();
} }
} }
@ -115,9 +115,9 @@ class NoteInterface implements IActivityPubInterface {
/** @var Note $note */ /** @var Note $note */
try { try {
$this->notesRequest->getNoteById($note->getId()); $this->streamRequest->getStreamById($note->getId());
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
$this->notesRequest->save($note); $this->streamRequest->save($note);
} }
} }
@ -149,7 +149,7 @@ class NoteInterface implements IActivityPubInterface {
$item->checkOrigin(($item->getId())); $item->checkOrigin(($item->getId()));
/** @var Note $item */ /** @var Note $item */
$this->notesRequest->deleteNoteById($item->getId(), Note::TYPE); $this->streamRequest->deleteStreamById($item->getId(), Note::TYPE);
} }

Wyświetl plik

@ -35,7 +35,7 @@ use Exception;
use OC\User\NoUserException; use OC\User\NoUserException;
use OCA\Social\Db\ActorsRequest; use OCA\Social\Db\ActorsRequest;
use OCA\Social\Db\FollowsRequest; use OCA\Social\Db\FollowsRequest;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\AccountAlreadyExistsException; use OCA\Social\Exceptions\AccountAlreadyExistsException;
use OCA\Social\Exceptions\ActorDoesNotExistException; use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\ItemUnknownException;
@ -72,8 +72,8 @@ class AccountService {
/** @var FollowsRequest */ /** @var FollowsRequest */
private $followsRequest; private $followsRequest;
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var ActorService */ /** @var ActorService */
private $actorService; private $actorService;
@ -98,7 +98,7 @@ class AccountService {
* @param IAccountManager $accountManager * @param IAccountManager $accountManager
* @param ActorsRequest $actorsRequest * @param ActorsRequest $actorsRequest
* @param FollowsRequest $followsRequest * @param FollowsRequest $followsRequest
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param ActorService $actorService * @param ActorService $actorService
* @param DocumentService $documentService * @param DocumentService $documentService
* @param SignatureService $signatureService * @param SignatureService $signatureService
@ -107,7 +107,7 @@ class AccountService {
*/ */
public function __construct( public function __construct(
IUserManager $userManager, IAccountManager $accountManager, ActorsRequest $actorsRequest, IUserManager $userManager, IAccountManager $accountManager, ActorsRequest $actorsRequest,
FollowsRequest $followsRequest, NotesRequest $notesRequest, ActorService $actorService, FollowsRequest $followsRequest, StreamRequest $streamRequest, ActorService $actorService,
DocumentService $documentService, SignatureService $signatureService, DocumentService $documentService, SignatureService $signatureService,
ConfigService $configService, MiscService $miscService ConfigService $configService, MiscService $miscService
) { ) {
@ -115,7 +115,7 @@ class AccountService {
$this->accountManager = $accountManager; $this->accountManager = $accountManager;
$this->actorsRequest = $actorsRequest; $this->actorsRequest = $actorsRequest;
$this->followsRequest = $followsRequest; $this->followsRequest = $followsRequest;
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->actorService = $actorService; $this->actorService = $actorService;
$this->documentService = $documentService; $this->documentService = $documentService;
$this->signatureService = $signatureService; $this->signatureService = $signatureService;
@ -280,7 +280,7 @@ class AccountService {
$count = [ $count = [
'followers' => $this->followsRequest->countFollowers($actor->getId()), 'followers' => $this->followsRequest->countFollowers($actor->getId()),
'following' => $this->followsRequest->countFollowing($actor->getId()), 'following' => $this->followsRequest->countFollowing($actor->getId()),
'post' => $this->notesRequest->countNotesFromActorId($actor->getId()) 'post' => $this->streamRequest->countNotesFromActorId($actor->getId())
]; ];
$actor->addDetailArray('count', $count); $actor->addDetailArray('count', $count);
} }

Wyświetl plik

@ -33,10 +33,9 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Model\Request; use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools; use daita\MySmallPhpTools\Traits\TArrayTools;
use Exception; use Exception;
use OCA\ShareByMail\Activity;
use OCA\Social\AP; use OCA\Social\AP;
use OCA\Social\Db\FollowsRequest; use OCA\Social\Db\FollowsRequest;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\ActorDoesNotExistException; use OCA\Social\Exceptions\ActorDoesNotExistException;
use OCA\Social\Exceptions\EmptyQueueException; use OCA\Social\Exceptions\EmptyQueueException;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
@ -53,11 +52,16 @@ use OCA\Social\Model\ActivityPub\ACore;
use OCA\Social\Model\ActivityPub\Activity\Create; use OCA\Social\Model\ActivityPub\Activity\Create;
use OCA\Social\Model\ActivityPub\Activity\Delete; use OCA\Social\Model\ActivityPub\Activity\Delete;
use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\ActivityPub\Actor\Person;
use OCA\Social\Model\ActivityPub\Object\Announce;
use OCA\Social\Model\ActivityPub\Object\Tombstone; use OCA\Social\Model\ActivityPub\Object\Tombstone;
use OCA\Social\Model\InstancePath; use OCA\Social\Model\InstancePath;
use OCA\Social\Model\RequestQueue; use OCA\Social\Model\RequestQueue;
/**
* Class ActivityService
*
* @package OCA\Social\Service
*/
class ActivityService { class ActivityService {
@ -69,8 +73,8 @@ class ActivityService {
const TIMEOUT_SERVICE = 30; const TIMEOUT_SERVICE = 30;
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var FollowsRequest */ /** @var FollowsRequest */
private $followsRequest; private $followsRequest;
@ -101,7 +105,7 @@ class ActivityService {
/** /**
* ActivityService constructor. * ActivityService constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param FollowsRequest $followsRequest * @param FollowsRequest $followsRequest
* @param SignatureService $signatureService * @param SignatureService $signatureService
* @param RequestQueueService $requestQueueService * @param RequestQueueService $requestQueueService
@ -111,12 +115,12 @@ class ActivityService {
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, FollowsRequest $followsRequest, StreamRequest $streamRequest, FollowsRequest $followsRequest,
SignatureService $signatureService, RequestQueueService $requestQueueService, SignatureService $signatureService, RequestQueueService $requestQueueService,
AccountService $accountService, CurlService $curlService, ConfigService $configService, AccountService $accountService, CurlService $curlService, ConfigService $configService,
MiscService $miscService MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->followsRequest = $followsRequest; $this->followsRequest = $followsRequest;
$this->requestQueueService = $requestQueueService; $this->requestQueueService = $requestQueueService;
$this->accountService = $accountService; $this->accountService = $accountService;

Wyświetl plik

@ -33,9 +33,9 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Traits\TStringTools; use daita\MySmallPhpTools\Traits\TStringTools;
use Exception; use Exception;
use OCA\Social\AP; use OCA\Social\AP;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\RedundancyLimitException; use OCA\Social\Exceptions\RedundancyLimitException;
use OCA\Social\Exceptions\SocialAppConfigException; use OCA\Social\Exceptions\SocialAppConfigException;
use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\ACore;
@ -56,8 +56,8 @@ class BoostService {
use TStringTools; use TStringTools;
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var NoteService */ /** @var NoteService */
private $noteService; private $noteService;
@ -81,7 +81,7 @@ class BoostService {
/** /**
* BoostService constructor. * BoostService constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param NoteService $noteService * @param NoteService $noteService
* @param SignatureService $signatureService * @param SignatureService $signatureService
* @param ActivityService $activityService * @param ActivityService $activityService
@ -90,11 +90,11 @@ class BoostService {
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, NoteService $noteService, SignatureService $signatureService, StreamRequest $streamRequest, NoteService $noteService, SignatureService $signatureService,
ActivityService $activityService, StreamActionService $streamActionService, ActivityService $activityService, StreamActionService $streamActionService,
StreamQueueService $streamQueueService, MiscService $miscService StreamQueueService $streamQueueService, MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->noteService = $noteService; $this->noteService = $noteService;
$this->signatureService = $signatureService; $this->signatureService = $signatureService;
$this->activityService = $activityService; $this->activityService = $activityService;
@ -110,7 +110,7 @@ class BoostService {
* @param string $token * @param string $token
* *
* @return ACore * @return ACore
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws SocialAppConfigException * @throws SocialAppConfigException
* @throws Exception * @throws Exception
*/ */
@ -118,7 +118,7 @@ class BoostService {
try { try {
return $this->get($actor, $postId); return $this->get($actor, $postId);
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
} }
$announce = new Announce(); $announce = new Announce();
@ -127,7 +127,7 @@ class BoostService {
$note = $this->noteService->getNoteById($postId, true); $note = $this->noteService->getNoteById($postId, true);
if ($note->getType() !== Note::TYPE) { if ($note->getType() !== Note::TYPE) {
throw new NoteNotFoundException('Stream is not a Note'); throw new StreamNotFoundException('Stream is not a Note');
} }
$announce->addCc($note->getAttributedTo()); $announce->addCc($note->getAttributedTo());
@ -153,13 +153,13 @@ class BoostService {
* @param string $postId * @param string $postId
* *
* @return Stream * @return Stream
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws SocialAppConfigException * @throws SocialAppConfigException
* @throws ItemUnknownException * @throws ItemUnknownException
* @throws RedundancyLimitException * @throws RedundancyLimitException
*/ */
public function get(Person $actor, string $postId): Stream { public function get(Person $actor, string $postId): Stream {
$stream = $this->notesRequest->getNoteByObjectId($actor, Announce::TYPE, $postId); $stream = $this->streamRequest->getStreamByObjectId($actor, Announce::TYPE, $postId);
return $stream; return $stream;
} }
@ -171,7 +171,7 @@ class BoostService {
* @param string $token * @param string $token
* *
* @return ACore * @return ACore
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws SocialAppConfigException * @throws SocialAppConfigException
*/ */
public function delete(Person $actor, string $postId, &$token = ''): ACore { public function delete(Person $actor, string $postId, &$token = ''): ACore {
@ -181,15 +181,15 @@ class BoostService {
$note = $this->noteService->getNoteById($postId, true); $note = $this->noteService->getNoteById($postId, true);
if ($note->getType() !== Note::TYPE) { if ($note->getType() !== Note::TYPE) {
throw new NoteNotFoundException('Stream is not a Note'); throw new StreamNotFoundException('Stream is not a Note');
} }
$announce = $this->notesRequest->getNoteByObjectId($actor, Announce::TYPE, $postId); $announce = $this->streamRequest->getStreamByObjectId($actor, Announce::TYPE, $postId);
$undo->setObject($announce); $undo->setObject($announce);
$undo->setCcArray($announce->getCcArray()); $undo->setCcArray($announce->getCcArray());
$this->notesRequest->deleteNoteById($announce->getId(), Announce::TYPE); $this->streamRequest->deleteStreamById($announce->getId(), Announce::TYPE);
$this->streamActionService->setActionBool($actor->getId(), $postId, 'boosted', false); $this->streamActionService->setActionBool($actor->getId(), $postId, 'boosted', false);
$this->signatureService->signObject($actor, $undo); $this->signatureService->signObject($actor, $undo);

Wyświetl plik

@ -33,8 +33,11 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Traits\TArrayTools; use daita\MySmallPhpTools\Traits\TArrayTools;
use OCA\Social\Db\HashtagsRequest; use OCA\Social\Db\HashtagsRequest;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\DateTimeException;
use OCA\Social\Exceptions\HashtagDoesNotExistException; use OCA\Social\Exceptions\HashtagDoesNotExistException;
use OCA\Social\Model\ActivityPub\Object\Note;
use OCA\Social\Model\ActivityPub\Stream;
class HashtagService { class HashtagService {
@ -53,8 +56,8 @@ class HashtagService {
/** @var HashtagsRequest */ /** @var HashtagsRequest */
private $hashtagsRequest; private $hashtagsRequest;
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var ConfigService */ /** @var ConfigService */
private $configService; private $configService;
@ -67,16 +70,17 @@ class HashtagService {
* ImportService constructor. * ImportService constructor.
* *
* @param HashtagsRequest $hashtagsRequest * @param HashtagsRequest $hashtagsRequest
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param ConfigService $configService * @param ConfigService $configService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
HashtagsRequest $hashtagsRequest, NotesRequest $notesRequest, ConfigService $configService, HashtagsRequest $hashtagsRequest, StreamRequest $streamRequest,
ConfigService $configService,
MiscService $miscService MiscService $miscService
) { ) {
$this->hashtagsRequest = $hashtagsRequest; $this->hashtagsRequest = $hashtagsRequest;
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->configService = $configService; $this->configService = $configService;
$this->miscService = $miscService; $this->miscService = $miscService;
} }
@ -92,8 +96,10 @@ class HashtagService {
* ] * ]
*/ */
/** /**
* * @return int
* @throws DateTimeException
*/ */
public function manageHashtags(): int { public function manageHashtags(): int {
$current = $this->hashtagsRequest->getAll(); $current = $this->hashtagsRequest->getAll();
@ -151,14 +157,15 @@ class HashtagService {
/** /**
* @param int $timestamp * @param int $timestamp
* *
* @return array * @return Stream[]
* @throws DateTimeException
*/ */
private function getTrendSince(int $timestamp): array { private function getTrendSince(int $timestamp): array {
$result = []; $result = [];
$notes = $this->notesRequest->getNotesSince($timestamp); $notes = $this->streamRequest->getNoteSince($timestamp);
foreach ($notes as $note) { foreach ($notes as $note) {
/** @var Note $note */
foreach ($note->getHashtags() as $hashtag) { foreach ($note->getHashtags() as $hashtag) {
if (array_key_exists($hashtag, $result)) { if (array_key_exists($hashtag, $result)) {
$result[$hashtag]++; $result[$hashtag]++;

Wyświetl plik

@ -32,11 +32,11 @@ namespace OCA\Social\Service;
use daita\MySmallPhpTools\Exceptions\MalformedArrayException; use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
use Exception; use Exception;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\RedundancyLimitException; use OCA\Social\Exceptions\RedundancyLimitException;
use OCA\Social\Exceptions\RequestContentException; use OCA\Social\Exceptions\RequestContentException;
use OCA\Social\Exceptions\RequestNetworkException; use OCA\Social\Exceptions\RequestNetworkException;
@ -53,8 +53,8 @@ use OCA\Social\Model\InstancePath;
class NoteService { class NoteService {
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var ActivityService */ /** @var ActivityService */
private $activityService; private $activityService;
@ -85,7 +85,7 @@ class NoteService {
/** /**
* NoteService constructor. * NoteService constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param ActivityService $activityService * @param ActivityService $activityService
* @param AccountService $accountService * @param AccountService $accountService
* @param SignatureService $signatureService * @param SignatureService $signatureService
@ -95,12 +95,12 @@ class NoteService {
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, ActivityService $activityService, StreamRequest $streamRequest, ActivityService $activityService,
AccountService $accountService, SignatureService $signatureService, AccountService $accountService, SignatureService $signatureService,
StreamQueueService $streamQueueService, CacheActorService $cacheActorService, StreamQueueService $streamQueueService, CacheActorService $cacheActorService,
ConfigService $configService, MiscService $miscService ConfigService $configService, MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->activityService = $activityService; $this->activityService = $activityService;
$this->accountService = $accountService; $this->accountService = $accountService;
$this->signatureService = $signatureService; $this->signatureService = $signatureService;
@ -116,7 +116,7 @@ class NoteService {
*/ */
public function setViewer(Person $viewer) { public function setViewer(Person $viewer) {
$this->viewer = $viewer; $this->viewer = $viewer;
$this->notesRequest->setViewer($viewer); $this->streamRequest->setViewer($viewer);
} }
@ -285,7 +285,7 @@ class NoteService {
* @throws InvalidOriginException * @throws InvalidOriginException
* @throws InvalidResourceException * @throws InvalidResourceException
* @throws MalformedArrayException * @throws MalformedArrayException
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws RedundancyLimitException * @throws RedundancyLimitException
* @throws RequestContentException * @throws RequestContentException
* @throws RequestNetworkException * @throws RequestNetworkException
@ -324,7 +324,7 @@ class NoteService {
$item->setActorId($item->getAttributedTo()); $item->setActorId($item->getAttributedTo());
$this->activityService->deleteActivity($item); $this->activityService->deleteActivity($item);
$this->notesRequest->deleteNoteById($item->getId(), $type); $this->streamRequest->deleteStreamById($item->getId(), $type);
} }
@ -333,10 +333,10 @@ class NoteService {
* @param bool $asViewer * @param bool $asViewer
* *
* @return Stream * @return Stream
* @throws NoteNotFoundException * @throws StreamNotFoundException
*/ */
public function getNoteById(string $id, bool $asViewer = false): Stream { public function getNoteById(string $id, bool $asViewer = false): Stream {
return $this->notesRequest->getNoteById($id, $asViewer); return $this->streamRequest->getStreamById($id, $asViewer);
} }
@ -349,7 +349,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamHome($actor, $since, $limit); return $this->streamRequest->getStreamHome($actor, $since, $limit);
} }
@ -362,7 +362,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamNotifications($actor, $since, $limit); return $this->streamRequest->getStreamNotifications($actor, $since, $limit);
} }
@ -375,7 +375,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array { public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamAccount($actorId, $since, $limit); return $this->streamRequest->getStreamAccount($actorId, $since, $limit);
} }
@ -388,7 +388,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array { public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamDirect($actor, $since, $limit); return $this->streamRequest->getStreamDirect($actor, $since, $limit);
} }
@ -400,7 +400,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamLocalTimeline(int $since = 0, int $limit = 5): array { public function getStreamLocalTimeline(int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamTimeline($since, $limit, true); return $this->streamRequest->getStreamTimeline($since, $limit, true);
} }
@ -415,7 +415,7 @@ class NoteService {
*/ */
public function getStreamLocalTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5 public function getStreamLocalTag(Person $actor, string $hashtag, int $since = 0, int $limit = 5
): array { ): array {
return $this->notesRequest->getStreamTag($actor, $hashtag, $since, $limit); return $this->streamRequest->getStreamTag($actor, $hashtag, $since, $limit);
} }
@ -440,7 +440,7 @@ class NoteService {
* @throws Exception * @throws Exception
*/ */
public function getStreamGlobalTimeline(int $since = 0, int $limit = 5): array { public function getStreamGlobalTimeline(int $since = 0, int $limit = 5): array {
return $this->notesRequest->getStreamTimeline($since, $limit, false); return $this->streamRequest->getStreamTimeline($since, $limit, false);
} }
@ -451,7 +451,7 @@ class NoteService {
* @throws InvalidOriginException * @throws InvalidOriginException
* @throws InvalidResourceException * @throws InvalidResourceException
* @throws MalformedArrayException * @throws MalformedArrayException
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws RedundancyLimitException * @throws RedundancyLimitException
* @throws SocialAppConfigException * @throws SocialAppConfigException
* @throws ItemUnknownException * @throws ItemUnknownException
@ -462,7 +462,7 @@ class NoteService {
* @throws RequestResultNotJsonException * @throws RequestResultNotJsonException
*/ */
public function getAuthorFromPostId($noteId) { public function getAuthorFromPostId($noteId) {
$note = $this->notesRequest->getNoteById($noteId); $note = $this->streamRequest->getStreamById($noteId);
return $this->cacheActorService->getFromId($note->getAttributedTo()); return $this->cacheActorService->getFromId($note->getAttributedTo());
} }

Wyświetl plik

@ -34,7 +34,7 @@ use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\RedundancyLimitException; use OCA\Social\Exceptions\RedundancyLimitException;
use OCA\Social\Exceptions\RequestContentException; use OCA\Social\Exceptions\RequestContentException;
use OCA\Social\Exceptions\RequestNetworkException; use OCA\Social\Exceptions\RequestNetworkException;
@ -95,7 +95,7 @@ class PostService {
* @throws InvalidResourceException * @throws InvalidResourceException
* @throws ItemUnknownException * @throws ItemUnknownException
* @throws MalformedArrayException * @throws MalformedArrayException
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws RedundancyLimitException * @throws RedundancyLimitException
* @throws RequestContentException * @throws RequestContentException
* @throws RequestNetworkException * @throws RequestNetworkException

Wyświetl plik

@ -34,12 +34,12 @@ use daita\MySmallPhpTools\Exceptions\MalformedArrayException;
use daita\MySmallPhpTools\Model\Cache; use daita\MySmallPhpTools\Model\Cache;
use daita\MySmallPhpTools\Model\CacheItem; use daita\MySmallPhpTools\Model\CacheItem;
use OCA\Social\AP; use OCA\Social\AP;
use OCA\Social\Db\NotesRequest; use OCA\Social\Db\StreamRequest;
use OCA\Social\Db\StreamQueueRequest; use OCA\Social\Db\StreamQueueRequest;
use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\InvalidOriginException;
use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Exceptions\InvalidResourceException;
use OCA\Social\Exceptions\ItemUnknownException; use OCA\Social\Exceptions\ItemUnknownException;
use OCA\Social\Exceptions\NoteNotFoundException; use OCA\Social\Exceptions\StreamNotFoundException;
use OCA\Social\Exceptions\QueueStatusException; use OCA\Social\Exceptions\QueueStatusException;
use OCA\Social\Exceptions\RedundancyLimitException; use OCA\Social\Exceptions\RedundancyLimitException;
use OCA\Social\Exceptions\RequestContentException; use OCA\Social\Exceptions\RequestContentException;
@ -61,8 +61,8 @@ use OCA\Social\Model\StreamQueue;
class StreamQueueService { class StreamQueueService {
/** @var NotesRequest */ /** @var StreamRequest */
private $notesRequest; private $streamRequest;
/** @var StreamQueueRequest */ /** @var StreamQueueRequest */
private $streamQueueRequest; private $streamQueueRequest;
@ -79,17 +79,17 @@ class StreamQueueService {
/** /**
* StreamQueueService constructor. * StreamQueueService constructor.
* *
* @param NotesRequest $notesRequest * @param StreamRequest $streamRequest
* @param StreamQueueRequest $streamQueueRequest * @param StreamQueueRequest $streamQueueRequest
* @param ImportService $importService * @param ImportService $importService
* @param CurlService $curlService * @param CurlService $curlService
* @param MiscService $miscService * @param MiscService $miscService
*/ */
public function __construct( public function __construct(
NotesRequest $notesRequest, StreamQueueRequest $streamQueueRequest, StreamRequest $streamRequest, StreamQueueRequest $streamQueueRequest,
ImportService $importService, CurlService $curlService, MiscService $miscService ImportService $importService, CurlService $curlService, MiscService $miscService
) { ) {
$this->notesRequest = $notesRequest; $this->streamRequest = $streamRequest;
$this->streamQueueRequest = $streamQueueRequest; $this->streamQueueRequest = $streamQueueRequest;
$this->importService = $importService; $this->importService = $importService;
$this->curlService = $curlService; $this->curlService = $curlService;
@ -170,8 +170,8 @@ class StreamQueueService {
*/ */
private function manageStreamQueueCache(StreamQueue $queue) { private function manageStreamQueueCache(StreamQueue $queue) {
try { try {
$stream = $this->notesRequest->getNoteById($queue->getStreamId()); $stream = $this->streamRequest->getStreamById($queue->getStreamId());
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
$this->deleteCache($queue); $this->deleteCache($queue);
return; return;
@ -211,7 +211,7 @@ class StreamQueueService {
$this->cacheItem($item); $this->cacheItem($item);
$item->setStatus(StreamQueue::STATUS_SUCCESS); $item->setStatus(StreamQueue::STATUS_SUCCESS);
$cache->updateItem($item); $cache->updateItem($item);
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
$this->miscService->log( $this->miscService->log(
'Error caching stream: ' . json_encode($item) . ' ' . get_class($e) . ' ' 'Error caching stream: ' . json_encode($item) . ' ' . get_class($e) . ' '
. $e->getMessage(), 1 . $e->getMessage(), 1
@ -291,7 +291,7 @@ class StreamQueueService {
* @throws InvalidResourceException * @throws InvalidResourceException
* @throws ItemUnknownException * @throws ItemUnknownException
* @throws MalformedArrayException * @throws MalformedArrayException
* @throws NoteNotFoundException * @throws StreamNotFoundException
* @throws RedundancyLimitException * @throws RedundancyLimitException
* @throws RequestContentException * @throws RequestContentException
* @throws RequestNetworkException * @throws RequestNetworkException
@ -303,8 +303,8 @@ class StreamQueueService {
private function cacheItem(CacheItem &$item) { private function cacheItem(CacheItem &$item) {
try { try {
$object = $this->notesRequest->getNoteById($item->getUrl()); $object = $this->streamRequest->getStreamById($item->getUrl());
} catch (NoteNotFoundException $e) { } catch (StreamNotFoundException $e) {
$data = $this->curlService->retrieveObject($item->getUrl()); $data = $this->curlService->retrieveObject($item->getUrl());
$object = AP::$activityPub->getItemFromData($data); $object = AP::$activityPub->getItemFromData($data);
@ -323,7 +323,7 @@ class StreamQueueService {
$interface->save($object); $interface->save($object);
} }
$note = $this->notesRequest->getNoteById($object->getId()); $note = $this->streamRequest->getStreamById($object->getId());
$item->setContent(json_encode($note, JSON_UNESCAPED_SLASHES)); $item->setContent(json_encode($note, JSON_UNESCAPED_SLASHES));
} }
@ -335,7 +335,7 @@ class StreamQueueService {
* @return bool * @return bool
*/ */
private function updateCache(Stream $stream, Cache $cache): bool { private function updateCache(Stream $stream, Cache $cache): bool {
$this->notesRequest->updateCache($stream, $cache); $this->streamRequest->updateCache($stream, $cache);
$done = true; $done = true;
foreach ($cache->getItems() as $item) { foreach ($cache->getItems() as $item) {