]> cat aescling's git repositories - mastodon.git/commitdiff
Add Event activity-type support (#12637)
authorThomas Citharel <tcit@tcit.fr>
Mon, 16 Dec 2019 22:55:28 +0000 (23:55 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Mon, 16 Dec 2019 22:55:28 +0000 (23:55 +0100)
This adds support for Event AP type in Mastodon. Events are converted
into toots by taking their title (AS name) and their URL (AP ID). Event
picture is also brought in if available.

Testable by fetching event content from https://test.mobilizon.org

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
app/lib/activitypub/activity.rb
spec/services/activitypub/fetch_remote_status_service_spec.rb

index 0ca6b92a4f56d9c7283a209afbf895c76e4c5300..49b1dc9cd05cc1a575521d8a7cede782de1045a6 100644 (file)
@@ -5,7 +5,7 @@ class ActivityPub::Activity
   include Redisable
 
   SUPPORTED_TYPES = %w(Note Question).freeze
-  CONVERTED_TYPES = %w(Image Audio Video Article Page).freeze
+  CONVERTED_TYPES = %w(Image Audio Video Article Page Event).freeze
 
   def initialize(json, account, **options)
     @json    = json
index 78dd59e3b6ccb743afc2d07988025462338b0ea1..1ecc469524f3e113180aca201b2b50a395d46e82 100644 (file)
@@ -104,6 +104,26 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
       end
     end
 
+    context 'with Event object' do
+      let(:object) do
+        {
+          '@context': 'https://www.w3.org/ns/activitystreams',
+          id: "https://#{valid_domain}/@foo/1234",
+          type: 'Event',
+          name: "Let's change the world",
+          attributedTo: ActivityPub::TagManager.instance.uri_for(sender)
+        }
+      end
+
+      it 'creates status' do
+        status = sender.statuses.first
+
+        expect(status).to_not be_nil
+        expect(status.url).to eq "https://#{valid_domain}/@foo/1234"
+        expect(strip_tags(status.text)).to eq "Let's change the world https://#{valid_domain}/@foo/1234"
+      end
+    end
+
     context 'with wrong id' do
       let(:note) do
         {