diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-10-12 18:06:22 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-10-12 18:06:22 +0200 |
commit | 1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8 (patch) | |
tree | e1af5850f05bfd165c3542f0b50a49fe623452c0 /lib | |
parent | a9671a4dc2cc904ebb852c7804204ac9f245017e (diff) | |
download | nextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.tar.gz nextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.zip |
emit pre-update event for comments
* notifications can be cleaned up, no polluted DB
* updating comments will re-notify users or remove notifications, depending on the message
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Comments/Manager.php | 6 | ||||
-rw-r--r-- | lib/public/Comments/CommentsEvent.php | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index f7b23dd5f58..b3ecab731e1 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -536,6 +536,12 @@ class Manager implements ICommentsManager { * @throws NotFoundException */ protected function update(IComment $comment) { + // for properly working preUpdate Events we need the old comments as is + // in the DB and overcome caching. Also avoid that outdated information stays. + $this->uncache($comment->getId()); + $this->sendEvent(CommentsEvent::EVENT_PRE_UPDATE, $this->get($comment->getId())); + $this->uncache($comment->getId()); + $qb = $this->dbConn->getQueryBuilder(); $affectedRows = $qb ->update('comments') diff --git a/lib/public/Comments/CommentsEvent.php b/lib/public/Comments/CommentsEvent.php index a0bff349fb4..0d8a783c107 100644 --- a/lib/public/Comments/CommentsEvent.php +++ b/lib/public/Comments/CommentsEvent.php @@ -32,9 +32,10 @@ use Symfony\Component\EventDispatcher\Event; */ class CommentsEvent extends Event { - const EVENT_ADD = 'OCP\Comments\ICommentsManager::addComment'; - const EVENT_UPDATE = 'OCP\Comments\ICommentsManager::updateComment'; - const EVENT_DELETE = 'OCP\Comments\ICommentsManager::deleteComment'; + const EVENT_ADD = 'OCP\Comments\ICommentsManager::addComment'; + const EVENT_PRE_UPDATE = 'OCP\Comments\ICommentsManager::preUpdateComment'; + const EVENT_UPDATE = 'OCP\Comments\ICommentsManager::updateComment'; + const EVENT_DELETE = 'OCP\Comments\ICommentsManager::deleteComment'; /** @var string */ protected $event; |