Skip to content

Commit d759684

Browse files
committed
only staff should be able to see bookmarks and favs of other users
ensure that when they click on them they see the correct topics (topics for user they are looking at, not current user)
1 parent 38e80b9 commit d759684

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

app/assets/javascripts/discourse/routes/user_routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,6 @@ Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
190190
userActionType: Discourse.UserAction.TYPES.favorites,
191191

192192
model: function() {
193-
return Discourse.TopicList.find('favorited');
193+
return Discourse.TopicList.find('favorited?user_id=' + this.modelFor('user').get('id'));
194194
}
195195
});

app/controllers/list_controller.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class ListController < ApplicationController
88
[:latest, :hot, :favorited, :read, :posted, :unread, :new].each do |filter|
99
define_method(filter) do
1010
list_opts = build_topic_list_options
11-
list = TopicQuery.new(current_user, list_opts).public_send("list_#{filter}")
11+
user = current_user
12+
if params[:user_id] && guardian.is_staff?
13+
user = User.find(params[:user_id].to_i)
14+
end
15+
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
1216
list.more_topics_url = url_for(self.public_send "#{filter}_path".to_sym, list_opts.merge(format: 'json', page: next_page))
1317

1418
respond(list)

app/models/user_action.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ def self.apply_common_filters(builder,user_id,guardian,ignore_private_messages=f
301301
builder.where("p.deleted_at is null and p2.deleted_at is null and t.deleted_at is null")
302302
end
303303

304-
unless guardian.user && guardian.user.id == user_id
305-
builder.where("a.action_type not in (#{BOOKMARK})")
304+
unless (guardian.user && guardian.user.id == user_id) || guardian.is_staff?
305+
builder.where("a.action_type not in (#{BOOKMARK},#{STAR})")
306306
end
307307

308308
if !guardian.can_see_private_messages?(user_id) || ignore_private_messages

0 commit comments

Comments
 (0)