diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-11-12 14:33:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 14:33:14 +0100 |
commit | 81b1d32d5b618daa4003b8de8292ae4dd3e656f6 (patch) | |
tree | 5cdf443e718788f8473148ce4d4205da54efbf04 /app/models/concerns | |
parent | d37f426f95f812b44925e13c00eabb9d1cd76b1f (diff) | |
parent | a808ac1fd8d4a42ee930bbb30cb6b58c810f828b (diff) |
Merge pull request #1920 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/account_avatar.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/account_header.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/status_threading_concern.rb | 21 |
3 files changed, 10 insertions, 15 deletions
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) |