diff options
author | Starfall <admin@plural.cafe> | 2020-07-01 12:06:19 -0500 |
---|---|---|
committer | Starfall <admin@plural.cafe> | 2020-07-01 12:06:19 -0500 |
commit | 4d93b5c442ff5c9f4d640b4c7d543f0c04c120df (patch) | |
tree | 4df391c12dc761ac99ca6421d53d8d31870b68ec /app/lib | |
parent | 5668836f56cddf3257f38a2483c1d42cacbad3a8 (diff) | |
parent | 39a0622de70dc24275808cee9526658bd68a55ed (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 12 | ||||
-rw-r--r-- | app/lib/feed_manager.rb | 2 | ||||
-rw-r--r-- | app/lib/language_detector.rb | 2 | ||||
-rw-r--r-- | app/lib/sanitize_config.rb | 2 |
4 files changed, 14 insertions, 4 deletions
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 3509a6c40..d3d460551 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -238,12 +238,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity begin href = Addressable::URI.parse(attachment['url']).normalize.to_s - media_attachment = MediaAttachment.create(account: @account, remote_url: href, description: attachment['summary'].presence || attachment['name'].presence, focus: attachment['focalPoint'], blurhash: supported_blurhash?(attachment['blurhash']) ? attachment['blurhash'] : nil) + media_attachment = MediaAttachment.create(account: @account, remote_url: href, thumbnail_remote_url: icon_url_from_attachment(attachment), description: attachment['summary'].presence || attachment['name'].presence, focus: attachment['focalPoint'], blurhash: supported_blurhash?(attachment['blurhash']) ? attachment['blurhash'] : nil) media_attachments << media_attachment next if unsupported_media_type?(attachment['mediaType']) || skip_download? - media_attachment.file_remote_url = href + media_attachment.download_file! + media_attachment.download_thumbnail! media_attachment.save rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError RedownloadMediaWorker.perform_in(rand(30..600).seconds, media_attachment.id) @@ -256,6 +257,13 @@ class ActivityPub::Activity::Create < ActivityPub::Activity media_attachments end + def icon_url_from_attachment(attachment) + url = attachment['icon'].is_a?(Hash) ? attachment['icon']['url'] : attachment['icon'] + Addressable::URI.parse(url).normalize.to_s if url.present? + rescue Addressable::URI::InvalidURIError + nil + end + def process_poll return unless @object['type'] == 'Question' && (@object['anyOf'].is_a?(Array) || @object['oneOf'].is_a?(Array)) diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 8b3198df7..af0fa2b98 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -121,7 +121,7 @@ class FeedManager crutches = build_crutches(into_account.id, statuses) statuses.each do |status| - next if filter_from_home?(status, into_account, crutches) + next if filter_from_home?(status, into_account.id, crutches) add_to_feed(:home, into_account.id, status, aggregate) end diff --git a/app/lib/language_detector.rb b/app/lib/language_detector.rb index 05a06726d..2cc8ac615 100644 --- a/app/lib/language_detector.rb +++ b/app/lib/language_detector.rb @@ -4,7 +4,7 @@ class LanguageDetector include Singleton WORDS_THRESHOLD = 4 - RELIABLE_CHARACTERS_RE = /[\p{Hebrew}\p{Arabic}\p{Syriac}\p{Thaana}\p{Nko}\p{Han}\p{Katakana}\p{Hiragana}\p{Hangul}]+/m + RELIABLE_CHARACTERS_RE = /[\p{Hebrew}\p{Arabic}\p{Syriac}\p{Thaana}\p{Nko}\p{Han}\p{Katakana}\p{Hiragana}\p{Hangul}\p{Thai}]+/m def initialize @identifier = CLD3::NNetLanguageIdentifier.new(1, 2048) diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb index 8d094dddb..80e8f6cc7 100644 --- a/app/lib/sanitize_config.rb +++ b/app/lib/sanitize_config.rb @@ -91,6 +91,8 @@ class Sanitize 'span' => %w(class), 'abbr' => %w(title), 'blockquote' => %w(cite), + 'ol' => %w(start reversed), + 'li' => %w(value), }, add_attributes: { |