about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-11-12 10:09:41 -0600
committerStarfall <us@starfall.systems>2022-11-12 10:11:39 -0600
commitb07b6b9f339b604f9af150eb10ac1486eca8f189 (patch)
tree512943f7488b1fdb7d7c5d87cc039ea2f1886292 /app/models
parentb96b336a7871b5e88da8f308116e8f0ca7827132 (diff)
parent81b1d32d5b618daa4003b8de8292ae4dd3e656f6 (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account/field.rb3
-rw-r--r--app/models/concerns/account_avatar.rb2
-rw-r--r--app/models/concerns/account_header.rb2
-rw-r--r--app/models/concerns/status_threading_concern.rb21
-rw-r--r--app/models/custom_emoji.rb2
-rw-r--r--app/models/media_attachment.rb2
-rw-r--r--app/models/preview_card.rb4
-rw-r--r--app/models/preview_card_provider.rb2
-rw-r--r--app/models/site_upload.rb2
9 files changed, 18 insertions, 22 deletions
diff --git a/app/models/account/field.rb b/app/models/account/field.rb
index d74f90b2b..ffc8dce80 100644
--- a/app/models/account/field.rb
+++ b/app/models/account/field.rb
@@ -3,7 +3,7 @@
 class Account::Field < ActiveModelSerializers::Model
   MAX_CHARACTERS_LOCAL  = 255
   MAX_CHARACTERS_COMPAT = 2_047
-  ACCEPTED_SCHEMES      = %w(http https).freeze
+  ACCEPTED_SCHEMES      = %w(https).freeze
 
   attributes :name, :value, :verified_at, :account
 
@@ -76,6 +76,7 @@ class Account::Field < ActiveModelSerializers::Model
   def extract_url_from_html
     doc = Nokogiri::HTML(value).at_xpath('//body')
 
+    return if doc.nil?
     return if doc.children.size > 1
 
     element = doc.children.first
diff --git a/app/models/concerns/account_avatar.rb b/app/models/concerns/account_avatar.rb
index 0cfd9167c..e9b8b4adb 100644
--- a/app/models/concerns/account_avatar.rb
+++ b/app/models/concerns/account_avatar.rb
@@ -18,7 +18,7 @@ module AccountAvatar
 
   included do
     # Avatar upload
-    has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
+    has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '+profile "!icc,*" +set modify-date +set create-date' }, processors: [:lazy_thumbnail]
     validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
     validates_attachment_size :avatar, less_than: LIMIT
     remotable_attachment :avatar, LIMIT, suppress_errors: false
diff --git a/app/models/concerns/account_header.rb b/app/models/concerns/account_header.rb
index a8c0a28ef..0d197abfc 100644
--- a/app/models/concerns/account_header.rb
+++ b/app/models/concerns/account_header.rb
@@ -19,7 +19,7 @@ module AccountHeader
 
   included do
     # Header upload
-    has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
+    has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '+profile "!icc,*" +set modify-date +set create-date' }, processors: [:lazy_thumbnail]
     validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
     validates_attachment_size :header, less_than: LIMIT
     remotable_attachment :header, LIMIT, suppress_errors: false
diff --git a/app/models/concerns/status_threading_concern.rb b/app/models/concerns/status_threading_concern.rb
index 5c04108e4..8b628beea 100644
--- a/app/models/concerns/status_threading_concern.rb
+++ b/app/models/concerns/status_threading_concern.rb
@@ -7,8 +7,8 @@ module StatusThreadingConcern
     find_statuses_from_tree_path(ancestor_ids(limit), account)
   end
 
-  def descendants(limit, account = nil, max_child_id = nil, since_child_id = nil, depth = nil)
-    find_statuses_from_tree_path(descendant_ids(limit, max_child_id, since_child_id, depth), account, promote: true)
+  def descendants(limit, account = nil, depth = nil)
+    find_statuses_from_tree_path(descendant_ids(limit, depth), account, promote: true)
   end
 
   def self_replies(limit)
@@ -50,22 +50,17 @@ module StatusThreadingConcern
     SQL
   end
 
-  def descendant_ids(limit, max_child_id, since_child_id, depth)
-    descendant_statuses(limit, max_child_id, since_child_id, depth).pluck(:id)
-  end
-
-  def descendant_statuses(limit, max_child_id, since_child_id, depth)
+  def descendant_ids(limit, depth)
     # use limit + 1 and depth + 1 because 'self' is included
     depth += 1 if depth.present?
     limit += 1 if limit.present?
 
-    descendants_with_self = Status.find_by_sql([<<-SQL.squish, id: id, limit: limit, max_child_id: max_child_id, since_child_id: since_child_id, depth: depth])
-      WITH RECURSIVE search_tree(id, path)
-      AS (
+    descendants_with_self = Status.find_by_sql([<<-SQL.squish, id: id, limit: limit, depth: depth])
+      WITH RECURSIVE search_tree(id, path) AS (
         SELECT id, ARRAY[id]
         FROM statuses
-        WHERE id = :id AND COALESCE(id < :max_child_id, TRUE) AND COALESCE(id > :since_child_id, TRUE)
-        UNION ALL
+        WHERE id = :id
+      UNION ALL
         SELECT statuses.id, path || statuses.id
         FROM search_tree
         JOIN statuses ON statuses.in_reply_to_id = search_tree.id
@@ -77,7 +72,7 @@ module StatusThreadingConcern
       LIMIT :limit
     SQL
 
-    descendants_with_self - [self]
+    descendants_with_self.pluck(:id) - [id]
   end
 
   def find_statuses_from_tree_path(ids, account, promote: false)
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb
index 5af6aead8..fc8d3aed3 100644
--- a/app/models/custom_emoji.rb
+++ b/app/models/custom_emoji.rb
@@ -38,7 +38,7 @@ class CustomEmoji < ApplicationRecord
   belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
   has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode
 
-  has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } }, validate_media_type: false
+  has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set modify-date +set create-date' } }, validate_media_type: false
 
   before_validation :downcase_domain
 
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index e29be5d97..2bab8c0b6 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -167,7 +167,7 @@ class MediaAttachment < ApplicationRecord
   }.freeze
 
   GLOBAL_CONVERT_OPTIONS = {
-    all: '-quality 90 -strip +set modify-date +set create-date',
+    all: '-quality 90 +profile "!icc,*" +set modify-date +set create-date',
   }.freeze
 
   belongs_to :account,          inverse_of: :media_attachments, optional: true
diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb
index b5d3f9c8f..56ca62d5e 100644
--- a/app/models/preview_card.rb
+++ b/app/models/preview_card.rb
@@ -50,7 +50,7 @@ class PreviewCard < ApplicationRecord
   has_and_belongs_to_many :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 80 -strip' }, validate_media_type: false
+  has_attached_file :image, processors: [:thumbnail, :blurhash_transcoder], styles: ->(f) { image_styles(f) }, convert_options: { all: '-quality 90 +profile "!icc,*" +set modify-date +set create-date' }, validate_media_type: false
 
   validates :url, presence: true, uniqueness: true
   validates_attachment_content_type :image, content_type: IMAGE_MIME_TYPES
@@ -122,7 +122,7 @@ class PreviewCard < ApplicationRecord
         original: {
           geometry: '400x400>',
           file_geometry_parser: FastGeometryParser,
-          convert_options: '-coalesce -strip',
+          convert_options: '-coalesce',
           blurhash: BLURHASH_OPTIONS,
         },
       }
diff --git a/app/models/preview_card_provider.rb b/app/models/preview_card_provider.rb
index 15b24e2bd..d61fe6020 100644
--- a/app/models/preview_card_provider.rb
+++ b/app/models/preview_card_provider.rb
@@ -25,7 +25,7 @@ class PreviewCardProvider < ApplicationRecord
 
   validates :domain, presence: true, uniqueness: true, domain: true
 
-  has_attached_file :icon, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } }, validate_media_type: false
+  has_attached_file :icon, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set modify-date +set create-date' } }, validate_media_type: false
   validates_attachment :icon, content_type: { content_type: ICON_MIME_TYPES }, size: { less_than: LIMIT }
   remotable_attachment :icon, LIMIT
 
diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb
index d3b81d4d5..167131fdd 100644
--- a/app/models/site_upload.rb
+++ b/app/models/site_upload.rb
@@ -40,7 +40,7 @@ class SiteUpload < ApplicationRecord
     mascot: {}.freeze,
   }.freeze
 
-  has_attached_file :file, styles: ->(file) { STYLES[file.instance.var.to_sym] }, convert_options: { all: '-coalesce -strip' }, processors: [:lazy_thumbnail, :blurhash_transcoder, :type_corrector]
+  has_attached_file :file, styles: ->(file) { STYLES[file.instance.var.to_sym] }, convert_options: { all: '-coalesce +profile "!icc,*" +set modify-date +set create-date' }, processors: [:lazy_thumbnail, :blurhash_transcoder, :type_corrector]
 
   validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/
   validates :file, presence: true