Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master

This commit is contained in:
Jenkins
2018-03-09 00:17:17 +00:00
206 changed files with 2401 additions and 737 deletions

View File

@@ -43,6 +43,7 @@
# protocol :integer default("ostatus"), not null
# memorial :boolean default(FALSE), not null
# moved_to_account_id :integer
# featured_collection_url :string
#
class Account < ApplicationRecord

View File

@@ -7,8 +7,8 @@ module AccountAvatar
class_methods do
def avatar_styles(file)
styles = { original: { geometry: '120x120#', file_geometry_parser: FastGeometryParser } }
styles[:static] = { geometry: '120x120#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif'
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'
styles
end

View File

@@ -58,13 +58,14 @@ module Omniauthable
email_is_verified = auth.info.verified || auth.info.verified_email || assume_verified
email = auth.info.verified_email || auth.info.email
email = email_is_verified && !User.exists?(email: auth.info.email) && email
display_name = auth.info.full_name || [auth.info.first_name, auth.info.last_name].join(' ')
{
email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
password: Devise.friendly_token[0, 20],
account_attributes: {
username: ensure_unique_username(auth.uid),
display_name: [auth.info.first_name, auth.info.last_name].join(' '),
display_name: display_name,
},
}
end

View File

@@ -28,7 +28,11 @@ module Remotable
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/)
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1]
basename = SecureRandom.hex(8)
extname = File.extname(filename)
extname = if filename.nil?
''
else
File.extname(filename)
end
send("#{attachment_name}=", StringIO.new(response.to_s))
send("#{attachment_name}_file_name=", basename + extname)

View File

@@ -58,7 +58,7 @@ class Status < ApplicationRecord
has_one :stream_entry, as: :activity, inverse_of: :status
validates :uri, uniqueness: true, presence: true, unless: :local?
validates :text, presence: true, unless: :reblog?
validates :text, presence: true, unless: -> { with_media? || reblog? }
validates_with StatusLengthValidator
validates :reblog, uniqueness: { scope: :account }, if: :reblog?
@@ -153,8 +153,12 @@ class Status < ApplicationRecord
private_visibility? || direct_visibility?
end
def with_media?
media_attachments.any?
end
def non_sensitive_with_media?
!sensitive? && media_attachments.any?
!sensitive? && with_media?
end
def emojis

View File

@@ -44,7 +44,7 @@ class User < ApplicationRecord
ACTIVE_DURATION = 14.days
devise :two_factor_authenticatable,
otp_secret_encryption_key: ENV.fetch('OTP_SECRET')
otp_secret_encryption_key: Rails.configuration.x.otp_secret
devise :two_factor_backupable,
otp_number_of_backup_codes: 10