Fixed incorrect showing of favorites
- Moved all favorite checking logic to same file
This commit is contained in:
@@ -400,12 +400,6 @@ class PostQueryBuilder
|
|||||||
|
|
||||||
if q[:ordfav].present?
|
if q[:ordfav].present?
|
||||||
user_id = q[:ordfav].to_i
|
user_id = q[:ordfav].to_i
|
||||||
user = User.find(user_id)
|
|
||||||
|
|
||||||
if user.hide_favorites?
|
|
||||||
raise User::PrivilegeError.new
|
|
||||||
end
|
|
||||||
|
|
||||||
relation = relation.joins("INNER JOIN favorites ON favorites.post_id = posts.id")
|
relation = relation.joins("INNER JOIN favorites ON favorites.post_id = posts.id")
|
||||||
relation = relation.where("favorites.user_id % 100 = ? and favorites.user_id = ?", user_id % 100, user_id).order("favorites.id DESC")
|
relation = relation.where("favorites.user_id % 100 = ? and favorites.user_id = ?", user_id % 100, user_id).order("favorites.id DESC")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -617,13 +617,31 @@ class Tag < ApplicationRecord
|
|||||||
q[:favgroups] << favgroup_id
|
q[:favgroups] << favgroup_id
|
||||||
|
|
||||||
when "-fav"
|
when "-fav"
|
||||||
|
favuser = User.find_by_name(g2)
|
||||||
|
|
||||||
|
if favuser.hide_favorites?
|
||||||
|
raise User::PrivilegeError.new
|
||||||
|
end
|
||||||
|
|
||||||
q[:tags][:exclude] << "fav:#{User.name_to_id(g2)}"
|
q[:tags][:exclude] << "fav:#{User.name_to_id(g2)}"
|
||||||
|
|
||||||
when "fav"
|
when "fav"
|
||||||
|
favuser = User.find_by_name(g2)
|
||||||
|
|
||||||
|
if favuser.hide_favorites?
|
||||||
|
raise User::PrivilegeError.new
|
||||||
|
end
|
||||||
|
|
||||||
q[:tags][:related] << "fav:#{User.name_to_id(g2)}"
|
q[:tags][:related] << "fav:#{User.name_to_id(g2)}"
|
||||||
|
|
||||||
when "ordfav"
|
when "ordfav"
|
||||||
user_id = User.name_to_id(g2)
|
user_id = User.name_to_id(g2)
|
||||||
|
favuser = User.find(user_id)
|
||||||
|
|
||||||
|
if favuser.hide_favorites?
|
||||||
|
raise User::PrivilegeError.new
|
||||||
|
end
|
||||||
|
|
||||||
q[:tags][:related] << "fav:#{user_id}"
|
q[:tags][:related] << "fav:#{user_id}"
|
||||||
q[:ordfav] = user_id
|
q[:ordfav] = user_id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user