mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:24:47 +08:00
moderators now have teeth, more at http://meta.discourse.org/t/moderator-permission-set/6307/5
allow pms to be targetted at groups
This commit is contained in:
@ -38,6 +38,10 @@ class Topic < ActiveRecord::Base
|
||||
belongs_to :category
|
||||
has_many :posts
|
||||
has_many :topic_allowed_users
|
||||
has_many :topic_allowed_groups
|
||||
|
||||
has_many :allowed_group_users, through: :allowed_groups, source: :users
|
||||
has_many :allowed_groups, through: :topic_allowed_groups, source: :group
|
||||
has_many :allowed_users, through: :topic_allowed_users, source: :user
|
||||
|
||||
has_one :hot_topic
|
||||
@ -94,6 +98,12 @@ class Topic < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# all users (in groups or directly targetted) that are going to get the pm
|
||||
def all_allowed_users
|
||||
# TODO we should probably change this from 3 queries to 1
|
||||
User.where('id in (?)', allowed_users.select('users.id').to_a + allowed_group_users.select('users.id').to_a)
|
||||
end
|
||||
|
||||
# Additional rate limits on topics: per day and private messages per day
|
||||
def limit_topics_per_day
|
||||
RateLimiter.new(user, "topics-per-day:#{Date.today.to_s}", SiteSetting.max_topics_per_day, 1.day.to_i)
|
||||
|
Reference in New Issue
Block a user