2017-05-05 19:37:02 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-12-01 11:00:41 +00:00
|
|
|
module Account::Header
|
2017-05-05 19:37:02 +00:00
|
|
|
extend ActiveSupport::Concern
|
Account domain blocks (#2381)
* Add <ostatus:conversation /> tag to Atom input/output
Only uses ref attribute (not href) because href would be
the alternate link that's always included also.
Creates new conversation for every non-reply status. Carries
over conversation for every reply. Keeps remote URIs verbatim,
generates local URIs on the fly like the rest of them.
* Conversation muting - prevents notifications that reference a conversation
(including replies, favourites, reblogs) from being created. API endpoints
/api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute
Currently no way to tell when a status/conversation is muted, so the web UI
only has a "disable notifications" button, doesn't work as a toggle
* Display "Dismiss notifications" on all statuses in notifications column, not just own
* Add "muted" as a boolean attribute on statuses JSON
For now always false on contained reblogs, since it's only relevant for
statuses returned from the notifications endpoint, which are not nested
Remove "Disable notifications" from detailed status view, since it's
only relevant in the notifications column
* Up max class length
* Remove pending test for conversation mute
* Add tests, clean up
* Rename to "mute conversation" and "unmute conversation"
* Raise validation error when trying to mute/unmute status without conversation
* Adding account domain blocks that filter notifications and public timelines
* Add tests for domain blocks in notifications, public timelines
Filter reblogs of blocked domains from home
* Add API for listing and creating account domain blocks
* API for creating/deleting domain blocks, tests for Status#ancestors
and Status#descendants, filter domain blocks from them
* Filter domains in streaming API
* Update account_domain_block_spec.rb
2017-05-18 23:14:30 +00:00
|
|
|
|
2024-11-26 21:01:52 +00:00
|
|
|
HEADER_IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
|
|
|
HEADER_LIMIT = Rails.configuration.x.use_vips ? 8.megabytes : 2.megabytes
|
2024-10-01 11:36:25 +00:00
|
|
|
HEADER_DIMENSIONS = [1500, 500].freeze
|
|
|
|
HEADER_GEOMETRY = [HEADER_DIMENSIONS.first, HEADER_DIMENSIONS.last].join('x')
|
2024-11-26 21:01:52 +00:00
|
|
|
HEADER_MAX_PIXELS = HEADER_DIMENSIONS.first * HEADER_DIMENSIONS.last
|
2017-05-05 19:37:02 +00:00
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def header_styles(file)
|
2024-11-26 21:01:52 +00:00
|
|
|
styles = { original: { pixels: HEADER_MAX_PIXELS, file_geometry_parser: FastGeometryParser } }
|
2018-07-28 17:25:33 +00:00
|
|
|
styles[:static] = { format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
2017-05-05 19:37:02 +00:00
|
|
|
styles
|
|
|
|
end
|
Account domain blocks (#2381)
* Add <ostatus:conversation /> tag to Atom input/output
Only uses ref attribute (not href) because href would be
the alternate link that's always included also.
Creates new conversation for every non-reply status. Carries
over conversation for every reply. Keeps remote URIs verbatim,
generates local URIs on the fly like the rest of them.
* Conversation muting - prevents notifications that reference a conversation
(including replies, favourites, reblogs) from being created. API endpoints
/api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute
Currently no way to tell when a status/conversation is muted, so the web UI
only has a "disable notifications" button, doesn't work as a toggle
* Display "Dismiss notifications" on all statuses in notifications column, not just own
* Add "muted" as a boolean attribute on statuses JSON
For now always false on contained reblogs, since it's only relevant for
statuses returned from the notifications endpoint, which are not nested
Remove "Disable notifications" from detailed status view, since it's
only relevant in the notifications column
* Up max class length
* Remove pending test for conversation mute
* Add tests, clean up
* Rename to "mute conversation" and "unmute conversation"
* Raise validation error when trying to mute/unmute status without conversation
* Adding account domain blocks that filter notifications and public timelines
* Add tests for domain blocks in notifications, public timelines
Filter reblogs of blocked domains from home
* Add API for listing and creating account domain blocks
* API for creating/deleting domain blocks, tests for Status#ancestors
and Status#descendants, filter domain blocks from them
* Filter domains in streaming API
* Update account_domain_block_spec.rb
2017-05-18 23:14:30 +00:00
|
|
|
|
2017-05-05 19:37:02 +00:00
|
|
|
private :header_styles
|
|
|
|
end
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Header upload
|
2023-09-25 17:21:07 +00:00
|
|
|
has_attached_file :header, styles: ->(f) { header_styles(f) }, convert_options: { all: '+profile "!icc,*" +set date:modify +set date:create +set date:timestamp' }, processors: [:lazy_thumbnail]
|
2024-11-26 21:01:52 +00:00
|
|
|
validates_attachment_content_type :header, content_type: HEADER_IMAGE_MIME_TYPES
|
|
|
|
validates_attachment_size :header, less_than: HEADER_LIMIT
|
|
|
|
remotable_attachment :header, HEADER_LIMIT, suppress_errors: false
|
2017-05-19 09:41:45 +00:00
|
|
|
end
|
2017-05-05 19:37:02 +00:00
|
|
|
|
2017-05-19 09:41:45 +00:00
|
|
|
def header_original_url
|
|
|
|
header.url(:original)
|
|
|
|
end
|
2017-05-05 19:37:02 +00:00
|
|
|
|
2017-05-19 09:41:45 +00:00
|
|
|
def header_static_url
|
|
|
|
header_content_type == 'image/gif' ? header.url(:static) : header_original_url
|
2017-05-05 19:37:02 +00:00
|
|
|
end
|
|
|
|
end
|