mirror of
https://github.com/flarum/core.git
synced 2025-08-01 22:20:21 +02:00
Only notify when a post is created, not edited
This commit is contained in:
@@ -30,7 +30,15 @@ class PostMentionsMetadataUpdater
|
|||||||
|
|
||||||
public function whenPostWasPosted(PostWasPosted $event)
|
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)
|
public function whenPostWasRevised(PostWasRevised $event)
|
||||||
@@ -50,12 +58,6 @@ class PostMentionsMetadataUpdater
|
|||||||
$mentioned = $reply->discussion->posts()->with('user')->whereIn('number', array_filter($matches['number']))->get();
|
$mentioned = $reply->discussion->posts()->with('user')->whereIn('number', array_filter($matches['number']))->get();
|
||||||
$reply->mentionsPosts()->sync($mentioned->lists('id'));
|
$reply->mentionsPosts()->sync($mentioned->lists('id'));
|
||||||
|
|
||||||
// @todo convert this into a new event (PostWasMentioned) and send
|
return $mentioned;
|
||||||
// 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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,15 @@ class UserMentionsMetadataUpdater
|
|||||||
|
|
||||||
public function whenPostWasPosted(PostWasPosted $event)
|
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)
|
public function whenPostWasRevised(PostWasRevised $event)
|
||||||
@@ -51,12 +59,6 @@ class UserMentionsMetadataUpdater
|
|||||||
$mentioned = User::whereIn('username', array_filter($matches['username']))->get();
|
$mentioned = User::whereIn('username', array_filter($matches['username']))->get();
|
||||||
$post->mentionsUsers()->sync($mentioned);
|
$post->mentionsUsers()->sync($mentioned);
|
||||||
|
|
||||||
// @todo convert this into a new event (UserWasMentioned) and send
|
return $mentioned;
|
||||||
// notification as a handler?
|
|
||||||
foreach ($mentioned as $user) {
|
|
||||||
if ($user->id !== $post->user->id) {
|
|
||||||
$this->notifier->send(new UserMentionedNotification($post->user, $post), [$user]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user