2017-05-05 19:37:02 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module AccountAvatar
|
|
|
|
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
|
|
|
|
2019-08-17 20:04:15 +00:00
|
|
|
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
2018-03-26 12:02:10 +00:00
|
|
|
LIMIT = 2.megabytes
|
2017-05-05 19:37:02 +00:00
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def avatar_styles(file)
|
2018-03-06 05:29:01 +00:00
|
|
|
styles = { original: { geometry: '400x400#', file_geometry_parser: FastGeometryParser } }
|
|
|
|
styles[:static] = { geometry: '400x400#', 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 :avatar_styles
|
|
|
|
end
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Avatar upload
|
2018-02-21 02:40:12 +00:00
|
|
|
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
|
2017-05-05 19:37:02 +00:00
|
|
|
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
2018-03-26 12:02:10 +00:00
|
|
|
validates_attachment_size :avatar, less_than: LIMIT
|
2021-05-11 12:19:22 +00:00
|
|
|
remotable_attachment :avatar, 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 avatar_original_url
|
|
|
|
avatar.url(:original)
|
|
|
|
end
|
2017-05-05 19:37:02 +00:00
|
|
|
|
2017-05-19 09:41:45 +00:00
|
|
|
def avatar_static_url
|
|
|
|
avatar_content_type == 'image/gif' ? avatar.url(:static) : avatar_original_url
|
2017-05-05 19:37:02 +00:00
|
|
|
end
|
|
|
|
end
|