diff --git a/ember/app/components/discussion/post-renamed.js b/ember/app/components/discussion/post-discussion-renamed.js similarity index 88% rename from ember/app/components/discussion/post-renamed.js rename to ember/app/components/discussion/post-discussion-renamed.js index dc71621d7..bd5f3c203 100644 --- a/ember/app/components/discussion/post-renamed.js +++ b/ember/app/components/discussion/post-discussion-renamed.js @@ -6,12 +6,12 @@ import HasItemLists from 'flarum/mixins/has-item-lists'; var precompileTemplate = Ember.Handlebars.compile; /** - Component for a `renamed`-typed post. + Component for a `discussionRenamed`-typed post. */ export default Ember.Component.extend(FadeIn, HasItemLists, { - layoutName: 'components/discussion/post-renamed', + layoutName: 'components/discussion/post-discussion-renamed', tagName: 'article', - classNames: ['post', 'post-renamed', 'post-activity'], + classNames: ['post', 'post-discussion-renamed', 'post-activity'], itemLists: ['controls'], // The stream-content component instansiates this component and sets the diff --git a/ember/app/styles/flarum/discussion.less b/ember/app/styles/flarum/discussion.less index a77c84206..ddf8b0dd8 100644 --- a/ember/app/styles/flarum/discussion.less +++ b/ember/app/styles/flarum/discussion.less @@ -267,7 +267,7 @@ font-size: 15px; margin-bottom: 5px; } -.post-renamed { +.post-discussion-renamed { & .old-title, & .new-title { font-weight: normal; font-style: italic; diff --git a/ember/app/templates/components/discussion/post-renamed.hbs b/ember/app/templates/components/discussion/post-discussion-renamed.hbs similarity index 100% rename from ember/app/templates/components/discussion/post-renamed.hbs rename to ember/app/templates/components/discussion/post-discussion-renamed.hbs diff --git a/src/Core/CoreServiceProvider.php b/src/Core/CoreServiceProvider.php index ae274bc75..09e63e3e6 100644 --- a/src/Core/CoreServiceProvider.php +++ b/src/Core/CoreServiceProvider.php @@ -121,7 +121,7 @@ class CoreServiceProvider extends ServiceProvider public function registerPostTypes() { Post::addType('comment', 'Flarum\Core\Models\CommentPost'); - Post::addType('renamed', 'Flarum\Core\Models\RenamedPost'); + Post::addType('discussionRenamed', 'Flarum\Core\Models\DiscussionRenamedPost'); CommentPost::setFormatter($this->app['flarum.formatter']); } diff --git a/src/Core/Handlers/Events/DiscussionRenamedNotifier.php b/src/Core/Handlers/Events/DiscussionRenamedNotifier.php index c9d326617..260616f0b 100755 --- a/src/Core/Handlers/Events/DiscussionRenamedNotifier.php +++ b/src/Core/Handlers/Events/DiscussionRenamedNotifier.php @@ -1,8 +1,8 @@ createRenamedPost($event); + $post = $this->createPost($event); $event->discussion->postWasAdded($post); - $this->createRenamedNotification($event, $post); + if ($event->discussion->start_user_id !== $event->user->id) { + $this->sendNotification($event, $post); + } } - protected function createRenamedPost(DiscussionWasRenamed $event) + protected function createPost(DiscussionWasRenamed $event) { - $post = RenamedPost::reply( + $post = DiscussionRenamedPost::reply( $event->discussion->id, $event->user->id, $event->oldTitle, @@ -40,11 +42,8 @@ class DiscussionRenamedNotifier return $post; } - protected function createRenamedNotification(DiscussionWasRenamed $event, RenamedPost $post) + protected function sendNotification(DiscussionWasRenamed $event, DiscussionRenamedPost $post) { - if ($event->discussion->start_user_id === $event->user->id) { - return false; - } $notification = Notification::notify( $event->discussion->start_user_id, diff --git a/src/Core/Models/RenamedPost.php b/src/Core/Models/DiscussionRenamedPost.php similarity index 91% rename from src/Core/Models/RenamedPost.php rename to src/Core/Models/DiscussionRenamedPost.php index 98d2133de..38ce65a9b 100755 --- a/src/Core/Models/RenamedPost.php +++ b/src/Core/Models/DiscussionRenamedPost.php @@ -1,6 +1,6 @@ time = time(); $post->discussion_id = $discussionId; $post->user_id = $userId; - $post->type = 'renamed'; + $post->type = 'discussionRenamed'; return $post; } diff --git a/src/Core/Seeders/DiscussionsTableSeeder.php b/src/Core/Seeders/DiscussionsTableSeeder.php index 81041e5c0..9dbd3c806 100644 --- a/src/Core/Seeders/DiscussionsTableSeeder.php +++ b/src/Core/Seeders/DiscussionsTableSeeder.php @@ -64,7 +64,7 @@ class DiscussionsTableSeeder extends Seeder 'discussion_id' => $discussion->id, 'time' => $startTime = date_add($startTime, date_interval_create_from_date_string('1 second')), 'user_id' => rand(1, $users), - 'type' => 'renamed', + 'type' => 'discussionRenamed', 'content' => json_encode(array($faker->realText(rand(20, 40)), $discussion->title)) ]); } else {