diff options
author | pluralcafe-docker <git@plural.cafe> | 2019-01-04 21:19:55 +0000 |
---|---|---|
committer | pluralcafe-docker <git@plural.cafe> | 2019-01-04 21:19:55 +0000 |
commit | 74134e490c49d8a7d88cc69720e22cd88cee9233 (patch) | |
tree | bd7fc8d41f7887037401ff86c81bc93d5fb00d01 /app/lib | |
parent | 797a8429a0deb511e6d6092edad39f856231534e (diff) | |
parent | 0acd51acdc1e670bf57f58671cb8e30743782c63 (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activitypub/activity/block.rb | 5 | ||||
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 2 | ||||
-rw-r--r-- | app/lib/activitypub/activity/flag.rb | 2 | ||||
-rw-r--r-- | app/lib/activitypub/activity/follow.rb | 2 | ||||
-rw-r--r-- | app/lib/ostatus/activity/creation.rb | 2 | ||||
-rw-r--r-- | app/lib/request.rb | 12 |
6 files changed, 18 insertions, 7 deletions
diff --git a/app/lib/activitypub/activity/block.rb b/app/lib/activitypub/activity/block.rb index 26da8bdf5..a17a2d50a 100644 --- a/app/lib/activitypub/activity/block.rb +++ b/app/lib/activitypub/activity/block.rb @@ -4,9 +4,10 @@ class ActivityPub::Activity::Block < ActivityPub::Activity def perform target_account = account_from_uri(object_uri) - return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id']) || @account.blocking?(target_account) + return if target_account.nil? || !target_account.local? || @account.blocking?(target_account) UnfollowService.new.call(target_account, @account) if target_account.following?(@account) - @account.block!(target_account, uri: @json['id']) + + @account.block!(target_account, uri: @json['id']) unless delete_arrived_first?(@json['id']) end end diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 9d2ddd3f6..2b238bc88 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -210,7 +210,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def resolve_thread(status) - return unless status.reply? && status.thread.nil? + return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri) ThreadResolveWorker.perform_async(status.id, in_reply_to_uri) end diff --git a/app/lib/activitypub/activity/flag.rb b/app/lib/activitypub/activity/flag.rb index 92e59bb81..0d10d6c3c 100644 --- a/app/lib/activitypub/activity/flag.rb +++ b/app/lib/activitypub/activity/flag.rb @@ -8,8 +8,6 @@ class ActivityPub::Activity::Flag < ActivityPub::Activity target_statuses_by_account = object_uris.map { |uri| status_from_uri(uri) }.compact.select(&:local?).group_by(&:account_id) target_accounts.each do |target_account| - next if Report.where(account: @account, target_account: target_account).exists? - target_statuses = target_statuses_by_account[target_account.id] ReportService.new.call( diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index c45832648..5e703dc61 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -28,7 +28,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity end def reject_follow_request!(target_account) - json = Oj.dump(ActivityPub::LinkedDataSignature.new(ActiveModelSerializers::SerializableResource.new(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).as_json).sign!(target_account)) + json = ActiveModelSerializers::SerializableResource.new(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), serializer: ActivityPub::RejectFollowSerializer, adapter: ActivityPub::Adapter).to_json ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url) end end diff --git a/app/lib/ostatus/activity/creation.rb b/app/lib/ostatus/activity/creation.rb index 8f8c70052..3840c8fbf 100644 --- a/app/lib/ostatus/activity/creation.rb +++ b/app/lib/ostatus/activity/creation.rb @@ -57,7 +57,7 @@ class OStatus::Activity::Creation < OStatus::Activity::Base save_emojis(status) end - if thread? && status.thread.nil? + if thread? && status.thread.nil? && Request.valid_url?(thread.second) Rails.logger.debug "Trying to attach #{status.id} (#{id}) to #{thread.first}" ThreadResolveWorker.perform_async(status.id, thread.second) end diff --git a/app/lib/request.rb b/app/lib/request.rb index 4a81773e3..ef4aeaf29 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -66,6 +66,18 @@ class Request (@account ? @headers.merge('Signature' => signature) : @headers).without(REQUEST_TARGET) end + class << self + def valid_url?(url) + begin + parsed_url = Addressable::URI.parse(url) + rescue Addressable::URI::InvalidURIError + return false + end + + %w(http https).include?(parsed_url.scheme) && parsed_url.host.present? + end + end + private def set_common_headers! |