1
0
mirror of https://github.com/flarum/core.git synced 2025-10-20 03:06:07 +02:00

Delete associated notifications when deleting discussions, posts, and users. fixes #1380

This commit is contained in:
Toby Zerner
2018-11-11 16:59:24 +10:30
parent 6d14d0c39b
commit bf8bc0222f
4 changed files with 45 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ use Flarum\Discussion\Discussion;
use Flarum\Event\GetModelIsPrivate;
use Flarum\Event\ScopeModelVisibility;
use Flarum\Foundation\EventGeneratorTrait;
use Flarum\Notification\Notification;
use Flarum\Post\Event\Deleted;
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
@@ -106,6 +107,8 @@ class Post extends AbstractModel
static::deleted(function (Post $post) {
$post->raise(new Deleted($post));
Notification::whereSubject($post)->delete();
});
static::addGlobalScope(new RegisteredTypesScope);