mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 21:27:16 -05:00
FEATURE: proper mailing list mode
once enable_mailing_list_mode is enabled any user can elect to get every post via email unless they opt out of category or topic
This commit is contained in:
@@ -72,23 +72,6 @@ class TopicUser < ActiveRecord::Base
|
||||
TopicUser.where('topic_id = ? and user_id = ?', topic, user).first
|
||||
end
|
||||
|
||||
def auto_watch_new_topic(topic_id)
|
||||
# Can not afford to slow down creation of topics when a pile of users are watching new topics, reverting to SQL for max perf here
|
||||
sql = <<SQL
|
||||
INSERT INTO topic_users(user_id, topic_id, notification_level, notifications_reason_id)
|
||||
SELECT id, :topic_id, :level, :reason
|
||||
FROM users
|
||||
WHERE watch_new_topics AND
|
||||
NOT EXISTS(SELECT 1 FROM topic_users WHERE topic_id = :topic_id AND user_id = users.id)
|
||||
SQL
|
||||
|
||||
exec_sql(
|
||||
sql,
|
||||
topic_id: topic_id,
|
||||
level: notification_levels[:watching],
|
||||
reason: notification_reasons[:auto_watch]
|
||||
)
|
||||
end
|
||||
|
||||
# Change attributes for a user (creates a record when none is present). First it tries an update
|
||||
# since there's more likely to be an existing record than not. If the update returns 0 rows affected
|
||||
|
||||
@@ -83,6 +83,7 @@ class User < ActiveRecord::Base
|
||||
attr_accessor :notification_channel_position
|
||||
|
||||
scope :blocked, -> { where(blocked: true) } # no index
|
||||
scope :not_blocked, -> { where(blocked: false) } # no index
|
||||
scope :suspended, -> { where('suspended_till IS NOT NULL AND suspended_till > ?', Time.zone.now) } # no index
|
||||
scope :not_suspended, -> { where('suspended_till IS NULL') }
|
||||
# excluding fake users like the community user
|
||||
|
||||
Reference in New Issue
Block a user