Change the way nuked users' posts are handled. Allow null in the user_id column of posts. Show these posts in the posts stream.

This commit is contained in:
Neil Lalonde
2013-09-03 17:19:29 -04:00
parent 1a6170a47c
commit 117fc8db58
16 changed files with 123 additions and 50 deletions

View File

@@ -45,7 +45,6 @@ class Post < ActiveRecord::Base
scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) }
scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) }
scope :with_topic_subtype, ->(subtype) { joins(:topic).where('topics.subtype = ?', subtype) }
scope :without_nuked_users, -> { where(nuked_user: false) }
def self.hidden_reasons
@hidden_reasons ||= Enum.new(:flag_threshold_reached, :flag_threshold_reached_again, :new_user_spam_threshold_reached)
@@ -383,7 +382,7 @@ end
# Table name: posts
#
# id :integer not null, primary key
# user_id :integer not null
# user_id :integer
# topic_id :integer not null
# post_number :integer not null
# raw :text not null
@@ -419,7 +418,6 @@ end
# notify_user_count :integer default(0), not null
# like_score :integer default(0), not null
# deleted_by_id :integer
# nuked_user :boolean default(FALSE)
#
# Indexes
#

View File

@@ -13,22 +13,22 @@ class User < ActiveRecord::Base
include Roleable
has_many :posts
has_many :notifications
has_many :topic_users
has_many :notifications, dependent: :destroy
has_many :topic_users, dependent: :destroy
has_many :topics
has_many :user_open_ids, dependent: :destroy
has_many :user_actions
has_many :post_actions
has_many :email_logs
has_many :user_actions, dependent: :destroy
has_many :post_actions, dependent: :destroy
has_many :email_logs, dependent: :destroy
has_many :post_timings
has_many :topic_allowed_users
has_many :topic_allowed_users, dependent: :destroy
has_many :topics_allowed, through: :topic_allowed_users, source: :topic
has_many :email_tokens
has_many :email_tokens, dependent: :destroy
has_many :views
has_many :user_visits
has_many :invites
has_many :topic_links
has_many :uploads
has_many :user_visits, dependent: :destroy
has_many :invites, dependent: :destroy
has_many :topic_links, dependent: :destroy
has_many :uploads, dependent: :destroy
has_one :facebook_user_info, dependent: :destroy
has_one :twitter_user_info, dependent: :destroy
@@ -37,11 +37,11 @@ class User < ActiveRecord::Base
has_one :oauth2_user_info, dependent: :destroy
belongs_to :approved_by, class_name: 'User'
has_many :group_users
has_many :group_users, dependent: :destroy
has_many :groups, through: :group_users
has_many :secure_categories, through: :groups, source: :categories
has_one :user_search_data
has_one :user_search_data, dependent: :destroy
belongs_to :uploaded_avatar, class_name: 'Upload', dependent: :destroy
@@ -61,6 +61,12 @@ class User < ActiveRecord::Base
after_create :create_email_token
before_destroy do
# These tables don't have primary keys, so destroying them with activerecord is tricky:
PostTiming.delete_all(user_id: self.id)
View.delete_all(user_id: self.id)
end
# Whether we need to be sending a system message after creation
attr_accessor :send_welcome_message