Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
- README.md
- app/helpers/statuses_helper.rb
  Upstream moved account helpers to their own file, we had extra
  helpers there, moved too.
- app/lib/sanitize_config.rb
- app/models/user.rb
- app/serializers/initial_state_serializer.rb
- config/locales/simple_form.en.yml
- spec/lib/sanitize_config_spec.rb
This commit is contained in:
Thibaut Girka
2019-10-27 12:14:01 +01:00
68 changed files with 631 additions and 454 deletions

View File

@ -153,6 +153,14 @@ class ActivityPub::Activity
fetch_remote_original_status
end
def follow_request_from_object
@follow_request ||= FollowRequest.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
end
def follow_from_object
@follow ||= Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
end
def fetch_remote_original_status
if object_uri.start_with?('http')
return if ActivityPub::TagManager.instance.local_uri?(object_uri)

View File

@ -2,17 +2,18 @@
class ActivityPub::Activity::Accept < ActivityPub::Activity
def perform
return accept_follow_for_relay if relay_follow?
return follow_request_from_object.authorize! unless follow_request_from_object.nil?
case @object['type']
when 'Follow'
accept_follow
accept_embedded_follow
end
end
private
def accept_follow
return accept_follow_for_relay if relay_follow?
def accept_embedded_follow
target_account = account_from_uri(target_uri)
return if target_account.nil? || !target_account.local?

View File

@ -2,17 +2,19 @@
class ActivityPub::Activity::Reject < ActivityPub::Activity
def perform
return reject_follow_for_relay if relay_follow?
return follow_request_from_object.reject! unless follow_request_from_object.nil?
return UnfollowService.new.call(follow_from_object.target_account, @account) unless follow_from_object.nil?
case @object['type']
when 'Follow'
reject_follow
reject_embedded_follow
end
end
private
def reject_follow
return reject_follow_for_relay if relay_follow?
def reject_embedded_follow
target_account = account_from_uri(target_uri)
return if target_account.nil? || !target_account.local?

View File

@ -337,7 +337,7 @@ class Formatter
def link_to_url(entity, options = {})
url = Addressable::URI.parse(entity[:url])
html_attrs = { target: '_blank', rel: 'nofollow noopener' }
html_attrs = { target: '_blank', rel: 'nofollow noopener noreferrer' }
html_attrs[:rel] = "me #{html_attrs[:rel]}" if options[:me]

View File

@ -50,7 +50,7 @@ class Sanitize
add_attributes: {
'a' => {
'rel' => 'nofollow noopener tag',
'rel' => 'nofollow noopener tag noreferrer',
'target' => '_blank',
},
},

View File

@ -42,6 +42,7 @@ class UserSettingsDecorator
user.settings['use_blurhash'] = use_blurhash_preference if change?('setting_use_blurhash')
user.settings['use_pending_items'] = use_pending_items_preference if change?('setting_use_pending_items')
user.settings['trends'] = trends_preference if change?('setting_trends')
user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images')
end
def merged_notification_emails
@ -152,6 +153,10 @@ class UserSettingsDecorator
boolean_cast_setting 'setting_trends'
end
def crop_images_preference
boolean_cast_setting 'setting_crop_images'
end
def boolean_cast_setting(key)
ActiveModel::Type::Boolean.new.cast(settings[key])
end