Fixed incorrect showing of favorite groups

This commit is contained in:
BrokenEagle
2017-12-18 12:16:20 -08:00
parent 26c168bdcd
commit 3b1fdc8cde
3 changed files with 26 additions and 5 deletions

View File

@@ -237,4 +237,8 @@ class FavoriteGroup < ApplicationRecord
def editable_by?(user)
creator_id == user.id
end
def viewable_by?(user)
creator_id == user.id || !creator.hide_favorites?
end
end

View File

@@ -608,11 +608,23 @@ class Tag < ApplicationRecord
when "-favgroup"
favgroup_id = FavoriteGroup.name_to_id(g2)
favgroup = FavoriteGroup.find(favgroup_id)
if !favgroup.viewable_by?(CurrentUser.user)
raise User::PrivilegeError.new
end
q[:favgroups_neg] ||= []
q[:favgroups_neg] << favgroup_id
when "favgroup"
favgroup_id = FavoriteGroup.name_to_id(g2)
favgroup = FavoriteGroup.find(favgroup_id)
if !favgroup.viewable_by?(CurrentUser.user)
raise User::PrivilegeError.new
end
q[:favgroups] ||= []
q[:favgroups] << favgroup_id