Merge branch 'main' into glitch-soc/merge-upstream

- `app/views/statuses/_simple_status.html.haml`:
  Small markup change in glitch-soc, on a line that has been modified by
  upstream. Ported upstream changes.
This commit is contained in:
Claire
2021-05-07 18:21:59 +02:00
483 changed files with 13397 additions and 7694 deletions

View File

@@ -22,6 +22,10 @@ class ActivityPub::Activity::Announce < ActivityPub::Activity
visibility: visibility_from_audience
)
original_status.tags.each do |tag|
tag.use!(@account)
end
distribute(@status)
end

View File

@@ -164,7 +164,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def attach_tags(status)
@tags.each do |tag|
status.tags << tag
TrendingTags.record_use!(tag, status.account, status.created_at) if status.public_visibility?
tag.use!(@account, status: status, at_time: status.created_at) if status.public_visibility?
end
@mentions.each do |mention|

View File

@@ -17,6 +17,10 @@ class DeliveryFailureTracker
UnavailableDomain.find_by(domain: @host)&.destroy
end
def clear_failures!
Redis.current.del(exhausted_deliveries_key)
end
def days
Redis.current.scard(exhausted_deliveries_key) || 0
end
@@ -25,6 +29,10 @@ class DeliveryFailureTracker
!UnavailableDomain.where(domain: @host).exists?
end
def exhausted_deliveries_days
Redis.current.smembers(exhausted_deliveries_key).sort.map { |date| Date.new(date.slice(0, 4).to_i, date.slice(4, 2).to_i, date.slice(6, 2).to_i) }
end
alias reset! track_success!
class << self
@@ -44,6 +52,24 @@ class DeliveryFailureTracker
def reset!(url)
new(url).reset!
end
def warning_domains
domains = Redis.current.keys(exhausted_deliveries_key_by('*')).map do |key|
key.delete_prefix(exhausted_deliveries_key_by(''))
end
domains - UnavailableDomain.all.pluck(:domain)
end
def warning_domains_map
warning_domains.index_with { |domain| Redis.current.scard(exhausted_deliveries_key_by(domain)) }
end
private
def exhausted_deliveries_key_by(host)
"exhausted_deliveries:#{host}"
end
end
private

View File

@@ -27,15 +27,5 @@ class PotentialFriendshipTracker
def remove(account_id, target_account_id)
redis.zrem("interactions:#{account_id}", target_account_id)
end
def get(account, limit)
account_ids = redis.zrevrange("interactions:#{account.id}", 0, limit)
return [] if account_ids.empty? || limit < 1
accounts = Account.searchable.where(id: account_ids).index_by(&:id)
account_ids.map { |id| accounts[id.to_i] }.compact
end
end
end

View File

@@ -62,7 +62,11 @@ class StatusReachFinder
end
def followers_inboxes
@status.account.followers.inboxes
if @status.in_reply_to_local_account? && @status.distributable?
@status.account.followers.or(@status.thread.account.followers).inboxes
else
@status.account.followers.inboxes
end
end
def relay_inboxes

View File

@@ -0,0 +1,54 @@
# frozen_string_literal: true
class VideoMetadataExtractor
attr_reader :duration, :bitrate, :video_codec, :audio_codec,
:colorspace, :width, :height, :frame_rate
def initialize(path)
@path = path
@metadata = Oj.load(ffmpeg_command_output, mode: :strict, symbol_keys: true)
parse_metadata
rescue Terrapin::ExitStatusError, Oj::ParseError
@invalid = true
rescue Terrapin::CommandNotFoundError
raise Paperclip::Errors::CommandNotFoundError, 'Could not run the `ffprobe` command. Please install ffmpeg.'
end
def valid?
!@invalid
end
private
def ffmpeg_command_output
command = Terrapin::CommandLine.new('ffprobe', '-i :path -print_format :format -show_format -show_streams -show_error -loglevel :loglevel')
command.run(path: @path, format: 'json', loglevel: 'fatal')
end
def parse_metadata
if @metadata.key?(:format)
@duration = @metadata[:format][:duration].to_f
@bitrate = @metadata[:format][:bit_rate].to_i
end
if @metadata.key?(:streams)
video_streams = @metadata[:streams].select { |stream| stream[:codec_type] == 'video' }
audio_streams = @metadata[:streams].select { |stream| stream[:codec_type] == 'audio' }
if (video_stream = video_streams.first)
@video_codec = video_stream[:codec_name]
@colorspace = video_stream[:pix_fmt]
@width = video_stream[:width]
@height = video_stream[:height]
@frame_rate = video_stream[:avg_frame_rate] == '0/0' ? nil : Rational(video_stream[:avg_frame_rate])
end
if (audio_stream = audio_streams.first)
@audio_codec = audio_stream[:codec_name]
end
end
@invalid = true if @metadata.key?(:error)
end
end