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

Only notify when a post is created, not edited

This commit is contained in:
Toby Zerner
2015-05-19 11:01:11 +09:30
parent fdc82b5273
commit 2101250eaa
2 changed files with 20 additions and 16 deletions

View File

@@ -30,7 +30,15 @@ class PostMentionsMetadataUpdater
public function whenPostWasPosted(PostWasPosted $event)
{
$this->syncMentions($event->post);
$mentioned = $this->syncMentions($event->post);
// @todo convert this into a new event (PostWasMentioned) and send
// notification as a handler?
foreach ($mentioned as $post) {
if ($post->user->id !== $reply->user->id) {
$this->notifier->send(new PostMentionedNotification($post, $reply->user, $reply), [$post->user]);
}
}
}
public function whenPostWasRevised(PostWasRevised $event)
@@ -50,12 +58,6 @@ class PostMentionsMetadataUpdater
$mentioned = $reply->discussion->posts()->with('user')->whereIn('number', array_filter($matches['number']))->get();
$reply->mentionsPosts()->sync($mentioned->lists('id'));
// @todo convert this into a new event (PostWasMentioned) and send
// notification as a handler?
foreach ($mentioned as $post) {
if ($post->user->id !== $reply->user->id) {
$this->notifier->send(new PostMentionedNotification($post, $reply->user, $reply), [$post->user]);
}
}
return $mentioned;
}
}

View File

@@ -31,7 +31,15 @@ class UserMentionsMetadataUpdater
public function whenPostWasPosted(PostWasPosted $event)
{
$this->syncMentions($event->post);
$mentioned = $this->syncMentions($event->post);
// @todo convert this into a new event (UserWasMentioned) and send
// notification as a handler?
foreach ($mentioned as $user) {
if ($user->id !== $post->user->id) {
$this->notifier->send(new UserMentionedNotification($post->user, $post), [$user]);
}
}
}
public function whenPostWasRevised(PostWasRevised $event)
@@ -51,12 +59,6 @@ class UserMentionsMetadataUpdater
$mentioned = User::whereIn('username', array_filter($matches['username']))->get();
$post->mentionsUsers()->sync($mentioned);
// @todo convert this into a new event (UserWasMentioned) and send
// notification as a handler?
foreach ($mentioned as $user) {
if ($user->id !== $post->user->id) {
$this->notifier->send(new UserMentionedNotification($post->user, $post), [$user]);
}
}
return $mentioned;
}
}