Make storing and displaying application used to toot opt-in

This commit is contained in:
Thibaut Girka 2019-01-21 19:36:33 +01:00 committed by ThibG
parent 64cb9b6913
commit 05415fa5d3
10 changed files with 25 additions and 3 deletions

View file

@ -45,6 +45,7 @@ class Settings::PreferencesController < Settings::BaseController
:setting_hide_network, :setting_hide_network,
:setting_hide_followers_count, :setting_hide_followers_count,
:setting_aggregate_reblogs, :setting_aggregate_reblogs,
:setting_show_application,
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

@ -35,6 +35,7 @@ class UserSettingsDecorator
user.settings['skin'] = skin_preference if change?('setting_skin') user.settings['skin'] = skin_preference if change?('setting_skin')
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['show_application'] = show_application_preference if change?('setting_show_application')
end end
def merged_notification_emails def merged_notification_emails
@ -109,6 +110,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_hide_network' boolean_cast_setting 'setting_hide_network'
end end
def show_application_preference
boolean_cast_setting 'setting_show_application'
end
def default_language_preference def default_language_preference
settings['setting_default_language'] settings['setting_default_language']
end end

View file

@ -113,6 +113,7 @@ class Account < ApplicationRecord
:staff?, :staff?,
:locale, :locale,
:hides_network?, :hides_network?,
:shows_application?,
to: :user, to: :user,
prefix: true, prefix: true,
allow_nil: true allow_nil: true

View file

@ -100,7 +100,7 @@ class User < ApplicationRecord
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal, delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
:reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count, :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
: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 attr_reader :invite_code
@ -244,6 +244,10 @@ class User < ApplicationRecord
@aggregates_reblogs ||= settings.aggregate_reblogs @aggregates_reblogs ||= settings.aggregate_reblogs
end end
def shows_application?
@shows_application ||= settings.shows_application
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

@ -14,7 +14,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
attribute :local_only if :local? attribute :local_only if :local?
belongs_to :reblog, serializer: REST::StatusSerializer belongs_to :reblog, serializer: REST::StatusSerializer
belongs_to :application belongs_to :application, if: :user_shows_application?
belongs_to :account, serializer: REST::AccountSerializer belongs_to :account, serializer: REST::AccountSerializer
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
@ -40,6 +40,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
!current_user.nil? !current_user.nil?
end end
def user_shows_application?
object.account.user_shows_application?
end
def visibility def visibility
# This visibility is masked behind "private" # This visibility is masked behind "private"
# to avoid API changes because there are no # to avoid API changes because there are no

View file

@ -22,6 +22,7 @@ class PostStatusService < BaseService
@options = options @options = options
@text = @options[:text] || '' @text = @options[:text] || ''
@in_reply_to = @options[:thread] @in_reply_to = @options[:thread]
@options.delete(:application) unless @account.user&.setting_show_application
return idempotency_duplicate if idempotency_given? && idempotency_duplicate? return idempotency_duplicate if idempotency_given? && idempotency_duplicate?

View file

@ -34,6 +34,9 @@
.fields-group .fields-group
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label = f.input :setting_hide_network, as: :boolean, wrapper: :with_label
.fields-group
= f.input :setting_show_application, as: :boolean, wrapper: :with_label
- unless Setting.hide_followers_count - unless Setting.hide_followers_count
.fields-group .fields-group
= f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label = f.input :setting_hide_followers_count, as: :boolean, wrapper: :with_label

View file

@ -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 = 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) %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? - if status.application.website.blank?
%strong.detailed-status__application= status.application.name %strong.detailed-status__application= status.application.name
- else - else

View file

@ -33,6 +33,7 @@ en:
setting_display_media_show_all: Always show media marked as sensitive 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_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_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_skin: Reskins the selected Mastodon flavour setting_skin: Reskins the selected Mastodon flavour
username: Your username will be unique on %{domain} 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 whole_word: When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word
@ -102,6 +103,7 @@ en:
setting_hide_network: Hide your network setting_hide_network: Hide your network
setting_noindex: Opt-out of search engine indexing setting_noindex: Opt-out of search engine indexing
setting_reduce_motion: Reduce motion in animations setting_reduce_motion: Reduce motion in animations
setting_show_application: Disclose application used to send toots
setting_skin: Skin setting_skin: Skin
setting_system_font_ui: Use system's default font setting_system_font_ui: Use system's default font
setting_unfollow_modal: Show confirmation dialog before unfollowing someone setting_unfollow_modal: Show confirmation dialog before unfollowing someone

View file

@ -27,6 +27,7 @@ defaults: &defaults
expand_spoilers: false expand_spoilers: false
preview_sensitive_media: false preview_sensitive_media: false
reduce_motion: false reduce_motion: false
show_application: false
system_font_ui: false system_font_ui: false
noindex: false noindex: false
hide_followers_count: false hide_followers_count: false