Skip to content

Commit

Permalink
Make displaying application used to toot opt-in (mastodon#9897)
Browse files Browse the repository at this point in the history
* Make storing and displaying application used to toot opt-in

* Revert to storing application info, and display it to the author via API
  • Loading branch information
ClearlyClaire authored and hiyuki2578 committed Oct 2, 2019
1 parent b6dd20c commit a65805e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/settings/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def user_settings_params
:setting_theme,
:setting_hide_network,
:setting_aggregate_reblogs,
:setting_show_application,
notification_emails: %i(follow follow_request reblog favourite mention digest report),
interactions: %i(must_be_follower must_be_following)
)
Expand Down
5 changes: 5 additions & 0 deletions app/lib/user_settings_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def process_update
user.settings['theme'] = theme_preference if change?('setting_theme')
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['show_application'] = show_application_preference if change?('setting_show_application')
end

def merged_notification_emails
Expand Down Expand Up @@ -90,6 +91,10 @@ def hide_network_preference
boolean_cast_setting 'setting_hide_network'
end

def show_application_preference
boolean_cast_setting 'setting_show_application'
end

def theme_preference
settings['setting_theme']
end
Expand Down
1 change: 1 addition & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Account < ApplicationRecord
:staff?,
:locale,
:hides_network?,
:shows_application?,
to: :user,
prefix: true,
allow_nil: true
Expand Down
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class User < ApplicationRecord

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

attr_reader :invite_code

Expand Down Expand Up @@ -244,6 +244,10 @@ def aggregates_reblogs?
@aggregates_reblogs ||= settings.aggregate_reblogs
end

def shows_application?
@shows_application ||= settings.shows_application
end

def token_for_app(a)
return nil if a.nil? || a.owner != self
Doorkeeper::AccessToken
Expand Down
6 changes: 5 additions & 1 deletion app/serializers/rest/status_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
attribute :pinned, if: :pinnable?

belongs_to :reblog, serializer: REST::StatusSerializer
belongs_to :application
belongs_to :application, if: :show_application?
belongs_to :account, serializer: REST::AccountSerializer

has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
Expand All @@ -38,6 +38,10 @@ def current_user?
!current_user.nil?
end

def show_application?
object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
end

def visibility
# This visibility is masked behind "private"
# to avoid API changes because there are no
Expand Down
3 changes: 3 additions & 0 deletions app/views/settings/preferences/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
.fields-group
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_show_application, as: :boolean, wrapper: :with_label

%hr#settings_web/

.fields-row
Expand Down
2 changes: 1 addition & 1 deletion app/views/stream_entries/_detailed_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
= link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: stream_link_target, rel: 'noopener' do
%time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at)
·
- if status.application
- if status.application && @account.user&.setting_show_application
- if status.application.website.blank?
%strong.detailed-status__application= status.application.name
- else
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ en:
setting_display_media_show_all: Always show media marked as sensitive
setting_hide_network: Who you follow and who follows you will not be shown on your profile
setting_noindex: Affects your public profile and status pages
setting_show_application: The application you use to toot will be displayed in the detailed view of your toots
setting_theme: Affects how Mastodon looks when you're logged in from any device.
username: Your username will be unique on %{domain}
whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word
Expand Down Expand Up @@ -101,6 +102,7 @@ en:
setting_hide_network: Hide your network
setting_noindex: Opt-out of search engine indexing
setting_reduce_motion: Reduce motion in animations
setting_show_application: Disclose application used to send toots
setting_system_font_ui: Use system's default font
setting_theme: Site theme
setting_unfollow_modal: Show confirmation dialog before unfollowing someone
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defaults: &defaults
expand_spoilers: false
preview_sensitive_media: false
reduce_motion: false
show_application: false
system_font_ui: false
noindex: false
theme: 'default'
Expand Down

0 comments on commit a65805e

Please sign in to comment.