diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-05-17 09:19:00 -0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-17 09:19:00 -0100 |
commit | 1ad4d54ac76c54def69158669dd785dad3d2233e (patch) | |
tree | f920c293f47a15947e94e59503e3fa3ef475eb51 /lib | |
parent | 7d5ea91b58fce9e95b8e524ab8a6fed5858c2794 (diff) | |
parent | d16537b403a0ee29f6c4d5d99c9e8cadd7a201e3 (diff) |
Merge pull request #524 from nextcloud/notes-to-stream
Notes -> Stream
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/CoreRequestBuilder.php | 10 | ||||
-rw-r--r-- | lib/Db/StreamRequest.php (renamed from lib/Db/NotesRequest.php) | 225 | ||||
-rw-r--r-- | lib/Db/StreamRequestBuilder.php (renamed from lib/Db/NotesRequestBuilder.php) | 39 | ||||
-rw-r--r-- | lib/Exceptions/DateTimeException.php | 10 | ||||
-rw-r--r-- | lib/Exceptions/NoteNotFoundException.php | 8 | ||||
-rw-r--r-- | lib/Exceptions/StreamNotFoundException.php | 8 | ||||
-rw-r--r-- | lib/Interfaces/Actor/PersonInterface.php | 14 | ||||
-rw-r--r-- | lib/Interfaces/Internal/SocialAppNotificationInterface.php | 14 | ||||
-rw-r--r-- | lib/Interfaces/Object/AnnounceInterface.php | 29 | ||||
-rw-r--r-- | lib/Interfaces/Object/NoteInterface.php | 26 | ||||
-rw-r--r-- | lib/Service/AccountService.php | 14 | ||||
-rw-r--r-- | lib/Service/ActivityService.php | 20 | ||||
-rw-r--r-- | lib/Service/BoostService.php | 32 | ||||
-rw-r--r-- | lib/Service/HashtagService.php | 27 | ||||
-rw-r--r-- | lib/Service/NoteService.php | 42 | ||||
-rw-r--r-- | lib/Service/PostService.php | 4 | ||||
-rw-r--r-- | lib/Service/StreamQueueService.php | 30 |
17 files changed, 269 insertions, 283 deletions
diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 6bfbd2a4..697f5465 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -35,6 +35,7 @@ use DateInterval; use DateTime; use Doctrine\DBAL\Query\QueryBuilder; use Exception; +use OCA\Social\Exceptions\DateTimeException; use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Model\ActivityPub\Actor\Person; use OCA\Social\Model\ActivityPub\Object\Document; @@ -587,10 +588,15 @@ class CoreRequestBuilder { * @param int $timestamp * @param string $field * - * @throws Exception + * @throws DateTimeException */ 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); $expr = $qb->expr(); diff --git a/lib/Db/NotesRequest.php b/lib/Db/StreamRequest.php index 5bbf2478..d427fee2 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/StreamRequest.php @@ -34,7 +34,8 @@ use daita\MySmallPhpTools\Model\Cache; use DateTime; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; 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\Actor\Person; use OCA\Social\Model\ActivityPub\Object\Note; @@ -44,11 +45,17 @@ use OCA\Social\Service\MiscService; use OCP\DB\QueryBuilder\IQueryBuilder; 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 ConfigService $configService @@ -63,8 +70,6 @@ class NotesRequest extends NotesRequestBuilder { /** * @param Stream $stream - * - * @throws Exception */ public function save(Stream $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 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))); $this->limitToIdString($qb, $stream->getId()); @@ -146,14 +112,14 @@ class NotesRequest extends NotesRequestBuilder { * @param bool $asViewer * * @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 === '') { - throw new NoteNotFoundException(); + throw new StreamNotFoundException(); }; - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitToIdString($qb, $id); $this->leftJoinCacheActors($qb, 'attributed_to'); @@ -167,17 +133,16 @@ class NotesRequest extends NotesRequestBuilder { $cursor->closeCursor(); if ($data === false) { - throw new NoteNotFoundException('Post not found'); + throw new StreamNotFoundException('Stream not found'); } try { - /** @var Note $note */ - $note = $this->parseNotesSelectSql($data); + $stream = $this->parseStreamSelectSql($data); } 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 * * @return Stream - * @throws NoteNotFoundException + * @throws StreamNotFoundException * @throws Exception */ - public function getNoteByActivityId(string $id): Stream { + public function getStreamByActivityId(string $id): Stream { if ($id === '') { - throw new NoteNotFoundException(); + throw new StreamNotFoundException(); }; - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitToActivityId($qb, $id); $cursor = $qb->execute(); @@ -201,10 +166,10 @@ class NotesRequest extends NotesRequestBuilder { $cursor->closeCursor(); 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 * * @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 === '') { - throw new NoteNotFoundException('missing objectId'); + throw new StreamNotFoundException('missing objectId'); }; - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitToObjectId($qb, $objectId); $this->limitToType($qb, $type); $this->limitToAttributedTo($qb, $actor->getId()); @@ -232,13 +197,13 @@ class NotesRequest extends NotesRequestBuilder { $cursor->closeCursor(); if ($data === false) { - throw new NoteNotFoundException( + throw new StreamNotFoundException( 'StreamByObjectId not found - ' . $actor->getId() . ' - ' . $type . ' - ' . $objectId ); } - return $this->parseNotesSelectSql($data); + return $this->parseStreamSelectSql($data); } @@ -273,25 +238,24 @@ class NotesRequest extends NotesRequestBuilder { * @throws Exception */ public function getStreamHome(Person $actor, int $since = 0, int $limit = 5): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->joinFollowing($qb, $actor); -// $this->limitToType($qb, Note::TYPE); $this->limitPaginate($qb, $since, $limit); $this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinStreamAction($qb); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { try { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } catch (Exception $e) { } } $cursor->closeCursor(); - return $notes; + return $streams; } @@ -311,24 +275,24 @@ class NotesRequest extends NotesRequestBuilder { * @throws Exception */ public function getStreamNotifications(Person $actor, int $since = 0, int $limit = 5): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitPaginate($qb, $since, $limit); $this->limitToRecipient($qb, $actor->getId(), false); $this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinStreamAction($qb); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { try { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } catch (Exception $e) { } } $cursor->closeCursor(); - return $notes; + return $streams; } @@ -345,26 +309,25 @@ class NotesRequest extends NotesRequestBuilder { * @throws Exception */ public function getStreamAccount(string $actorId, int $since = 0, int $limit = 5): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitPaginate($qb, $since, $limit); -// $this->limitToType($qb, Note::TYPE); $this->limitToAttributedTo($qb, $actorId); $this->leftJoinCacheActors($qb, 'attributed_to'); $this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC); $this->leftJoinStreamAction($qb); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { try { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } catch (Exception $e) { } } $cursor->closeCursor(); - return $notes; + return $streams; } @@ -381,27 +344,26 @@ class NotesRequest extends NotesRequestBuilder { * @throws Exception */ public function getStreamDirect(Person $actor, int $since = 0, int $limit = 5): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitPaginate($qb, $since, $limit); -// $this->limitToType($qb, Note::TYPE); $this->limitToRecipient($qb, $actor->getId(), true); $this->filterToRecipient($qb, ACore::CONTEXT_PUBLIC); $this->filterToRecipient($qb, $actor->getFollowers()); $this->leftJoinCacheActors($qb, 'attributed_to'); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { try { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } catch (Exception $e) { } } $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 ): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $this->limitPaginate($qb, $since, $limit); -// $this->limitToType($qb, Note::TYPE); if ($localOnly) { $this->limitToLocal($qb, true); @@ -432,17 +393,17 @@ class NotesRequest extends NotesRequestBuilder { // TODO: to: = real public, cc: = unlisted !? $this->limitToRecipient($qb, ACore::CONTEXT_PUBLIC, true, ['to']); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { try { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } catch (Exception $e) { } } $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 ): array { - $qb = $this->getNotesSelectSql(); + $qb = $this->getStreamSelectSql(); $on = $this->exprJoinFollowing($qb, $actor); $on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false)); @@ -475,36 +436,37 @@ class NotesRequest extends NotesRequestBuilder { $this->leftJoinCacheActors($qb, 'attributed_to'); $this->leftJoinStreamAction($qb); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } $cursor->closeCursor(); - return $notes; + return $streams; } /** * @param int $since * - * @return Note[] - * @throws Exception + * @return Stream[] + * @throws DateTimeException */ - public function getNotesSince(int $since): array { - $qb = $this->getNotesSelectSql(); + public function getNoteSince(int $since): array { + $qb = $this->getStreamSelectSql(); $this->limitToSince($qb, $since, 'published_time'); + $this->limitToType($qb, Note::TYPE); $this->leftJoinStreamAction($qb); - $notes = []; + $streams = []; $cursor = $qb->execute(); while ($data = $cursor->fetch()) { - $notes[] = $this->parseNotesSelectSql($data); + $streams[] = $this->parseStreamSelectSql($data); } $cursor->closeCursor(); - return $notes; + return $streams; } @@ -512,8 +474,8 @@ class NotesRequest extends NotesRequestBuilder { * @param string $id * @param string $type */ - public function deleteNoteById(string $id, string $type = '') { - $qb = $this->getNotesDeleteSql(); + public function deleteStreamById(string $id, string $type = '') { + $qb = $this->getStreamDeleteSql(); $this->limitToIdString($qb, $id); if ($type !== '') { @@ -528,7 +490,7 @@ class NotesRequest extends NotesRequestBuilder { * @param string $actorId */ public function deleteByAuthor(string $actorId) { - $qb = $this->getNotesDeleteSql(); + $qb = $this->getStreamDeleteSql(); $this->limitToAttributedTo($qb, $actorId); $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 */ - public function saveStream(Stream $note): IQueryBuilder { + public function saveStream(Stream $stream): IQueryBuilder { try { $dTime = new DateTime(); - $dTime->setTimestamp($note->getPublishedTime()); + $dTime->setTimestamp($stream->getPublishedTime()); } catch (Exception $e) { } $cache = '[]'; - if ($note->gotCache()) { - $cache = json_encode($note->getCache(), JSON_UNESCAPED_SLASHES); + if ($stream->gotCache()) { + $cache = json_encode($stream->getCache(), JSON_UNESCAPED_SLASHES); } - $attributedTo = $note->getAttributedTo(); - if ($attributedTo === '' && $note->isLocal()) { - $attributedTo = $note->getActor() - ->getId(); + $attributedTo = $stream->getAttributedTo(); + if ($attributedTo === '' && $stream->isLocal()) { + $attributedTo = $stream->getActor() + ->getId(); } - $qb = $this->getNotesInsertSql(); - $qb->setValue('id', $qb->createNamedParameter($note->getId())) - ->setValue('type', $qb->createNamedParameter($note->getType())) - ->setValue('to', $qb->createNamedParameter($note->getTo())) + $qb = $this->getStreamInsertSql(); + $qb->setValue('id', $qb->createNamedParameter($stream->getId())) + ->setValue('type', $qb->createNamedParameter($stream->getType())) + ->setValue('to', $qb->createNamedParameter($stream->getTo())) ->setValue( 'to_array', $qb->createNamedParameter( - json_encode($note->getToArray(), JSON_UNESCAPED_SLASHES) + json_encode($stream->getToArray(), JSON_UNESCAPED_SLASHES) ) ) ->setValue( 'cc', $qb->createNamedParameter( - json_encode($note->getCcArray(), JSON_UNESCAPED_SLASHES) + json_encode($stream->getCcArray(), JSON_UNESCAPED_SLASHES) ) ) ->setValue( 'bcc', $qb->createNamedParameter( - json_encode($note->getBccArray()), JSON_UNESCAPED_SLASHES + json_encode($stream->getBccArray()), JSON_UNESCAPED_SLASHES ) ) - ->setValue('content', $qb->createNamedParameter($note->getContent())) - ->setValue('summary', $qb->createNamedParameter($note->getSummary())) - ->setValue('published', $qb->createNamedParameter($note->getPublished())) + ->setValue('content', $qb->createNamedParameter($stream->getContent())) + ->setValue('summary', $qb->createNamedParameter($stream->getSummary())) + ->setValue('published', $qb->createNamedParameter($stream->getPublished())) ->setValue('attributed_to', $qb->createNamedParameter($attributedTo)) - ->setValue('in_reply_to', $qb->createNamedParameter($note->getInReplyTo())) - ->setValue('source', $qb->createNamedParameter($note->getSource())) - ->setValue('object_id', $qb->createNamedParameter($note->getObjectId())) + ->setValue('in_reply_to', $qb->createNamedParameter($stream->getInReplyTo())) + ->setValue('source', $qb->createNamedParameter($stream->getSource())) + ->setValue('activity_id', $qb->createNamedParameter($stream->getActivityId())) + ->setValue('object_id', $qb->createNamedParameter($stream->getObjectId())) ->setValue('cache', $qb->createNamedParameter($cache)) ->setValue( '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 { $dTime = new DateTime(); - $dTime->setTimestamp($note->getPublishedTime()); + $dTime->setTimestamp($stream->getPublishedTime()); $qb->setValue( 'published_time', $qb->createNamedParameter($dTime, IQueryBuilder::PARAM_DATE) ) @@ -608,7 +571,7 @@ class NotesRequest extends NotesRequestBuilder { } catch (Exception $e) { } - $this->generatePrimaryKey($qb, $note->getId()); + $this->generatePrimaryKey($qb, $stream->getId()); return $qb; } diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/StreamRequestBuilder.php index 19334e99..254d3ca0 100644 --- a/lib/Db/NotesRequestBuilder.php +++ b/lib/Db/StreamRequestBuilder.php @@ -35,6 +35,7 @@ use Doctrine\DBAL\Query\QueryBuilder; use OCA\Social\Exceptions\InvalidResourceException; use OCA\Social\Model\ActivityPub\ACore; use OCA\Social\Model\ActivityPub\Actor\Person; +use OCA\Social\Model\ActivityPub\Object\Note; use OCA\Social\Model\ActivityPub\Stream; use OCA\Social\Model\InstancePath; use OCP\DB\QueryBuilder\ICompositeExpression; @@ -42,11 +43,11 @@ use OCP\DB\QueryBuilder\IQueryBuilder; /** - * Class NotesRequestBuilder + * Class StreamRequestBuilder * * @package OCA\Social\Db */ -class NotesRequestBuilder extends CoreRequestBuilder { +class StreamRequestBuilder extends CoreRequestBuilder { use TArrayTools; @@ -57,7 +58,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { * * @return IQueryBuilder */ - protected function getNotesInsertSql(): IQueryBuilder { + protected function getStreamInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $qb->insert(self::TABLE_STREAMS); @@ -70,7 +71,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { * * @return IQueryBuilder */ - protected function getNotesUpdateSql(): IQueryBuilder { + protected function getStreamUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $qb->update(self::TABLE_STREAMS); @@ -83,21 +84,21 @@ class NotesRequestBuilder extends CoreRequestBuilder { * * @return IQueryBuilder */ - protected function getNotesSelectSql(): IQueryBuilder { + protected function getStreamSelectSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); /** @noinspection PhpMethodParametersCountMismatchInspection */ - $qb->selectDistinct('sn.id') + $qb->selectDistinct('s.id') ->addSelect( - 'sn.type', 'sn.to', 'sn.to_array', 'sn.cc', 'sn.bcc', 'sn.content', - 'sn.summary', 'sn.attachments', 'sn.published', 'sn.published_time', 'sn.cache', - 'sn.object_id', - 'sn.attributed_to', 'sn.in_reply_to', 'sn.source', 'sn.local', 'sn.instances', - 'sn.creation' + 's.type', 's.to', 's.to_array', 's.cc', 's.bcc', 's.content', + 's.summary', 's.attachments', 's.published', 's.published_time', 's.cache', + 's.object_id', + 's.attributed_to', 's.in_reply_to', 's.source', 's.local', 's.instances', + 's.creation' ) - ->from(self::TABLE_STREAMS, 'sn'); + ->from(self::TABLE_STREAMS, 's'); - $this->defaultSelectAlias = 'sn'; + $this->defaultSelectAlias = 's'; return $qb; } @@ -111,9 +112,11 @@ class NotesRequestBuilder extends CoreRequestBuilder { protected function countNotesSelectSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $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; } @@ -124,7 +127,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { * * @return IQueryBuilder */ - protected function getNotesDeleteSql(): IQueryBuilder { + protected function getStreamDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete(self::TABLE_STREAMS); @@ -155,7 +158,6 @@ class NotesRequestBuilder extends CoreRequestBuilder { } $on = $this->exprJoinFollowing($qb, $actor); - $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on); } @@ -163,7 +165,6 @@ class NotesRequestBuilder extends CoreRequestBuilder { /** * @param IQueryBuilder $qb * @param Person $actor - * * @param bool $followers * * @return ICompositeExpression @@ -362,7 +363,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { * * @return Stream */ - protected function parseNotesSelectSql($data): Stream { + protected function parseStreamSelectSql($data): Stream { $item = new Stream(); $item->importFromDatabase($data); diff --git a/lib/Exceptions/DateTimeException.php b/lib/Exceptions/DateTimeException.php new file mode 100644 index 00000000..917c07e4 --- /dev/null +++ b/lib/Exceptions/DateTimeException.php @@ -0,0 +1,10 @@ +<?php + +namespace OCA\Social\Exceptions; + +use Exception; + +class DateTimeException extends Exception { + +} + diff --git a/lib/Exceptions/NoteNotFoundException.php b/lib/Exceptions/NoteNotFoundException.php deleted file mode 100644 index 0bd86298..00000000 --- a/lib/Exceptions/NoteNotFoundException.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php - -namespace OCA\Social\Exceptions; - -class NoteNotFoundException extends \Exception { - -} - diff --git a/lib/Exceptions/StreamNotFoundException.php b/lib/Exceptions/StreamNotFoundException.php new file mode 100644 index 00000000..5538996a --- /dev/null +++ b/lib/Exceptions/StreamNotFoundException.php @@ -0,0 +1,8 @@ +<?php + +namespace OCA\Social\Exceptions; + +class StreamNotFoundException extends \Exception { + +} + diff --git a/lib/Interfaces/Actor/PersonInterface.php b/lib/Interfaces/Actor/PersonInterface.php index e7b6e9a8..5e843b44 100644 --- a/lib/Interfaces/Actor/PersonInterface.php +++ b/lib/Interfaces/Actor/PersonInterface.php @@ -33,7 +33,7 @@ namespace OCA\Social\Interfaces\Actor; use daita\MySmallPhpTools\Traits\TArrayTools; use OCA\Social\Db\CacheActorsRequest; -use OCA\Social\Db\NotesRequest; +use OCA\Social\Db\StreamRequest; use OCA\Social\Exceptions\CacheActorDoesNotExistException; use OCA\Social\Exceptions\InvalidOriginException; use OCA\Social\Exceptions\ItemNotFoundException; @@ -60,8 +60,8 @@ class PersonInterface implements IActivityPubInterface { /** @var CacheActorsRequest */ private $cacheActorsRequest; - /** @var NotesRequest */ - private $notesRequest; + /** @var StreamRequest */ + private $streamRequest; /** @var ActorService */ private $actorService; @@ -77,17 +77,17 @@ class PersonInterface implements IActivityPubInterface { * UndoService constructor. * * @param CacheActorsRequest $cacheActorsRequest - * @param NotesRequest $notesRequest + * @param StreamRequest $streamRequest * @param ActorService $actorService * @param ConfigService $configService * @param MiscService $miscService */ public function __construct( - CacheActorsRequest $cacheActorsRequest, NotesRequest $notesRequest, + CacheActorsRequest $cacheActorsRequest, StreamRequest $streamRequest, ActorService $actorService, ConfigService $configService, MiscService $miscService ) { $this->cacheActorsRequest = $cacheActorsRequest; - $this->notesRequest = $notesRequest; + $this->streamRequest = $streamRequest; $this->actorService = $actorService; $this->configService = $configService; $this->miscService = $miscService; @@ -161,7 +161,7 @@ class PersonInterface implements IActivityPubInterface { public function delete(ACore $item) { /** @var Person $item */ $this->cacheActorsRequest->deleteFromId($item-& |