]> cat aescling's git repositories - mastodon.git/commitdiff
Do not misattribute inlined boosts if `attributedTo` isn't present (#10967)
authorThibG <thib@sitedethib.com>
Tue, 4 Jun 2019 21:24:31 +0000 (23:24 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 4 Jun 2019 21:24:31 +0000 (23:24 +0200)
* Do not misattribute inlined boosts if `attributedTo` isn't present

Fixes #10950

* Fix tests

app/lib/activitypub/activity.rb
spec/lib/activitypub/activity/announce_spec.rb

index 54b17561305884dd353ec1fbeaaaca8ce0c3778b..66b5763a9cf5df8af0bc908cc36d1e80291ee144 100644 (file)
@@ -143,7 +143,7 @@ class ActivityPub::Activity
 
     # If the boosted toot is embedded and it is a self-boost, handle it like a Create
     unless unsupported_object_type?
-      actor_id = value_or_id(first_of_value(@object['attributedTo'])) || @account.uri
+      actor_id = value_or_id(first_of_value(@object['attributedTo']))
 
       if actor_id == @account.uri
         return ActivityPub::Activity.factory({ 'type' => 'Create', 'actor' => actor_id, 'object' => @object }, @account).perform
index 926083a4f332c73eaca0de6884393465041a0af4..60fd96a18ac69d2687698bf0ed756d1af5bdd4f3 100644 (file)
@@ -58,21 +58,6 @@ RSpec.describe ActivityPub::Activity::Announce do
         end
       end
 
-      context 'self-boost of a previously unknown status with missing attributedTo' do
-        let(:object_json) do
-          {
-            id: 'https://example.com/actor#bar',
-            type: 'Note',
-            content: 'Lorem ipsum',
-            to: 'http://example.com/followers',
-          }
-        end
-
-        it 'creates a reblog by sender of status' do
-          expect(sender.reblogged?(sender.statuses.first)).to be true
-        end
-      end
-
       context 'self-boost of a previously unknown status with correct attributedTo' do
         let(:object_json) do
           {
@@ -122,6 +107,7 @@ RSpec.describe ActivityPub::Activity::Announce do
             type: 'Note',
             content: 'Lorem ipsum',
             to: 'http://example.com/followers',
+            attributedTo: 'https://example.com/actor',
           }
         end
 
@@ -141,6 +127,7 @@ RSpec.describe ActivityPub::Activity::Announce do
             type: 'Note',
             content: 'Lorem ipsum',
             to: 'http://example.com/followers',
+            attributedTo: 'https://example.com/actor',
           }
         end
 
@@ -161,6 +148,7 @@ RSpec.describe ActivityPub::Activity::Announce do
           type: 'Note',
           content: 'Lorem ipsum',
           to: 'http://example.com/followers',
+          attributedTo: 'https://example.com/actor',
         }
       end