Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/Activity/DeckProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OCA\Deck\Db\Acl;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\CirclesService;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
use OCP\Comments\IComment;
Expand Down Expand Up @@ -61,12 +62,12 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
* To do so, simply use setChildEvent($previousEvent) after setting the
* combined subject on the current event.
* @return IEvent
* @throws \InvalidArgumentException Should be thrown if your provider does not know this event
* @throws UnknownActivityException Should be thrown if your provider does not know this event
* @since 11.0.0
*/
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'deck') {
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}

$event = $this->getIcon($event);
Expand Down Expand Up @@ -107,7 +108,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):
}
if ($event->getObjectType() === ActivityManager::DECK_OBJECT_BOARD) {
if (!$this->activityManager->canSeeBoardActivity($event->getObjectId(), $event->getAffectedUser())) {
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}
if (isset($subjectParams['board']) && $event->getObjectName() === '') {
$event->setObject($event->getObjectType(), $event->getObjectId(), $subjectParams['board']['title']);
Expand All @@ -124,7 +125,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):

if (isset($subjectParams['card']) && $event->getObjectType() === ActivityManager::DECK_OBJECT_CARD) {
if (!$this->activityManager->canSeeCardActivity($event->getObjectId(), $event->getAffectedUser())) {
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}
if ($event->getObjectName() === '') {
$event->setObject($event->getObjectType(), $event->getObjectId(), $subjectParams['card']['title']);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Activity/DeckProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Deck\Db\Card;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\CirclesService;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
Expand Down Expand Up @@ -122,7 +123,7 @@ private function mockEvent($objectType, $objectId, $objectName, $subject, $subje
}

public function testParseFailureApp() {
$this->expectException(\InvalidArgumentException::class);
$this->expectException(UnknownActivityException::class);
$event = $this->createMock(IEvent::class);
$event->expects($this->once())->method('getApp')->willReturn('notdeck');
$this->provider->parse('en_US', $event, $event);
Expand Down
Loading