2017-05-05 15:37:02 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-12-01 06:00:41 -05:00
|
|
|
module Account::Header
|
2017-05-05 15:37:02 -04: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 19:14:30 -04:00
|
|
|
|
2022-05-27 14:06:40 -04:00
|
|
|
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
2018-03-26 08:02:10 -04:00
|
|
|
LIMIT = 2.megabytes
|
2018-07-28 13:25:33 -04:00
|
|
|
MAX_PIXELS = 750_000 # 1500x500px
|
2017-05-05 15:37:02 -04:00
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def header_styles(file)
|
2018-07-28 13:25:33 -04:00
|
|
|
styles = { original: { pixels: MAX_PIXELS, file_geometry_parser: FastGeometryParser } }
|
|
|
|
styles[:static] = { format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
|
2017-05-05 15:37:02 -04: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 19:14:30 -04:00
|
|
|
|
2017-05-05 15:37:02 -04:00
|
|
|
private :header_styles
|
|
|
|
end
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Header upload
|
2023-09-25 13:21:07 -04: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]
|
2017-05-05 15:37:02 -04:00
|
|
|
validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
|
2018-03-26 08:02:10 -04:00
|
|
|
validates_attachment_size :header, less_than: LIMIT
|
2021-05-11 08:19:22 -04:00
|
|
|
remotable_attachment :header, LIMIT, suppress_errors: false
|
2017-05-19 05:41:45 -04:00
|
|
|
end
|
2017-05-05 15:37:02 -04:00
|
|
|
|
2017-05-19 05:41:45 -04:00
|
|
|
def header_original_url
|
|
|
|
header.url(:original)
|
|
|
|
end
|
2017-05-05 15:37:02 -04:00
|
|
|
|
2017-05-19 05:41:45 -04:00
|
|
|
def header_static_url
|
|
|
|
header_content_type == 'image/gif' ? header.url(:static) : header_original_url
|
2017-05-05 15:37:02 -04:00
|
|
|
end
|
|
|
|
end
|