Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - app/controllers/home_controller.rb - app/controllers/shares_controller.rb - app/javascript/packs/public.js - app/models/status.rb - app/serializers/initial_state_serializer.rb - app/views/home/index.html.haml - app/views/layouts/public.html.haml - app/views/public_timelines/show.html.haml - app/views/shares/show.html.haml - app/views/tags/show.html.haml - config/initializers/content_security_policy.rb - config/locales/en.yml - config/webpack/shared.js - package.json
This commit is contained in:
@@ -131,6 +131,8 @@ class Account < ApplicationRecord
|
||||
|
||||
delegate :chosen_languages, to: :user, prefix: false, allow_nil: true
|
||||
|
||||
update_index('accounts#account', :self) if Chewy.enabled?
|
||||
|
||||
def local?
|
||||
domain.nil?
|
||||
end
|
||||
@@ -173,6 +175,10 @@ class Account < ApplicationRecord
|
||||
subscription_expires_at.present?
|
||||
end
|
||||
|
||||
def searchable?
|
||||
!(suspended? || moved?)
|
||||
end
|
||||
|
||||
def possibly_stale?
|
||||
last_webfingered_at.nil? || last_webfingered_at <= 1.day.ago
|
||||
end
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
class AccountStat < ApplicationRecord
|
||||
belongs_to :account, inverse_of: :account_stat
|
||||
|
||||
update_index('accounts#account', :account) if Chewy.enabled?
|
||||
|
||||
def increment_count!(key)
|
||||
update(attributes_for_increment(key))
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module AccountAvatar
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
|
||||
class_methods do
|
||||
|
||||
@@ -26,7 +26,8 @@ module AccountCounters
|
||||
private
|
||||
|
||||
def save_account_stat
|
||||
return unless account_stat&.changed?
|
||||
return unless association(:account_stat).loaded? && account_stat&.changed?
|
||||
|
||||
account_stat.save
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
module AccountHeader
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
||||
LIMIT = 2.megabytes
|
||||
MAX_PIXELS = 750_000 # 1500x500px
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ module Attachmentable
|
||||
|
||||
width, height = FastImage.size(attachment.queued_for_write[:original].path)
|
||||
|
||||
raise Mastodon::DimensionsValidationError, "#{width}x#{height} images are not supported" if width.present? && height.present? && (width * height >= MAX_MATRIX_LIMIT)
|
||||
raise Mastodon::DimensionsValidationError, "#{width}x#{height} images are not supported, must be below #{MAX_MATRIX_LIMIT} sqpx" if width.present? && height.present? && (width * height >= MAX_MATRIX_LIMIT)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class CustomEmoji < ApplicationRecord
|
||||
:(#{SHORTCODE_RE_FRAGMENT}):
|
||||
(?=[^[:alnum:]:]|$)/x
|
||||
|
||||
IMAGE_MIME_TYPES = %w(image/png image/gif image/webp).freeze
|
||||
IMAGE_MIME_TYPES = %w(image/png image/gif).freeze
|
||||
|
||||
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
|
||||
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode
|
||||
|
||||
@@ -25,6 +25,7 @@ class DomainBlock < ApplicationRecord
|
||||
delegate :count, to: :accounts, prefix: true
|
||||
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
scope :with_user_facing_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)) }
|
||||
|
||||
class << self
|
||||
def suspend?(domain)
|
||||
|
||||
@@ -36,6 +36,8 @@ class Form::AdminSettings
|
||||
show_replies_in_public_timelines
|
||||
spam_check_enabled
|
||||
trends
|
||||
show_domain_blocks
|
||||
show_domain_blocks_rationale
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
@@ -74,6 +76,8 @@ class Form::AdminSettings
|
||||
validates :site_contact_email, :site_contact_username, presence: true
|
||||
validates :site_contact_username, existing_username: true
|
||||
validates :bootstrap_timeline_accounts, existing_username: { multiple: true }
|
||||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }
|
||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }
|
||||
|
||||
def initialize(_attributes = {})
|
||||
super
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# autofollow :boolean default(FALSE), not null
|
||||
# comment :text
|
||||
#
|
||||
|
||||
class Invite < ApplicationRecord
|
||||
@@ -22,6 +23,8 @@ class Invite < ApplicationRecord
|
||||
|
||||
scope :available, -> { where(expires_at: nil).or(where('expires_at >= ?', Time.now.utc)) }
|
||||
|
||||
validates :comment, length: { maximum: 420 }
|
||||
|
||||
before_validation :set_code
|
||||
|
||||
def valid_for_use?
|
||||
|
||||
@@ -26,11 +26,11 @@ class MediaAttachment < ApplicationRecord
|
||||
|
||||
enum type: [:image, :gifv, :video, :unknown, :audio]
|
||||
|
||||
IMAGE_FILE_EXTENSIONS = %w(.jpg .jpeg .png .gif .webp).freeze
|
||||
IMAGE_FILE_EXTENSIONS = %w(.jpg .jpeg .png .gif).freeze
|
||||
VIDEO_FILE_EXTENSIONS = %w(.webm .mp4 .m4v .mov).freeze
|
||||
AUDIO_FILE_EXTENSIONS = %w(.ogg .oga .mp3 .wav .flac .opus .aac .m4a .3gp).freeze
|
||||
|
||||
IMAGE_MIME_TYPES = %w(image/jpeg image/png image/gif image/webp).freeze
|
||||
IMAGE_MIME_TYPES = %w(image/jpeg image/png image/gif).freeze
|
||||
VIDEO_MIME_TYPES = %w(video/webm video/mp4 video/quicktime video/ogg).freeze
|
||||
VIDEO_CONVERTIBLE_MIME_TYPES = %w(video/webm video/quicktime).freeze
|
||||
AUDIO_MIME_TYPES = %w(audio/wave audio/wav audio/x-wav audio/x-pn-wave audio/ogg audio/mpeg audio/mp3 audio/webm audio/flac audio/aac audio/m4a audio/3gpp).freeze
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#
|
||||
|
||||
class PreviewCard < ApplicationRecord
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif'].freeze
|
||||
LIMIT = 1.megabytes
|
||||
|
||||
self.inheritance_column = false
|
||||
|
||||
@@ -455,13 +455,16 @@ class Status < ApplicationRecord
|
||||
'👁'
|
||||
end
|
||||
|
||||
def status_stat
|
||||
super || build_status_stat
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_status_stat!(attrs)
|
||||
return if marked_for_destruction? || destroyed?
|
||||
|
||||
record = status_stat || build_status_stat
|
||||
record.update(attrs)
|
||||
status_stat.update(attrs)
|
||||
end
|
||||
|
||||
def store_uri
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# listable :boolean
|
||||
# reviewed_at :datetime
|
||||
# requested_review_at :datetime
|
||||
# last_status_at :datetime
|
||||
# last_trend_at :datetime
|
||||
#
|
||||
|
||||
class Tag < ApplicationRecord
|
||||
@@ -33,7 +35,8 @@ class Tag < ApplicationRecord
|
||||
scope :unreviewed, -> { where(reviewed_at: nil) }
|
||||
scope :pending_review, -> { unreviewed.where.not(requested_review_at: nil) }
|
||||
scope :usable, -> { where(usable: [true, nil]) }
|
||||
scope :discoverable, -> { where(listable: [true, nil]).joins(:account_tag_stat).where(AccountTagStat.arel_table[:accounts_count].gt(0)).order(Arel.sql('account_tag_stats.accounts_count desc')) }
|
||||
scope :listable, -> { where(listable: [true, nil]) }
|
||||
scope :discoverable, -> { listable.joins(:account_tag_stat).where(AccountTagStat.arel_table[:accounts_count].gt(0)).order(Arel.sql('account_tag_stats.accounts_count desc')) }
|
||||
scope :most_used, ->(account) { joins(:statuses).where(statuses: { account: account }).group(:id).order(Arel.sql('count(*) desc')) }
|
||||
|
||||
delegate :accounts_count,
|
||||
@@ -44,6 +47,8 @@ class Tag < ApplicationRecord
|
||||
|
||||
after_save :save_account_tag_stat
|
||||
|
||||
update_index('tags#tag', :self) if Chewy.enabled?
|
||||
|
||||
def account_tag_stat
|
||||
super || build_account_tag_stat
|
||||
end
|
||||
@@ -121,9 +126,10 @@ class Tag < ApplicationRecord
|
||||
normalized_term = normalize(term.strip).mb_chars.downcase.to_s
|
||||
pattern = sanitize_sql_like(normalized_term) + '%'
|
||||
|
||||
Tag.where(arel_table[:name].lower.matches(pattern))
|
||||
.where(arel_table[:score].gt(0).or(arel_table[:name].lower.eq(normalized_term)))
|
||||
.order(Arel.sql('length(name) ASC, score DESC, name ASC'))
|
||||
Tag.listable
|
||||
.where(arel_table[:name].lower.matches(pattern))
|
||||
.where(arel_table[:name].lower.eq(normalized_term).or(arel_table[:reviewed_at].not_eq(nil)))
|
||||
.order(Arel.sql('length(name) ASC, name ASC'))
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
end
|
||||
|
||||
@@ -17,6 +17,9 @@ class TrendingTags
|
||||
increment_historical_use!(tag.id, at_time)
|
||||
increment_unique_use!(tag.id, account.id, at_time)
|
||||
increment_vote!(tag, at_time)
|
||||
|
||||
tag.update(last_status_at: Time.now.utc) if tag.last_status_at.nil? || tag.last_status_at < 12.hours.ago
|
||||
tag.update(last_trend_at: Time.now.utc) if trending?(tag) && (tag.last_trend_at.nil? || tag.last_trend_at < 12.hours.ago)
|
||||
end
|
||||
|
||||
def get(limit, filtered: true)
|
||||
|
||||
Reference in New Issue
Block a user