Add backend support for comments

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-04 17:29:28 +02:00
parent 10c09927e2
commit d3027acd37
6 changed files with 68 additions and 1 deletions

View File

@@ -23,12 +23,15 @@
namespace OCA\Deck\AppInfo;
use OCA\Deck\Activity\CommentEventHandler;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\AclMapper;
use OCA\Deck\Db\AssignedUsersMapper;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Notification\Notifier;
use OCP\AppFramework\App;
use OCA\Deck\Middleware\SharingMiddleware;
use OCP\Comments\CommentsEntityEvent;
use OCP\IGroup;
use OCP\IUser;
use OCP\IUserManager;
@@ -120,6 +123,27 @@ class Application extends App {
}, function() {
return ['id' => 'deck', 'name' => 'Deck'];
});
}
public function registerCommentsEntity() {
$this->getContainer()->getServer()->getEventDispatcher()->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
$event->addEntityCollection('deckCard', function($name) {
/** @var CardMapper */
$service = $this->getContainer()->query(CardMapper::class);
try {
$card = $service->find((int) $name);
} catch (\InvalidArgumentException $e) {
return false;
}
return true;
});
});
$this->registerCommentsEventHandler();
}
protected function registerCommentsEventHandler() {
$this->getContainer()->getServer()->getCommentsManager()->registerEventHandler(function () {
return $this->getContainer()->query(CommentEventHandler::class);
});
}
}