BUGFIX: New status posts weren't using PostCreator

This commit is contained in:
Robin Ward 2013-03-28 16:40:54 -04:00
parent 473a64d39d
commit a819a26f34
5 changed files with 17 additions and 13 deletions

View file

@ -102,12 +102,8 @@ Discourse.MessageBus = (function() {
if (failCount > 2) { if (failCount > 2) {
interval = interval * failCount; interval = interval * failCount;
} else if (isHidden()) { } else if (isHidden()) {
/* slowning down stuff a lot when hidden // slowning down stuff a lot when hidden
*/ // we will need to add a lot of fine tuning here
/* we will need to add a lot of fine tuning here
*/
interval = interval * 4; interval = interval * 4;
} }
if (interval > _this.maxPollInterval) { if (interval > _this.maxPollInterval) {

View file

@ -309,6 +309,7 @@ Discourse.TopicController = Discourse.ObjectController.extend({
})) { })) {
return; return;
} }
topic.set('posts_count', topic.get('posts_count') + 1); topic.set('posts_count', topic.get('posts_count') + 1);
topic.set('highest_post_number', data.post_number); topic.set('highest_post_number', data.post_number);
topic.set('last_poster', data.user); topic.set('last_poster', data.user);

View file

@ -322,12 +322,16 @@ class Topic < ActiveRecord::Base
def add_moderator_post(user, text, opts={}) def add_moderator_post(user, text, opts={})
new_post = nil new_post = nil
Topic.transaction do Topic.transaction do
new_post = posts.create(user: user, raw: text, post_type: Post.types[:moderator_action], no_bump: opts[:bump].blank?) creator = PostCreator.new(user,
raw: text,
post_type: Post.types[:moderator_action],
no_bump: opts[:bump].blank?,
topic_id: self.id)
new_post = creator.create
increment!(:moderator_posts_count) increment!(:moderator_posts_count)
new_post new_post
end end
if new_post.present? if new_post.present?
# If we are moving posts, we want to insert the moderator post where the previous posts were # If we are moving posts, we want to insert the moderator post where the previous posts were
# in the stream, not at the end. # in the stream, not at the end.

View file

@ -77,6 +77,9 @@ class PostCreator
post = topic.posts.new(raw: @opts[:raw], post = topic.posts.new(raw: @opts[:raw],
user: @user, user: @user,
reply_to_post_number: @opts[:reply_to_post_number]) reply_to_post_number: @opts[:reply_to_post_number])
post.post_type = @opts[:post_type] if @opts[:post_type].present?
post.no_bump = @opts[:no_bump] if @opts[:no_bump].present?
post.extract_quoted_post_numbers post.extract_quoted_post_numbers
post.image_sizes = @opts[:image_sizes] if @opts[:image_sizes].present? post.image_sizes = @opts[:image_sizes] if @opts[:image_sizes].present?