mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 04:28:29 -05:00
update message bus to support per client filtering
start work on user_tracking_state fix can_ban? in guardian expose protected scopes on topic_query we need move guardian spec to use build as opposed to creating topics / posts / users start work on user tracking spec
This commit is contained in:
+2
-4
@@ -109,11 +109,9 @@ class Guardian
|
||||
alias :can_activate? :can_approve?
|
||||
|
||||
def can_ban?(user)
|
||||
return false if user.blank?
|
||||
return false unless @user.try(:admin?)
|
||||
return false if user.admin?
|
||||
true
|
||||
is_staff? && user && !user.staff?
|
||||
end
|
||||
|
||||
alias :can_deactivate? :can_ban?
|
||||
|
||||
def can_clear_flags?(post)
|
||||
|
||||
+13
-12
@@ -190,6 +190,19 @@ class TopicQuery
|
||||
create_list(:new_in_category) {|l| l.where(category_id: category.id).by_newest.first(25)}
|
||||
end
|
||||
|
||||
def new_results(list_opts={})
|
||||
default_list(list_opts)
|
||||
.where("topics.created_at >= :created_at", created_at: @user.treat_as_new_topic_start_date)
|
||||
.where("tu.last_read_post_number IS NULL")
|
||||
.where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
def unread_results(list_opts={})
|
||||
default_list(list_opts)
|
||||
.where("tu.last_read_post_number < topics.highest_post_number")
|
||||
.where("COALESCE(tu.notification_level, :regular) >= :tracking", regular: TopicUser.notification_levels[:regular], tracking: TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def create_list(filter, list_opts={})
|
||||
@@ -240,18 +253,6 @@ class TopicQuery
|
||||
result
|
||||
end
|
||||
|
||||
def new_results(list_opts={})
|
||||
default_list(list_opts)
|
||||
.where("topics.created_at >= :created_at", created_at: @user.treat_as_new_topic_start_date)
|
||||
.where("tu.last_read_post_number IS NULL")
|
||||
.where("COALESCE(tu.notification_level, :tracking) >= :tracking", tracking: TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
def unread_results(list_opts={})
|
||||
default_list(list_opts)
|
||||
.where("tu.last_read_post_number < topics.highest_post_number")
|
||||
.where("COALESCE(tu.notification_level, :regular) >= :tracking", regular: TopicUser.notification_levels[:regular], tracking: TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
def random_suggested_results_for(topic, count, exclude_topic_ids)
|
||||
results = default_list(unordered: true, per_page: count)
|
||||
|
||||
Reference in New Issue
Block a user