Add support for editing for published statuses (#16697)
* Add support for editing for published statuses * Fix references to stripped-out code * Various fixes and improvements * Further fixes and improvements * Fix updates being potentially sent to unauthorized recipients * Various fixes and improvements * Fix wrong words in test * Fix notifying accounts that were tagged but were not in the audience * Fix mistake
This commit is contained in:
parent
2d1f082bb6
commit
1060666c58
56 changed files with 1415 additions and 574 deletions
58
app/lib/activitypub/parser/media_attachment_parser.rb
Normal file
58
app/lib/activitypub/parser/media_attachment_parser.rb
Normal file
|
@ -0,0 +1,58 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::Parser::MediaAttachmentParser
|
||||
include JsonLdHelper
|
||||
|
||||
def initialize(json)
|
||||
@json = json
|
||||
end
|
||||
|
||||
# @param [MediaAttachment] previous_record
|
||||
def significantly_changes?(previous_record)
|
||||
remote_url != previous_record.remote_url ||
|
||||
thumbnail_remote_url != previous_record.thumbnail_remote_url ||
|
||||
description != previous_record.description
|
||||
end
|
||||
|
||||
def remote_url
|
||||
Addressable::URI.parse(@json['url'])&.normalize&.to_s
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
nil
|
||||
end
|
||||
|
||||
def thumbnail_remote_url
|
||||
Addressable::URI.parse(@json['icon'].is_a?(Hash) ? @json['icon']['url'] : @json['icon'])&.normalize&.to_s
|
||||
rescue Addressable::URI::InvalidURIError
|
||||
nil
|
||||
end
|
||||
|
||||
def description
|
||||
@json['summary'].presence || @json['name'].presence
|
||||
end
|
||||
|
||||
def focus
|
||||
@json['focalPoint']
|
||||
end
|
||||
|
||||
def blurhash
|
||||
supported_blurhash? ? @json['blurhash'] : nil
|
||||
end
|
||||
|
||||
def file_content_type
|
||||
@json['mediaType']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def supported_blurhash?
|
||||
components = begin
|
||||
blurhash = @json['blurhash']
|
||||
|
||||
if blurhash.present? && /^[\w#$%*+-.:;=?@\[\]^{|}~]+$/.match?(blurhash)
|
||||
Blurhash.components(blurhash)
|
||||
end
|
||||
end
|
||||
|
||||
components.present? && components.none? { |comp| comp > 5 }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue