Add privacy control to user profiles

This commit is contained in:
Justin Edmund 2023-08-25 14:43:12 -07:00
parent 5562c92d46
commit 549589728e

View file

@ -63,6 +63,7 @@ module Api
.where(name_quality) .where(name_quality)
.where(user_quality) .where(user_quality)
.where(original) .where(original)
.where(privacy)
.order(created_at: :desc) .order(created_at: :desc)
.paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE) .paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE)
.each do |party| .each do |party|
@ -176,6 +177,12 @@ params['charge_attack'].to_i
"name NOT IN (#{joined_names})" "name NOT IN (#{joined_names})"
end end
def privacy
return if admin_mode
'visibility = 1' if current_user != @user
end
# Specify whitelisted properties that can be modified. # Specify whitelisted properties that can be modified.
def set def set
@user = User.find_by('lower(username) = ?', params[:id].downcase) @user = User.find_by('lower(username) = ?', params[:id].downcase)