2017-05-05 15:37:02 -04: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 19:14:30 -04:00
|
|
|
|
2017-05-05 15:37:02 -04:00
|
|
|
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def avatar_styles(file)
|
2018-02-20 21:40:12 -05:00
|
|
|
styles = { original: { geometry: '120x120#', file_geometry_parser: FastGeometryParser } }
|
2018-02-21 18:28:19 -05:00
|
|
|
styles[:static] = { geometry: '120x120#', 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 :avatar_styles
|
|
|
|
end
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Avatar upload
|
2018-02-20 21:40:12 -05:00
|
|
|
has_attached_file :avatar, styles: ->(f) { avatar_styles(f) }, convert_options: { all: '-strip' }, processors: [:lazy_thumbnail]
|
2017-05-05 15:37:02 -04:00
|
|
|
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
|
|
|
validates_attachment_size :avatar, less_than: 2.megabytes
|
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 avatar_original_url
|
|
|
|
avatar.url(:original)
|
|
|
|
end
|
2017-05-05 15:37:02 -04:00
|
|
|
|
2017-05-19 05:41:45 -04:00
|
|
|
def avatar_static_url
|
|
|
|
avatar_content_type == 'image/gif' ? avatar.url(:static) : avatar_original_url
|
2017-05-05 15:37:02 -04:00
|
|
|
end
|
|
|
|
end
|