BUGFIX: eliminate drafts for system user

This commit is contained in:
Sam 2014-06-25 10:55:35 +10:00
parent 48790368a0
commit 7e1bd88c33
3 changed files with 5 additions and 2 deletions

View file

@ -2,6 +2,9 @@ class DraftSequence < ActiveRecord::Base
def self.next!(user,key)
user_id = user
user_id = user.id unless user.class == Fixnum
return 0 if user_id == Discourse::SYSTEM_USER_ID
h = { user_id: user_id, draft_key: key }
c = DraftSequence.find_by(h)
c ||= DraftSequence.new(h)

View file

@ -201,7 +201,7 @@ module Discourse
user ||= User.admins.real.order(:id).first
end
SYSTEM_USER_ID = -1
SYSTEM_USER_ID = -1 unless defined? SYSTEM_USER_ID
def self.system_user
User.find_by(id: SYSTEM_USER_ID)

View file

@ -25,7 +25,7 @@ class PostRevisor
update_topic_excerpt
post_process_post
update_topic_word_counts
@post.advance_draft_sequence unless editor.id == Discourse::SYSTEM_USER_ID
@post.advance_draft_sequence
PostAlerter.new.after_save_post(@post)
publish_revision