Compare commits

...

1 Commits

Author SHA1 Message Date
khr fe6a7dfb2c Add setting for whether to show DMS in home timeline 2019-01-21 15:08:25 -08:00
5 changed files with 12 additions and 1 deletions

View File

@ -48,6 +48,7 @@ class Settings::PreferencesController < Settings::BaseController
:setting_theme, :setting_theme,
:setting_hide_network, :setting_hide_network,
:setting_aggregate_reblogs, :setting_aggregate_reblogs,
:setting_home_dms,
notification_emails: %i(follow follow_request reblog favourite mention digest report), notification_emails: %i(follow follow_request reblog favourite mention digest report),
interactions: %i(must_be_follower must_be_following) interactions: %i(must_be_follower must_be_following)
) )

View File

@ -92,7 +92,7 @@ class FeedManager
end end
query.each do |status| query.each do |status|
next if status.direct_visibility? || status.limited_visibility? || filter?(:home, status, into_account) next if not (status.direct_visibility? && account.user&.home_dms?) || status.limited_visibility? || filter?(:home, status, into_account)
add_to_feed(:home, into_account.id, status, into_account.user&.aggregates_reblogs?) add_to_feed(:home, into_account.id, status, into_account.user&.aggregates_reblogs?)
end end

View File

@ -32,6 +32,7 @@ class UserSettingsDecorator
user.settings['theme'] = theme_preference if change?('setting_theme') user.settings['theme'] = theme_preference if change?('setting_theme')
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network') user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs') user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
user.settings['home_dms'] = aggregate_reblogs_preference if change?('home_dms')
end end
def merged_notification_emails def merged_notification_emails
@ -102,6 +103,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_aggregate_reblogs' boolean_cast_setting 'setting_aggregate_reblogs'
end end
def home_dms_preference
boolean_cast_setting 'setting_home_dms'
end
def boolean_cast_setting(key) def boolean_cast_setting(key)
ActiveModel::Type::Boolean.new.cast(settings[key]) ActiveModel::Type::Boolean.new.cast(settings[key])
end end

View File

@ -244,6 +244,10 @@ class User < ApplicationRecord
@aggregates_reblogs ||= settings.aggregate_reblogs @aggregates_reblogs ||= settings.aggregate_reblogs
end end
def home_dms?
@home_dms ||= settings.home_dms
end
def token_for_app(a) def token_for_app(a)
return nil if a.nil? || a.owner != self return nil if a.nil? || a.owner != self
Doorkeeper::AccessToken Doorkeeper::AccessToken

View File

@ -49,6 +49,7 @@
.fields-group .fields-group
= f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label = f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label
= f.input :setting_home_dms, as: :boolean, wrapper: :with_label
.fields-group .fields-group
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label = f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label