diff --git a/extensions/tags/js/src/components/notification-discussion-moved.js b/extensions/tags/js/src/components/notification-discussion-moved.js index de61cea58..90ac47ca4 100644 --- a/extensions/tags/js/src/components/notification-discussion-moved.js +++ b/extensions/tags/js/src/components/notification-discussion-moved.js @@ -6,18 +6,11 @@ export default class NotificationDiscussionMoved extends Notification { view() { var notification = this.props.notification; var discussion = notification.subject(); - var category = discussion.category(); return super.view({ - href: app.route('discussion.near', { - id: discussion.id(), - slug: discussion.slug(), - near: notification.content().postNumber - }), - config: m.route, - title: discussion.title(), + href: app.route.discussion(discussion, notification.content().postNumber), icon: 'arrow-right', - content: ['Moved to ', categoryLabel(category), ' by ', username(notification.sender())] + content: [username(notification.sender()), ' moved to ', categoryLabel(discussion.category())] }); } } diff --git a/extensions/tags/src/DiscussionMovedNotification.php b/extensions/tags/src/DiscussionMovedNotification.php index 5c11cff6f..d10eade16 100644 --- a/extensions/tags/src/DiscussionMovedNotification.php +++ b/extensions/tags/src/DiscussionMovedNotification.php @@ -1,30 +1,39 @@ discussion = $discussion; + $this->sender = $sender; $this->post = $post; - - parent::__construct($recipient, $sender); } public function getSubject() { - return $this->post->discussion; + return $this->discussion; + } + + public function getSender() + { + return $this->sender; } public function getAlertData() { - return [ - 'postNumber' => $this->post->number - ]; + return ['postNumber' => $this->post->number]; } public static function getType() diff --git a/extensions/tags/src/Handlers/DiscussionMovedNotifier.php b/extensions/tags/src/Handlers/DiscussionMovedNotifier.php index c50ba89fa..43a25173f 100755 --- a/extensions/tags/src/Handlers/DiscussionMovedNotifier.php +++ b/extensions/tags/src/Handlers/DiscussionMovedNotifier.php @@ -32,7 +32,13 @@ class DiscussionMovedNotifier $post = $event->discussion->addPost($post); if ($event->discussion->start_user_id !== $event->user->id) { - $this->sendNotification($event, $post); + $notification = new DiscussionMovedNotification($event->discussion, $post->user, $post); + + if ($post->exists) { + $this->notifier->send($notification, [$post->discussion->startUser]); + } else { + $this->notifier->retract($notification); + } } } @@ -45,16 +51,4 @@ class DiscussionMovedNotifier $event->discussion->category_id ); } - - protected function sendNotification(DiscussionWasMoved $event, DiscussionMovedPost $post) - { - $notification = new DiscussionMovedNotification( - $event->discussion->startUser, - $event->user, - $post, - $event->discussion->category_id - ); - - $this->notifier->send($notification); - } }