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

@ -15,6 +15,7 @@ class PostStatusService < BaseService
# @option [String] :spoiler_text
# @option [String] :language
# @option [String] :scheduled_at
# @option [Circle] :circle Optional circle to target the status to
# @option [Hash] :poll Optional poll to attach
# @option [Enumerable] :media_ids Optional array of media IDs to attach
# @option [Doorkeeper::Application] :application
@ -26,6 +27,7 @@ class PostStatusService < BaseService
@options = options
@text = @options[:text] || ''
@in_reply_to = @options[:thread]
@circle = @options[:circle]
return idempotency_duplicate if idempotency_given? && idempotency_duplicate?
@ -52,6 +54,7 @@ class PostStatusService < BaseService
@text = @options.delete(:spoiler_text) if @text.blank? && @options[:spoiler_text].present?
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
@visibility = :limited if @circle.present?
@scheduled_at = @options[:scheduled_at]&.to_datetime
@scheduled_at = nil if scheduled_in_the_past?
rescue ArgumentError
@ -67,7 +70,7 @@ class PostStatusService < BaseService
end
process_hashtags_service.call(@status)
process_mentions_service.call(@status)
process_mentions_service.call(@status, @circle)
end
def schedule_status!