Browse Source

Ensure correct functionality of new ActivityPub messages

lets-bump-hometown-to-mastodon-4.2
nachtjasmin 2 years ago
parent
commit
07cfc26116
No known key found for this signature in database
  1. 44
      app/lib/activitypub/activity/create.rb

44
app/lib/activitypub/activity/create.rb

@ -111,33 +111,32 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def process_status_params
@status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url)
@params = begin
{
uri: @status_parser.uri,
url: @status_parser.url || @status_parser.uri,
account: @account,
text: text_from_content || '',
language: @status_parser.language,
spoiler_text: converted_object_type? ? '' : (@status_parser.spoiler_text || (@object['type'] == 'Article' && text_from_name) || ''),
created_at: @status_parser.created_at,
edited_at: @status_parser.edited_at && @status_parser.edited_at != @status_parser.created_at ? @status_parser.edited_at : nil,
override_timestamps: @options[:override_timestamps],
reply: @status_parser.reply,
sensitive: @account.sensitized? || @status_parser.sensitive || false,
visibility: @status_parser.visibility,
thread: replied_to_status,
conversation: conversation_from_uri(@object['conversation']),
media_attachment_ids: process_attachments.take(4).map(&:id),
poll: process_poll,
activity_pub_type: @object['type'],
}
end
@params = {
uri: @status_parser.uri,
url: @status_parser.url || @status_parser.uri,
account: @account,
text: converted_object_type? ? converted_text : (@status_parser.text || ''),
language: @status_parser.language,
spoiler_text: converted_object_type? ? '' : (@status_parser.spoiler_text || (@object['type'] == 'Article' && text_from_name) || ''),
created_at: @status_parser.created_at,
edited_at: @status_parser.edited_at && @status_parser.edited_at != @status_parser.created_at ? @status_parser.edited_at : nil,
override_timestamps: @options[:override_timestamps],
reply: @status_parser.reply,
sensitive: @account.sensitized? || @status_parser.sensitive || false,
visibility: @status_parser.visibility,
thread: replied_to_status,
conversation: conversation_from_uri(@object['conversation']),
media_attachment_ids: process_attachments.take(4).map(&:id),
poll: process_poll,
activity_pub_type: @object['type'],
}
end
class Handler < ::Ox::Sax
attr_reader :srcs, :alts
def initialize(_block)
super
@stack = []
@srcs = []
@alts = {}
@ -159,11 +158,12 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def attr(attribute_name, attribute_value)
_name, attributes = @stack.last
attributes[attribute_name] = attribute_value
attributes
end
end
def process_inline_images
proc = proc { |name| puts name }
proc = proc { |name| Rails.logger.debug name }
handler = Handler.new(proc)
Ox.sax_parse(handler, @object['content'])
handler.srcs.each do |src|

Loading…
Cancel
Save