diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index b498a1ed..64de0d20 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,6 +4,7 @@ class HomeController < ApplicationController before_action :authenticate_user! before_action :set_referrer_policy_header before_action :set_initial_state_json + before_action :set_data_for_meta def index @body_classes = 'app-body' @@ -11,6 +12,25 @@ class HomeController < ApplicationController private + def set_data_for_meta + if params[:username].present? + @account = Account.find_local!(params[:username]) + elsif params[:account_username].present? + @account = Account.find_local!(params[:account_username]) + + if params[:id].present? + @status = @account.statuses.find(params[:id]) + @stream_entry = @status.stream_entry + @type = @stream_entry.activity_type.downcase + end + end + + if request.path.starts_with?('/tags') && params[:tag].present? + @tag = Tag.find_normalized!(params[:tag]) + end + + end + def authenticate_user! return if user_signed_in?