diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/accounts_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 1 |
5 files changed, 33 insertions, 1 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 3937e9e8a..f29be82c9 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -29,10 +29,10 @@ class AccountsController < ApplicationController return end - @pinned_statuses = cache_collection(pinned_statuses, Status) if show_pinned_statuses? @statuses = filtered_status_page(params) @statuses = cache_collection(@statuses, Status) + @rss_url = rss_url unless @statuses.empty? @older_url = older_url if @statuses.last.id > filtered_statuses.last.id @@ -40,6 +40,18 @@ class AccountsController < ApplicationController end end + format.rss do + expires_in 1.minute, public: true + + if current_account&.user&.allows_rss? + @statuses = filtered_statuses.without_reblogs.without_replies.limit(PAGE_SIZE) + @statuses = cache_collection(@statuses, Status) + else + @statuses = [] + end + render xml: RSS::AccountSerializer.render(@account, @statuses, params[:tag]) + end + format.json do expires_in 3.minutes, public: !(authorized_fetch_mode? && signed_request_account.present?) render json: @account, content_type: 'application/activity+json', serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, fields: restrict_fields_to @@ -106,6 +118,14 @@ class AccountsController < ApplicationController params[:username] end + def rss_url + if tag_requested? + short_account_tag_url(@account, params[:tag], format: 'rss') + else + short_account_url(@account, format: 'rss') + end + end + def older_url pagination_url(max_id: @statuses.last.id) end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index c91f40d26..e5a122de0 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -98,6 +98,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_boost_interval_from, :setting_boost_interval_to, :setting_show_cursor, + :setting_allow_rss, :setting_default_privacy, :setting_default_sensitive, diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 56a35a8af..560700899 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -52,6 +52,7 @@ class UserSettingsDecorator user.settings['boost_interval_from'] = boost_interval_from_preference if change?('setting_boost_interval_from') user.settings['boost_interval_to'] = boost_interval_to_preference if change?('setting_boost_interval_to') user.settings['show_cursor'] = show_cursor_preference if change?('setting_show_cursor') + user.settings['allow_rss'] = allow_rss_preference if change?('setting_allow_rss') user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails') user.settings['interactions'] = merged_interactions if change?('interactions') @@ -207,6 +208,10 @@ class UserSettingsDecorator settings['setting_delayed_for'] end + def allow_rss_preference + boolean_cast_setting['setting_allow_rss'] + end + def merged_notification_emails user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h end diff --git a/app/models/user.rb b/app/models/user.rb index 45eb33a1c..29946b826 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -159,6 +159,7 @@ class User < ApplicationRecord :boost_interval_from, :boost_interval_to, :show_cursor, + :allow_rss, :auto_play_gif, :default_sensitive, @@ -386,6 +387,10 @@ class User < ApplicationRecord @show_cursor ||= (settings.show_cursor || false) end + def allows_rss? + @allows_rss ||= (setting.allow_rss || false) + end + def defaults_to_local_only? @defaults_to_local_only ||= (settings.default_local || false) end diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 97ac59975..d9262fb3b 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -39,6 +39,7 @@ = f.input :setting_always_local, as: :boolean, wrapper: :with_label = f.input :setting_hide_public_profile, as: :boolean, wrapper: :with_label = f.input :setting_hide_public_outbox, as: :boolean, wrapper: :with_label + = f.input :setting_allow_rss, as: :boolean, wrapper: :with_label %hr/ |