related tags: eliminate favorite_tags cookie (#3955).
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
class RelatedTagQuery
|
||||
attr_reader :query, :category, :translated_tags, :artists
|
||||
attr_reader :query, :category, :translated_tags, :artists, :user
|
||||
|
||||
def initialize(query, category: nil, translated_tags: nil, artists: nil);
|
||||
def initialize(query, category: nil, translated_tags: nil, artists: nil, user: nil)
|
||||
@user = user
|
||||
@query = TagAlias.to_aliased(query.to_s.downcase.strip).join(" ")
|
||||
@category = category
|
||||
@translated_tags = translated_tags.to_s.split
|
||||
@@ -25,6 +26,10 @@ class RelatedTagQuery
|
||||
end
|
||||
end
|
||||
|
||||
def favorite_tags
|
||||
user&.favorite_tags.to_s.split
|
||||
end
|
||||
|
||||
def wiki_page_tags
|
||||
results = wiki_page.try(:tags) || []
|
||||
results.reject! do |name|
|
||||
|
||||
@@ -28,7 +28,6 @@ class SessionLoader
|
||||
update_last_logged_in_at
|
||||
update_last_ip_addr
|
||||
set_time_zone
|
||||
store_favorite_tags_in_cookies
|
||||
CurrentUser.user.unban! if CurrentUser.user.ban_expired?
|
||||
end
|
||||
|
||||
@@ -92,14 +91,6 @@ private
|
||||
cookies[:password_hash] && cookies.signed[:user_name] && User.authenticate_cookie_hash(cookies.signed[:user_name], cookies[:password_hash])
|
||||
end
|
||||
|
||||
def store_favorite_tags_in_cookies
|
||||
if (cookies[:favorite_tags].blank? || cookies[:favorite_tags_with_categories].blank?) && CurrentUser.user.favorite_tags.present?
|
||||
favorite_tags = CurrentUser.user.favorite_tags.slice(0, 1024)
|
||||
cookies[:favorite_tags] = favorite_tags
|
||||
cookies[:favorite_tags_with_categories] = Tag.categories_for(favorite_tags.split(/[[:space:]]+/)).to_a.flatten.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
def update_last_logged_in_at
|
||||
return if CurrentUser.is_anonymous?
|
||||
return if CurrentUser.last_logged_in_at && CurrentUser.last_logged_in_at > 1.week.ago
|
||||
|
||||
Reference in New Issue
Block a user