Change link previews to keep original URL from the status (#27312)
This commit is contained in:
parent
9dc3ce878b
commit
0d14fcebae
19 changed files with 70 additions and 30 deletions
|
@ -50,7 +50,9 @@ class PreviewCard < ApplicationRecord
|
|||
enum type: { link: 0, photo: 1, video: 2, rich: 3 }
|
||||
enum link_type: { unknown: 0, article: 1 }
|
||||
|
||||
has_and_belongs_to_many :statuses
|
||||
has_many :preview_cards_statuses, dependent: :delete_all, inverse_of: :preview_card
|
||||
has_many :statuses, through: :preview_cards_statuses
|
||||
|
||||
has_one :trend, class_name: 'PreviewCardTrend', inverse_of: :preview_card, dependent: :destroy
|
||||
|
||||
has_attached_file :image, processors: [:thumbnail, :blurhash_transcoder], styles: ->(f) { image_styles(f) }, convert_options: { all: '-quality 90 +profile "!icc,*" +set date:modify +set date:create +set date:timestamp' }, validate_media_type: false
|
||||
|
@ -64,6 +66,9 @@ class PreviewCard < ApplicationRecord
|
|||
|
||||
before_save :extract_dimensions, if: :link?
|
||||
|
||||
# This can be set by the status when retrieving the preview card using the join model
|
||||
attr_accessor :original_url
|
||||
|
||||
def appropriate_for_trends?
|
||||
link? && article? && title.present? && description.present? && image.present? && provider_name.present?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue