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.

37 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. class SharesController < ApplicationController
  3. layout 'modal'
  4. before_action :authenticate_user!
  5. before_action :set_pack
  6. before_action :set_body_classes
  7. def show
  8. serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
  9. @initial_state_json = serializable_resource.to_json
  10. end
  11. private
  12. def initial_state_params
  13. text = [params[:title], params[:text], params[:url]].compact.join(' ')
  14. {
  15. settings: Web::Setting.find_by(user: current_user)&.data || {},
  16. push_subscription: current_account.user.web_push_subscription(current_session),
  17. current_account: current_account,
  18. token: current_session.token,
  19. admin: Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, '')),
  20. text: text,
  21. }
  22. end
  23. def set_pack
  24. use_pack 'share'
  25. end
  26. def set_body_classes
  27. @body_classes = 'modal-layout compose-standalone'
  28. end
  29. end