2017-08-09 04:52:15 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActivityPub::Activity::Create < ActivityPub::Activity
|
|
|
|
def perform
|
2019-02-17 11:38:25 +09:00
|
|
|
return reject_payload! if unsupported_object_type? || invalid_origin?(@object['id']) || Tombstone.exists?(uri: @object['id']) || !related_to_local_activity?
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2017-09-15 05:26:22 +09:00
|
|
|
RedisLock.acquire(lock_options) do |lock|
|
|
|
|
if lock.acquired?
|
2019-03-04 06:18:23 +09:00
|
|
|
return if delete_arrived_first?(object_uri) || poll_vote?
|
2019-01-16 23:42:00 +09:00
|
|
|
|
2017-09-15 05:26:22 +09:00
|
|
|
@status = find_existing_status
|
2018-10-30 23:03:55 +09:00
|
|
|
|
|
|
|
if @status.nil?
|
|
|
|
process_status
|
|
|
|
elsif @options[:delivered_to_account_id].present?
|
|
|
|
postprocess_audience_and_deliver
|
|
|
|
end
|
2018-05-16 19:29:45 +09:00
|
|
|
else
|
|
|
|
raise Mastodon::RaceConditionError
|
2017-09-15 05:26:22 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@status
|
|
|
|
end
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2017-09-15 05:26:22 +09:00
|
|
|
private
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2017-09-15 05:26:22 +09:00
|
|
|
def process_status
|
2018-10-11 07:50:18 +09:00
|
|
|
@tags = []
|
|
|
|
@mentions = []
|
|
|
|
@params = {}
|
2017-12-11 00:33:52 +09:00
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
process_status_params
|
|
|
|
process_tags
|
2018-10-18 00:13:04 +09:00
|
|
|
process_audience
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
ApplicationRecord.transaction do
|
|
|
|
@status = Status.create!(@params)
|
|
|
|
attach_tags(@status)
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2017-09-15 05:26:22 +09:00
|
|
|
resolve_thread(@status)
|
2019-02-28 23:22:21 +09:00
|
|
|
fetch_replies(@status)
|
2017-09-15 05:26:22 +09:00
|
|
|
distribute(@status)
|
|
|
|
forward_for_reply if @status.public_visibility? || @status.unlisted_visibility?
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2017-08-18 04:35:00 +09:00
|
|
|
def find_existing_status
|
2017-09-02 04:00:43 +09:00
|
|
|
status = status_from_uri(object_uri)
|
2017-09-02 21:01:23 +09:00
|
|
|
status ||= Status.find_by(uri: @object['atomUri']) if @object['atomUri'].present?
|
2017-08-18 04:35:00 +09:00
|
|
|
status
|
|
|
|
end
|
|
|
|
|
2018-03-08 09:22:47 +09:00
|
|
|
def process_status_params
|
2018-10-11 07:50:18 +09:00
|
|
|
@params = begin
|
|
|
|
{
|
|
|
|
uri: @object['id'],
|
|
|
|
url: object_url || @object['id'],
|
|
|
|
account: @account,
|
|
|
|
text: text_from_content || '',
|
|
|
|
language: detected_language,
|
2019-01-17 02:36:17 +09:00
|
|
|
spoiler_text: converted_object_type? ? '' : (text_from_summary || ''),
|
2018-10-11 07:50:18 +09:00
|
|
|
created_at: @object['published'],
|
|
|
|
override_timestamps: @options[:override_timestamps],
|
|
|
|
reply: @object['inReplyTo'].present?,
|
|
|
|
sensitive: @object['sensitive'] || false,
|
|
|
|
visibility: visibility_from_audience,
|
|
|
|
thread: replied_to_status,
|
|
|
|
conversation: conversation_from_uri(@object['conversation']),
|
|
|
|
media_attachment_ids: process_attachments.take(4).map(&:id),
|
2019-03-04 06:18:23 +09:00
|
|
|
owned_poll: process_poll,
|
2018-10-11 07:50:18 +09:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-18 00:13:04 +09:00
|
|
|
def process_audience
|
|
|
|
(as_array(@object['to']) + as_array(@object['cc'])).uniq.each do |audience|
|
|
|
|
next if audience == ActivityPub::TagManager::COLLECTIONS[:public]
|
|
|
|
|
|
|
|
# Unlike with tags, there is no point in resolving accounts we don't already
|
|
|
|
# know here, because silent mentions would only be used for local access
|
|
|
|
# control anyway
|
|
|
|
account = account_from_uri(audience)
|
|
|
|
|
|
|
|
next if account.nil? || @mentions.any? { |mention| mention.account_id == account.id }
|
|
|
|
|
|
|
|
@mentions << Mention.new(account: account, silent: true)
|
|
|
|
|
|
|
|
# If there is at least one silent mention, then the status can be considered
|
2018-10-26 01:12:22 +09:00
|
|
|
# as a limited-audience status, and not strictly a direct message, but only
|
|
|
|
# if we considered a direct message in the first place
|
2018-10-18 00:13:04 +09:00
|
|
|
next unless @params[:visibility] == :direct
|
|
|
|
|
|
|
|
@params[:visibility] = :limited
|
|
|
|
end
|
2018-10-26 01:12:22 +09:00
|
|
|
|
|
|
|
# If the payload was delivered to a specific inbox, the inbox owner must have
|
|
|
|
# access to it, unless they already have access to it anyway
|
2018-10-26 19:59:59 +09:00
|
|
|
return if @options[:delivered_to_account_id].nil? || @mentions.any? { |mention| mention.account_id == @options[:delivered_to_account_id] }
|
2018-10-26 01:12:22 +09:00
|
|
|
|
|
|
|
@mentions << Mention.new(account_id: @options[:delivered_to_account_id], silent: true)
|
|
|
|
|
2018-10-26 19:59:59 +09:00
|
|
|
return unless @params[:visibility] == :direct
|
2018-10-26 01:12:22 +09:00
|
|
|
|
|
|
|
@params[:visibility] = :limited
|
2018-10-18 00:13:04 +09:00
|
|
|
end
|
|
|
|
|
2018-10-30 23:03:55 +09:00
|
|
|
def postprocess_audience_and_deliver
|
|
|
|
return if @status.mentions.find_by(account_id: @options[:delivered_to_account_id])
|
|
|
|
|
|
|
|
delivered_to_account = Account.find(@options[:delivered_to_account_id])
|
|
|
|
|
|
|
|
@status.mentions.create(account: delivered_to_account, silent: true)
|
|
|
|
@status.update(visibility: :limited) if @status.direct_visibility?
|
|
|
|
|
|
|
|
return unless delivered_to_account.following?(@account)
|
|
|
|
|
|
|
|
FeedInsertWorker.perform_async(@status.id, delivered_to_account.id, :home)
|
|
|
|
end
|
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
def attach_tags(status)
|
|
|
|
@tags.each do |tag|
|
|
|
|
status.tags << tag
|
2018-10-11 09:10:15 +09:00
|
|
|
TrendingTags.record_use!(tag, status.account, status.created_at) if status.public_visibility?
|
2018-10-11 07:50:18 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
@mentions.each do |mention|
|
|
|
|
mention.status = status
|
|
|
|
mention.save
|
|
|
|
end
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
def process_tags
|
2017-10-27 23:10:36 +09:00
|
|
|
return if @object['tag'].nil?
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2017-10-27 23:10:36 +09:00
|
|
|
as_array(@object['tag']).each do |tag|
|
2018-05-02 19:40:24 +09:00
|
|
|
if equals_or_includes?(tag['type'], 'Hashtag')
|
2018-10-11 07:50:18 +09:00
|
|
|
process_hashtag tag
|
2018-05-02 19:40:24 +09:00
|
|
|
elsif equals_or_includes?(tag['type'], 'Mention')
|
2018-10-11 07:50:18 +09:00
|
|
|
process_mention tag
|
2018-05-02 19:40:24 +09:00
|
|
|
elsif equals_or_includes?(tag['type'], 'Emoji')
|
2018-10-11 07:50:18 +09:00
|
|
|
process_emoji tag
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
def process_hashtag(tag)
|
2017-09-26 01:33:11 +09:00
|
|
|
return if tag['name'].blank?
|
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
hashtag = tag['name'].gsub(/\A#/, '').mb_chars.downcase
|
2018-10-27 05:48:35 +09:00
|
|
|
hashtag = Tag.where(name: hashtag).first_or_create!(name: hashtag)
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
return if @tags.include?(hashtag)
|
2018-05-28 12:21:04 +09:00
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
@tags << hashtag
|
2018-03-30 22:44:54 +09:00
|
|
|
rescue ActiveRecord::RecordInvalid
|
|
|
|
nil
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
def process_mention(tag)
|
2017-09-26 01:33:11 +09:00
|
|
|
return if tag['href'].blank?
|
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
account = account_from_uri(tag['href'])
|
2019-02-27 22:57:14 +09:00
|
|
|
account = ::FetchRemoteAccountService.new.call(tag['href']) if account.nil?
|
2018-10-11 07:50:18 +09:00
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
return if account.nil?
|
2018-10-11 07:50:18 +09:00
|
|
|
|
2018-10-18 00:13:04 +09:00
|
|
|
@mentions << Mention.new(account: account, silent: false)
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2018-10-11 07:50:18 +09:00
|
|
|
def process_emoji(tag)
|
2017-10-08 00:43:42 +09:00
|
|
|
return if skip_download?
|
|
|
|
return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank?
|
2017-09-26 01:33:11 +09:00
|
|
|
|
2017-09-19 09:42:40 +09:00
|
|
|
shortcode = tag['name'].delete(':')
|
2017-10-08 00:43:42 +09:00
|
|
|
image_url = tag['icon']['url']
|
|
|
|
uri = tag['id']
|
|
|
|
updated = tag['updated']
|
2017-09-19 09:42:40 +09:00
|
|
|
emoji = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain)
|
|
|
|
|
2018-11-11 07:59:51 +09:00
|
|
|
return unless emoji.nil? || image_url != emoji.image_remote_url || (updated && updated >= emoji.updated_at)
|
2017-09-19 09:42:40 +09:00
|
|
|
|
2017-10-08 00:43:42 +09:00
|
|
|
emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri)
|
|
|
|
emoji.image_remote_url = image_url
|
2017-09-19 09:42:40 +09:00
|
|
|
emoji.save
|
|
|
|
end
|
|
|
|
|
2017-12-11 00:33:52 +09:00
|
|
|
def process_attachments
|
2018-03-08 09:22:47 +09:00
|
|
|
return [] if @object['attachment'].nil?
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2017-12-11 00:33:52 +09:00
|
|
|
media_attachments = []
|
|
|
|
|
2017-10-27 23:10:36 +09:00
|
|
|
as_array(@object['attachment']).each do |attachment|
|
2018-03-29 07:52:24 +09:00
|
|
|
next if attachment['url'].blank?
|
2017-08-09 04:52:15 +09:00
|
|
|
|
|
|
|
href = Addressable::URI.parse(attachment['url']).normalize.to_s
|
2018-02-22 08:35:46 +09:00
|
|
|
media_attachment = MediaAttachment.create(account: @account, remote_url: href, description: attachment['name'].presence, focus: attachment['focalPoint'])
|
2017-12-11 00:33:52 +09:00
|
|
|
media_attachments << media_attachment
|
2017-08-09 04:52:15 +09:00
|
|
|
|
2018-03-29 07:52:24 +09:00
|
|
|
next if unsupported_media_type?(attachment['mediaType']) || skip_download?
|
2017-08-09 04:52:15 +09:00
|
|
|
|
|
|
|
media_attachment.file_remote_url = href
|
|
|
|
media_attachment.save
|
|
|
|
end
|
2017-12-11 00:33:52 +09:00
|
|
|
|
|
|
|
media_attachments
|
2017-09-26 01:33:11 +09:00
|
|
|
rescue Addressable::URI::InvalidURIError => e
|
|
|
|
Rails.logger.debug e
|
2017-12-11 00:33:52 +09:00
|
|
|
|
|
|
|
media_attachments
|
|
|
|
end
|
|
|
|
|
2019-03-04 06:18:23 +09:00
|
|
|
def process_poll
|
|
|
|
return unless @object['type'] == 'Question' && (@object['anyOf'].is_a?(Array) || @object['oneOf'].is_a?(Array))
|
|
|
|
|
|
|
|
expires_at = begin
|
|
|
|
if @object['closed'].is_a?(String)
|
|
|
|
@object['closed']
|
2019-03-04 08:44:34 +09:00
|
|
|
elsif !@object['closed'].nil? && !@object['closed'].is_a?(FalseClass)
|
2019-03-04 06:18:23 +09:00
|
|
|
Time.now.utc
|
|
|
|
else
|
|
|
|
@object['endTime']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if @object['anyOf'].is_a?(Array)
|
|
|
|
multiple = true
|
|
|
|
items = @object['anyOf']
|
|
|
|
else
|
|
|
|
multiple = false
|
|
|
|
items = @object['oneOf']
|
|
|
|
end
|
|
|
|
|
2019-03-04 09:13:42 +09:00
|
|
|
@account.polls.new(
|
2019-03-04 06:18:23 +09:00
|
|
|
multiple: multiple,
|
|
|
|
expires_at: expires_at,
|
|
|
|
options: items.map { |item| item['name'].presence || item['content'] },
|
|
|
|
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def poll_vote?
|
|
|
|
return false if replied_to_status.nil? || replied_to_status.poll.nil? || !replied_to_status.local? || !replied_to_status.poll.options.include?(@object['name'])
|
2019-03-05 06:51:23 +09:00
|
|
|
replied_to_status.poll.votes.create!(account: @account, choice: replied_to_status.poll.options.index(@object['name']), uri: @object['id'])
|
2019-03-04 06:18:23 +09:00
|
|
|
end
|
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
def resolve_thread(status)
|
2018-12-27 03:15:53 +09:00
|
|
|
return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri)
|
2017-08-27 02:55:10 +09:00
|
|
|
ThreadResolveWorker.perform_async(status.id, in_reply_to_uri)
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2019-02-28 23:22:21 +09:00
|
|
|
def fetch_replies(status)
|
|
|
|
collection = @object['replies']
|
|
|
|
return if collection.nil?
|
|
|
|
replies = ActivityPub::FetchRepliesService.new.call(status, collection, false)
|
2019-03-07 09:50:37 +09:00
|
|
|
return unless replies.nil?
|
2019-02-28 23:22:21 +09:00
|
|
|
uri = value_or_id(collection)
|
|
|
|
ActivityPub::FetchRepliesWorker.perform_async(status.id, uri) unless uri.nil?
|
|
|
|
end
|
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
def conversation_from_uri(uri)
|
|
|
|
return nil if uri.nil?
|
2017-09-20 01:08:08 +09:00
|
|
|
return Conversation.find_by(id: OStatus::TagManager.instance.unique_tag_to_local_id(uri, 'Conversation')) if OStatus::TagManager.instance.local_id?(uri)
|
2017-09-26 01:33:11 +09:00
|
|
|
Conversation.find_by(uri: uri) || Conversation.create(uri: uri)
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def visibility_from_audience
|
|
|
|
if equals_or_includes?(@object['to'], ActivityPub::TagManager::COLLECTIONS[:public])
|
|
|
|
:public
|
|
|
|
elsif equals_or_includes?(@object['cc'], ActivityPub::TagManager::COLLECTIONS[:public])
|
|
|
|
:unlisted
|
|
|
|
elsif equals_or_includes?(@object['to'], @account.followers_url)
|
|
|
|
:private
|
|
|
|
else
|
|
|
|
:direct
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def audience_includes?(account)
|
|
|
|
uri = ActivityPub::TagManager.instance.uri_for(account)
|
|
|
|
equals_or_includes?(@object['to'], uri) || equals_or_includes?(@object['cc'], uri)
|
|
|
|
end
|
|
|
|
|
|
|
|
def replied_to_status
|
2017-08-27 02:55:10 +09:00
|
|
|
return @replied_to_status if defined?(@replied_to_status)
|
|
|
|
|
|
|
|
if in_reply_to_uri.blank?
|
|
|
|
@replied_to_status = nil
|
|
|
|
else
|
|
|
|
@replied_to_status = status_from_uri(in_reply_to_uri)
|
2017-09-02 21:01:23 +09:00
|
|
|
@replied_to_status ||= status_from_uri(@object['inReplyToAtomUri']) if @object['inReplyToAtomUri'].present?
|
2017-08-27 02:55:10 +09:00
|
|
|
@replied_to_status
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def in_reply_to_uri
|
|
|
|
value_or_id(@object['inReplyTo'])
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def text_from_content
|
2019-01-17 02:36:17 +09:00
|
|
|
return Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || @object['id']].join(' ')) if converted_object_type?
|
2017-11-30 12:06:20 +09:00
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
if @object['content'].present?
|
|
|
|
@object['content']
|
2017-11-30 12:06:20 +09:00
|
|
|
elsif content_language_map?
|
2017-08-09 04:52:15 +09:00
|
|
|
@object['contentMap'].values.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-25 20:27:34 +09:00
|
|
|
def text_from_summary
|
|
|
|
if @object['summary'].present?
|
|
|
|
@object['summary']
|
|
|
|
elsif summary_language_map?
|
|
|
|
@object['summaryMap'].values.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-30 12:06:20 +09:00
|
|
|
def text_from_name
|
|
|
|
if @object['name'].present?
|
|
|
|
@object['name']
|
|
|
|
elsif name_language_map?
|
|
|
|
@object['nameMap'].values.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def detected_language
|
|
|
|
if content_language_map?
|
|
|
|
@object['contentMap'].keys.first
|
|
|
|
elsif name_language_map?
|
|
|
|
@object['nameMap'].keys.first
|
2018-08-25 20:27:34 +09:00
|
|
|
elsif summary_language_map?
|
|
|
|
@object['summaryMap'].keys.first
|
2017-11-30 12:06:20 +09:00
|
|
|
elsif supported_object_type?
|
|
|
|
LanguageDetector.instance.detect(text_from_content, @account)
|
|
|
|
end
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|
|
|
|
|
2017-09-05 01:26:33 +09:00
|
|
|
def object_url
|
|
|
|
return if @object['url'].blank?
|
2018-01-08 13:00:23 +09:00
|
|
|
|
|
|
|
url_candidate = url_to_href(@object['url'], 'text/html')
|
|
|
|
|
|
|
|
if invalid_origin?(url_candidate)
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
url_candidate
|
|
|
|
end
|
2017-09-05 01:26:33 +09:00
|
|
|
end
|
|
|
|
|
2018-08-25 20:27:34 +09:00
|
|
|
def summary_language_map?
|
|
|
|
@object['summaryMap'].is_a?(Hash) && !@object['summaryMap'].empty?
|
|
|
|
end
|
|
|
|
|
2017-11-30 12:06:20 +09:00
|
|
|
def content_language_map?
|
2017-08-09 04:52:15 +09:00
|
|
|
@object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty?
|
|
|
|
end
|
|
|
|
|
2017-11-30 12:06:20 +09:00
|
|
|
def name_language_map?
|
|
|
|
@object['nameMap'].is_a?(Hash) && !@object['nameMap'].empty?
|
|
|
|
end
|
|
|
|
|
2017-08-09 04:52:15 +09:00
|
|
|
def unsupported_media_type?(mime_type)
|
|
|
|
mime_type.present? && !(MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES).include?(mime_type)
|
|
|
|
end
|
|
|
|
|
|
|
|
def skip_download?
|
|
|
|
return @skip_download if defined?(@skip_download)
|
|
|
|
@skip_download ||= DomainBlock.find_by(domain: @account.domain)&.reject_media?
|
|
|
|
end
|
2017-08-30 22:37:02 +09:00
|
|
|
|
2018-01-08 13:00:23 +09:00
|
|
|
def invalid_origin?(url)
|
|
|
|
return true if unsupported_uri_scheme?(url)
|
|
|
|
|
|
|
|
needle = Addressable::URI.parse(url).host
|
|
|
|
haystack = Addressable::URI.parse(@account.uri).host
|
|
|
|
|
|
|
|
!haystack.casecmp(needle).zero?
|
|
|
|
end
|
|
|
|
|
2017-08-30 22:37:02 +09:00
|
|
|
def reply_to_local?
|
|
|
|
!replied_to_status.nil? && replied_to_status.account.local?
|
|
|
|
end
|
|
|
|
|
2019-02-14 02:42:47 +09:00
|
|
|
def related_to_local_activity?
|
|
|
|
fetch? || followed_by_local_accounts? || requested_through_relay? ||
|
|
|
|
responds_to_followed_account? || addresses_local_accounts?
|
|
|
|
end
|
|
|
|
|
|
|
|
def responds_to_followed_account?
|
|
|
|
!replied_to_status.nil? && (replied_to_status.account.local? || replied_to_status.account.passive_relationships.exists?)
|
|
|
|
end
|
|
|
|
|
|
|
|
def addresses_local_accounts?
|
|
|
|
return true if @options[:delivered_to_account_id]
|
|
|
|
|
|
|
|
local_usernames = (as_array(@object['to']) + as_array(@object['cc'])).uniq.select { |uri| ActivityPub::TagManager.instance.local_uri?(uri) }.map { |uri| ActivityPub::TagManager.instance.uri_to_local_id(uri, :username) }
|
|
|
|
|
|
|
|
return false if local_usernames.empty?
|
|
|
|
|
|
|
|
Account.local.where(username: local_usernames).exists?
|
|
|
|
end
|
|
|
|
|
2017-08-30 22:37:02 +09:00
|
|
|
def forward_for_reply
|
|
|
|
return unless @json['signature'].present? && reply_to_local?
|
2017-11-30 11:50:05 +09:00
|
|
|
ActivityPub::RawDistributionWorker.perform_async(Oj.dump(@json), replied_to_status.account_id, [@account.preferred_inbox_url])
|
2017-08-30 22:37:02 +09:00
|
|
|
end
|
2017-09-15 05:26:22 +09:00
|
|
|
|
|
|
|
def lock_options
|
|
|
|
{ redis: Redis.current, key: "create:#{@object['id']}" }
|
|
|
|
end
|
2017-08-09 04:52:15 +09:00
|
|
|
end
|