Skip to content

Commit

Permalink
Add Event activity-type support (mastodon#12637)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
tcitworld authored and Gargron committed Dec 16, 2019
1 parent 34aa5c7 commit 8094955
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/lib/activitypub/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions spec/services/activitypub/fetch_remote_status_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@
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
{
Expand Down

0 comments on commit 8094955

Please sign in to comment.