The code powering m.abunchtell.com https://m.abunchtell.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

78 行
2.0 KiB

  1. # frozen_string_literal: true
  2. class AboutController < ApplicationController
  3. layout 'public'
  4. before_action :require_open_federation!, only: [:show, :more, :blocks]
  5. before_action :check_blocklist_enabled, only: [:blocks]
  6. before_action :authenticate_user!, only: [:blocks], if: :blocklist_account_required?
  7. before_action :set_body_classes, only: :show
  8. before_action :set_instance_presenter
  9. before_action :set_expires_in, only: [:show, :more, :terms]
  10. skip_before_action :require_functional!, only: [:more, :terms]
  11. def show; end
  12. def more
  13. flash.now[:notice] = I18n.t('about.instance_actor_flash') if params[:instance_actor]
  14. end
  15. def terms; end
  16. def blocks
  17. @show_rationale = Setting.show_domain_blocks_rationale == 'all'
  18. @show_rationale |= Setting.show_domain_blocks_rationale == 'users' && !current_user.nil? && current_user.functional?
  19. @blocks = DomainBlock.with_user_facing_limitations.order('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), reject_media, domain').to_a
  20. end
  21. private
  22. def require_open_federation!
  23. not_found if whitelist_mode?
  24. end
  25. def check_blocklist_enabled
  26. not_found if Setting.show_domain_blocks == 'disabled'
  27. end
  28. def blocklist_account_required?
  29. Setting.show_domain_blocks == 'users'
  30. end
  31. def block_severity_text(block)
  32. if block.severity == 'suspend'
  33. I18n.t('domain_blocks.suspension')
  34. else
  35. limitations = []
  36. limitations << I18n.t('domain_blocks.media_block') if block.reject_media?
  37. limitations << I18n.t('domain_blocks.silence') if block.severity == 'silence'
  38. limitations.join(', ')
  39. end
  40. end
  41. helper_method :block_severity_text
  42. helper_method :public_fetch_mode?
  43. def new_user
  44. User.new.tap do |user|
  45. user.build_account
  46. user.build_invite_request
  47. end
  48. end
  49. helper_method :new_user
  50. def set_instance_presenter
  51. @instance_presenter = InstancePresenter.new
  52. end
  53. def set_body_classes
  54. @hide_navbar = true
  55. end
  56. def set_expires_in
  57. expires_in 0, public: true
  58. end
  59. end