diff --git a/app/controllers/related_tags_controller.rb b/app/controllers/related_tags_controller.rb index 6697aa81b..bf820b55e 100644 --- a/app/controllers/related_tags_controller.rb +++ b/app/controllers/related_tags_controller.rb @@ -3,7 +3,7 @@ class RelatedTagsController < ApplicationController before_action :require_reportbooru_key, only: [:update] def show - @query = RelatedTagQuery.new(params[:query], category: params[:category], translated_tags: params[:translated_tags], artists: params[:artists]) + @query = RelatedTagQuery.new(params[:query], category: params[:category], translated_tags: params[:translated_tags], artists: params[:artists], user: CurrentUser.user) respond_with(@query) do |format| format.json do render :json => @query.to_json diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f796cec7d..d23892c4f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -65,8 +65,6 @@ class UsersController < ApplicationController @user = User.find(params[:id]) check_privilege(@user) @user.update(user_params(:update)) - cookies.delete(:favorite_tags) - cookies.delete(:favorite_tags_with_categories) if @user.errors.any? flash[:notice] = @user.errors.full_messages.join("; ") else diff --git a/app/logical/related_tag_query.rb b/app/logical/related_tag_query.rb index aab5dec39..1464c23bf 100644 --- a/app/logical/related_tag_query.rb +++ b/app/logical/related_tag_query.rb @@ -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| diff --git a/app/logical/session_loader.rb b/app/logical/session_loader.rb index 2e9ec2257..a2903b0d8 100644 --- a/app/logical/session_loader.rb +++ b/app/logical/session_loader.rb @@ -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 diff --git a/app/views/related_tags/_related_tags.html.erb b/app/views/related_tags/_related_tags.html.erb index 66c208060..7ebb38e94 100644 --- a/app/views/related_tags/_related_tags.html.erb +++ b/app/views/related_tags/_related_tags.html.erb @@ -3,7 +3,7 @@