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:
parent
a29080256e
commit
6358072bc0
19 changed files with 353 additions and 4 deletions
|
@ -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!
|
||||
|
|
|
@ -7,7 +7,8 @@ class ProcessMentionsService < BaseService
|
|||
# local mention pointers, send Salmon notifications to mentioned
|
||||
# remote users
|
||||
# @param [Status] status
|
||||
def call(status)
|
||||
# @param [Circle] circle
|
||||
def call(status, circle = nil)
|
||||
return unless status.local?
|
||||
|
||||
@status = status
|
||||
|
@ -41,6 +42,12 @@ class ProcessMentionsService < BaseService
|
|||
"@#{mentioned_account.acct}"
|
||||
end
|
||||
|
||||
if circle.present?
|
||||
circle.accounts.find_each do |target_account|
|
||||
status.mentions.create(silent: true, account: target_account)
|
||||
end
|
||||
end
|
||||
|
||||
status.save!
|
||||
check_for_spam(status)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue