Skip to content

Commit 81a795b

Browse files
ClearlyClaireGargron
authored andcommitted
Make displaying application used to toot opt-in (mastodon#9897)
* Make storing and displaying application used to toot opt-in * Revert to storing application info, and display it to the author via API
1 parent 5b0f970 commit 81a795b

9 files changed

Lines changed: 24 additions & 3 deletions

File tree

app/controllers/settings/preferences_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def user_settings_params
4848
:setting_theme,
4949
:setting_hide_network,
5050
:setting_aggregate_reblogs,
51+
:setting_show_application,
5152
notification_emails: %i(follow follow_request reblog favourite mention digest report),
5253
interactions: %i(must_be_follower must_be_following)
5354
)

app/lib/user_settings_decorator.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def process_update
3232
user.settings['theme'] = theme_preference if change?('setting_theme')
3333
user.settings['hide_network'] = hide_network_preference if change?('setting_hide_network')
3434
user.settings['aggregate_reblogs'] = aggregate_reblogs_preference if change?('setting_aggregate_reblogs')
35+
user.settings['show_application'] = show_application_preference if change?('setting_show_application')
3536
end
3637

3738
def merged_notification_emails
@@ -90,6 +91,10 @@ def hide_network_preference
9091
boolean_cast_setting 'setting_hide_network'
9192
end
9293

94+
def show_application_preference
95+
boolean_cast_setting 'setting_show_application'
96+
end
97+
9398
def theme_preference
9499
settings['setting_theme']
95100
end

app/models/account.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class Account < ApplicationRecord
109109
:staff?,
110110
:locale,
111111
:hides_network?,
112+
:shows_application?,
112113
to: :user,
113114
prefix: true,
114115
allow_nil: true

app/models/user.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class User < ApplicationRecord
100100

101101
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
102102
:reduce_motion, :system_font_ui, :noindex, :theme, :display_media, :hide_network,
103-
:expand_spoilers, :default_language, :aggregate_reblogs, to: :settings, prefix: :setting, allow_nil: false
103+
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application, to: :settings, prefix: :setting, allow_nil: false
104104

105105
attr_reader :invite_code
106106

@@ -244,6 +244,10 @@ def aggregates_reblogs?
244244
@aggregates_reblogs ||= settings.aggregate_reblogs
245245
end
246246

247+
def shows_application?
248+
@shows_application ||= settings.shows_application
249+
end
250+
247251
def token_for_app(a)
248252
return nil if a.nil? || a.owner != self
249253
Doorkeeper::AccessToken

app/serializers/rest/status_serializer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
1212
attribute :pinned, if: :pinnable?
1313

1414
belongs_to :reblog, serializer: REST::StatusSerializer
15-
belongs_to :application
15+
belongs_to :application, if: :show_application?
1616
belongs_to :account, serializer: REST::AccountSerializer
1717

1818
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
@@ -38,6 +38,10 @@ def current_user?
3838
!current_user.nil?
3939
end
4040

41+
def show_application?
42+
object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
43+
end
44+
4145
def visibility
4246
# This visibility is masked behind "private"
4347
# to avoid API changes because there are no

app/views/settings/preferences/show.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
.fields-group
3535
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label
3636

37+
.fields-group
38+
= f.input :setting_show_application, as: :boolean, wrapper: :with_label
39+
3740
%hr#settings_web/
3841

3942
.fields-row

app/views/stream_entries/_detailed_status.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
= link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: stream_link_target, rel: 'noopener' do
4040
%time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at)
4141
·
42-
- if status.application
42+
- if status.application && @account.user&.setting_show_application
4343
- if status.application.website.blank?
4444
%strong.detailed-status__application= status.application.name
4545
- else

config/locales/simple_form.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ en:
3333
setting_display_media_show_all: Always show media marked as sensitive
3434
setting_hide_network: Who you follow and who follows you will not be shown on your profile
3535
setting_noindex: Affects your public profile and status pages
36+
setting_show_application: The application you use to toot will be displayed in the detailed view of your toots
3637
setting_theme: Affects how Mastodon looks when you're logged in from any device.
3738
username: Your username will be unique on %{domain}
3839
whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word
@@ -100,6 +101,7 @@ en:
100101
setting_hide_network: Hide your network
101102
setting_noindex: Opt-out of search engine indexing
102103
setting_reduce_motion: Reduce motion in animations
104+
setting_show_application: Disclose application used to send toots
103105
setting_system_font_ui: Use system's default font
104106
setting_theme: Site theme
105107
setting_unfollow_modal: Show confirmation dialog before unfollowing someone

config/settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ defaults: &defaults
2626
expand_spoilers: false
2727
preview_sensitive_media: false
2828
reduce_motion: false
29+
show_application: false
2930
system_font_ui: false
3031
noindex: false
3132
theme: 'default'

0 commit comments

Comments
 (0)