Add REST API for managing and posting to circles

Circles are the conceptual opposite of lists. A list is a subdivision
of your follows, a circle is a subdivision of your followers. Posting
to a circle means making content available to only some of your
followers. Circles have been internally supported in Mastodon for
the purposes of federation since #8950, this adds the REST API
necessary for making use of them in Mastodon itsef.
This commit is contained in:
Eugen Rochko 2020-07-19 02:05:16 +02:00
parent a29080256e
commit 6358072bc0
19 changed files with 353 additions and 4 deletions

View file

@ -0,0 +1,5 @@
Fabricator(:circle_account) do
circle nil
account nil
follow nil
end

View file

@ -0,0 +1,4 @@
Fabricator(:circle) do
account
title "Family"
end

View file

@ -0,0 +1,4 @@
require 'rails_helper'
RSpec.describe CircleAccount, type: :model do
end

View file

@ -0,0 +1,4 @@
require 'rails_helper'
RSpec.describe Circle, type: :model do
end

View file

@ -25,6 +25,26 @@ RSpec.describe PostStatusService, type: :service do
expect(status.thread).to eq in_reply_to_status
end
it 'creates a new status for a given circle' do
account = Fabricate(:account)
circle = Fabricate(:circle, account: account)
circle_accounts = Fabricate.times(4, :account)
circle_accounts.each do |target_account|
target_account.follow!(account)
circle.accounts << target_account
end
text = 'Circle... hello'
status = subject.call(account, text: text, circle: circle)
expect(status).to be_persisted
expect(status.text).to eq text
expect(status.visibility).to eq 'limited'
expect(status.mentions.map(&:account)).to include(*circle_accounts)
end
it 'schedules a status' do
account = Fabricate(:account)
future = Time.now.utc + 2.hours
@ -134,7 +154,7 @@ RSpec.describe PostStatusService, type: :service do
status = subject.call(account, text: "test status update")
expect(ProcessMentionsService).to have_received(:new)
expect(mention_service).to have_received(:call).with(status)
expect(mention_service).to have_received(:call).with(status, nil)
end
it 'processes hashtags' do