The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 regels
948 B

  1. # frozen_string_literal: true
  2. class HomeController < ApplicationController
  3. before_action :authenticate_user!
  4. before_action :set_initial_state_json
  5. def index
  6. @body_classes = 'app-body'
  7. end
  8. private
  9. def authenticate_user!
  10. redirect_to(single_user_mode? ? account_path(Account.first) : about_path) unless user_signed_in?
  11. end
  12. def set_initial_state_json
  13. serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
  14. @initial_state_json = serializable_resource.to_json
  15. end
  16. def initial_state_params
  17. {
  18. settings: Web::Setting.find_by(user: current_user)&.data || {},
  19. push_subscription: current_account.user.web_push_subscription(current_session),
  20. current_account: current_account,
  21. token: current_session.token,
  22. admin: Account.find_local(Setting.site_contact_username),
  23. }
  24. end
  25. end