has_settings.rb 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # frozen_string_literal: true
  2. module User::HasSettings
  3. extend ActiveSupport::Concern
  4. included do
  5. serialize :settings, coder: UserSettingsSerializer
  6. end
  7. def settings_attributes=(attributes)
  8. settings.update(attributes)
  9. end
  10. def prefers_noindex?
  11. settings['noindex']
  12. end
  13. def preferred_posting_language
  14. valid_locale_cascade(settings['default_language'], locale, I18n.locale)
  15. end
  16. def setting_auto_play_gif
  17. settings['web.auto_play']
  18. end
  19. def setting_default_sensitive
  20. settings['default_sensitive']
  21. end
  22. def setting_unfollow_modal
  23. settings['web.unfollow_modal']
  24. end
  25. def setting_boost_modal
  26. settings['web.reblog_modal']
  27. end
  28. def setting_delete_modal
  29. settings['web.delete_modal']
  30. end
  31. def setting_reduce_motion
  32. settings['web.reduce_motion']
  33. end
  34. def setting_system_font_ui
  35. settings['web.use_system_font']
  36. end
  37. def setting_noindex
  38. settings['noindex']
  39. end
  40. def setting_theme
  41. settings['theme']
  42. end
  43. def setting_display_media
  44. settings['web.display_media']
  45. end
  46. def setting_expand_spoilers
  47. settings['web.expand_content_warnings']
  48. end
  49. def setting_default_language
  50. settings['default_language']
  51. end
  52. def setting_aggregate_reblogs
  53. settings['aggregate_reblogs']
  54. end
  55. def setting_show_application
  56. settings['show_application']
  57. end
  58. def setting_advanced_layout
  59. settings['web.advanced_layout']
  60. end
  61. def setting_use_blurhash
  62. settings['web.use_blurhash']
  63. end
  64. def setting_use_pending_items
  65. settings['web.use_pending_items']
  66. end
  67. def setting_trends
  68. settings['web.trends']
  69. end
  70. def setting_disable_swiping
  71. settings['web.disable_swiping']
  72. end
  73. def setting_always_send_emails
  74. settings['always_send_emails']
  75. end
  76. def setting_default_privacy
  77. settings['default_privacy'] || (account.locked? ? 'private' : 'public')
  78. end
  79. def allows_report_emails?
  80. settings['notification_emails.report']
  81. end
  82. def allows_pending_account_emails?
  83. settings['notification_emails.pending_account']
  84. end
  85. def allows_appeal_emails?
  86. settings['notification_emails.appeal']
  87. end
  88. def allows_trends_review_emails?
  89. settings['notification_emails.trends']
  90. end
  91. def aggregates_reblogs?
  92. settings['aggregate_reblogs']
  93. end
  94. def shows_application?
  95. settings['show_application']
  96. end
  97. def show_all_media?
  98. settings['web.display_media'] == 'show_all'
  99. end
  100. def hide_all_media?
  101. settings['web.display_media'] == 'hide_all'
  102. end
  103. end