diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/lib/activitypub/tag_manager.rb | 26 | ||||
-rw-r--r-- | app/models/media_attachment.rb | 11 | ||||
-rw-r--r-- | app/serializers/manifest_serializer.rb | 2 | ||||
-rw-r--r-- | app/serializers/rest/media_attachment_serializer.rb | 2 | ||||
-rw-r--r-- | app/views/notification_mailer/_status.html.haml | 2 |
5 files changed, 20 insertions, 23 deletions
diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index f6b5e10d3..f6b9741fa 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -64,6 +64,10 @@ class ActivityPub::TagManager account_status_replies_url(target.account, target, page_params) end + def followers_uri_for(target) + target.local? ? account_followers_url(target) : target.followers_url.presence + end + # Primary audience of a status # Public statuses go out to primarily the public collection # Unlisted and private statuses go out primarily to the followers collection @@ -80,17 +84,17 @@ class ActivityPub::TagManager account_ids = status.active_mentions.pluck(:account_id) to = status.account.followers.where(id: account_ids).each_with_object([]) do |account, result| result << uri_for(account) - result << account_followers_url(account) if account.group? + result << followers_uri_for(account) if account.group? end to.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result| result << uri_for(request.account) - result << account_followers_url(request.account) if request.account.group? - end) + result << followers_uri_for(request.account) if request.account.group? + end).compact else status.active_mentions.each_with_object([]) do |mention, result| result << uri_for(mention.account) - result << account_followers_url(mention.account) if mention.account.group? - end + result << followers_uri_for(mention.account) if mention.account.group? + end.compact end end end @@ -118,17 +122,17 @@ class ActivityPub::TagManager account_ids = status.active_mentions.pluck(:account_id) cc.concat(status.account.followers.where(id: account_ids).each_with_object([]) do |account, result| result << uri_for(account) - result << account_followers_url(account) if account.group? - end) + result << followers_uri_for(account) if account.group? + end.compact) cc.concat(FollowRequest.where(target_account_id: status.account_id, account_id: account_ids).each_with_object([]) do |request, result| result << uri_for(request.account) - result << account_followers_url(request.account) if request.account.group? - end) + result << followers_uri_for(request.account) if request.account.group? + end.compact) else cc.concat(status.active_mentions.each_with_object([]) do |mention, result| result << uri_for(mention.account) - result << account_followers_url(mention.account) if mention.account.group? - end) + result << followers_uri_for(mention.account) if mention.account.group? + end.compact) end end diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index a6ab22f61..8bc4578ba 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -255,7 +255,7 @@ class MediaAttachment < ApplicationRecord after_commit :reset_parent_cache, on: :update before_create :prepare_description, unless: :local? - before_create :set_shortcode + before_create :set_unknown_type before_create :set_processing after_post_process :set_meta @@ -298,15 +298,8 @@ class MediaAttachment < ApplicationRecord private - def set_shortcode + def set_unknown_type self.type = :unknown if file.blank? && !type_changed? - - return unless local? - - loop do - self.shortcode = SecureRandom.urlsafe_base64(14) - break if MediaAttachment.find_by(shortcode: shortcode).nil? - end end def prepare_description diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb index dafe8f55b..4786aa760 100644 --- a/app/serializers/manifest_serializer.rb +++ b/app/serializers/manifest_serializer.rb @@ -48,7 +48,7 @@ class ManifestSerializer < ActiveModel::Serializer end def scope - root_url + '/' end def share_target diff --git a/app/serializers/rest/media_attachment_serializer.rb b/app/serializers/rest/media_attachment_serializer.rb index a24f95315..f27dda832 100644 --- a/app/serializers/rest/media_attachment_serializer.rb +++ b/app/serializers/rest/media_attachment_serializer.rb @@ -40,7 +40,7 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer end def text_url - object.local? ? medium_url(object) : nil + object.local? && object.shortcode.present? ? medium_url(object) : nil end def meta diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index 9b7e1b65c..31460a76e 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -37,7 +37,7 @@ %p - status.media_attachments.each do |a| - if status.local? - = link_to medium_url(a), medium_url(a) + = link_to full_asset_url(a.file.url(:original)), full_asset_url(a.file.url(:original)) - else = link_to a.remote_url, a.remote_url |