Merge remote-tracking branch 'parent/main' into kb_migration
This commit is contained in:
commit
a0b98f9242
180 changed files with 2539 additions and 313 deletions
|
@ -15,10 +15,10 @@ export default class ColumnBackButton extends React.PureComponent {
|
|||
};
|
||||
|
||||
handleClick = () => {
|
||||
if (window.history && window.history.length === 1) {
|
||||
this.context.router.history.push('/');
|
||||
} else {
|
||||
if (window.history && window.history.state) {
|
||||
this.context.router.history.goBack();
|
||||
} else {
|
||||
this.context.router.history.push('/');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -43,14 +43,6 @@ class ColumnHeader extends React.PureComponent {
|
|||
animating: false,
|
||||
};
|
||||
|
||||
historyBack = () => {
|
||||
if (window.history && window.history.length === 1) {
|
||||
this.context.router.history.push('/');
|
||||
} else {
|
||||
this.context.router.history.goBack();
|
||||
}
|
||||
};
|
||||
|
||||
handleToggleClick = (e) => {
|
||||
e.stopPropagation();
|
||||
this.setState({ collapsed: !this.state.collapsed, animating: true });
|
||||
|
@ -69,7 +61,11 @@ class ColumnHeader extends React.PureComponent {
|
|||
};
|
||||
|
||||
handleBackClick = () => {
|
||||
this.historyBack();
|
||||
if (window.history && window.history.state) {
|
||||
this.context.router.history.goBack();
|
||||
} else {
|
||||
this.context.router.history.push('/');
|
||||
}
|
||||
};
|
||||
|
||||
handleTransitionEnd = () => {
|
||||
|
|
|
@ -477,10 +477,10 @@ class UI extends React.PureComponent {
|
|||
};
|
||||
|
||||
handleHotkeyBack = () => {
|
||||
if (window.history && window.history.length === 1) {
|
||||
this.context.router.history.push('/');
|
||||
} else {
|
||||
if (window.history && window.history.state) {
|
||||
this.context.router.history.goBack();
|
||||
} else {
|
||||
this.context.router.history.push('/');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -273,27 +273,27 @@ class FeedManager
|
|||
def clean_feeds!(type, ids)
|
||||
reblogged_id_sets = {}
|
||||
|
||||
redis.pipelined do
|
||||
redis.pipelined do |pipeline|
|
||||
ids.each do |feed_id|
|
||||
redis.del(key(type, feed_id))
|
||||
reblog_key = key(type, feed_id, 'reblogs')
|
||||
# We collect a future for this: we don't block while getting
|
||||
# it, but we can iterate over it later.
|
||||
reblogged_id_sets[feed_id] = redis.zrange(reblog_key, 0, -1)
|
||||
redis.del(reblog_key)
|
||||
reblogged_id_sets[feed_id] = pipeline.zrange(reblog_key, 0, -1)
|
||||
pipeline.del(key(type, feed_id), reblog_key)
|
||||
end
|
||||
end
|
||||
|
||||
# Remove all of the reblog tracking keys we just removed the
|
||||
# references to.
|
||||
redis.pipelined do
|
||||
reblogged_id_sets.each do |feed_id, future|
|
||||
future.value.each do |reblogged_id|
|
||||
reblog_set_key = key(type, feed_id, "reblogs:#{reblogged_id}")
|
||||
redis.del(reblog_set_key)
|
||||
end
|
||||
keys_to_delete = reblogged_id_sets.flat_map do |feed_id, future|
|
||||
future.value.map do |reblogged_id|
|
||||
key(type, feed_id, "reblogs:#{reblogged_id}")
|
||||
end
|
||||
end
|
||||
|
||||
redis.del(keys_to_delete) unless keys_to_delete.empty?
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -20,9 +20,9 @@ class FollowRecommendationSuppression < ApplicationRecord
|
|||
private
|
||||
|
||||
def remove_follow_recommendations
|
||||
redis.pipelined do
|
||||
redis.pipelined do |pipeline|
|
||||
I18n.available_locales.each do |locale|
|
||||
redis.zrem("follow_recommendations:#{locale}", account_id)
|
||||
pipeline.zrem("follow_recommendations:#{locale}", account_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,9 +45,9 @@ class BatchedRemoveStatusService < BaseService
|
|||
|
||||
# Cannot be batched
|
||||
@status_id_cutoff = Mastodon::Snowflake.id_at(2.weeks.ago)
|
||||
redis.pipelined do
|
||||
redis.pipelined do |pipeline|
|
||||
statuses.each do |status|
|
||||
unpush_from_public_timelines(status)
|
||||
unpush_from_public_timelines(status, pipeline)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -70,22 +70,22 @@ class BatchedRemoveStatusService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def unpush_from_public_timelines(status)
|
||||
def unpush_from_public_timelines(status, pipeline)
|
||||
return unless status.public_visibility? && status.id > @status_id_cutoff
|
||||
|
||||
payload = Oj.dump(event: :delete, payload: status.id.to_s)
|
||||
|
||||
redis.publish('timeline:public', payload)
|
||||
redis.publish(status.local? ? 'timeline:public:local' : 'timeline:public:remote', payload)
|
||||
pipeline.publish('timeline:public', payload)
|
||||
pipeline.publish(status.local? ? 'timeline:public:local' : 'timeline:public:remote', payload)
|
||||
|
||||
if status.media_attachments.any?
|
||||
redis.publish('timeline:public:media', payload)
|
||||
redis.publish(status.local? ? 'timeline:public:local:media' : 'timeline:public:remote:media', payload)
|
||||
pipeline.publish('timeline:public:media', payload)
|
||||
pipeline.publish(status.local? ? 'timeline:public:local:media' : 'timeline:public:remote:media', payload)
|
||||
end
|
||||
|
||||
status.tags.map { |tag| tag.name.mb_chars.downcase }.each do |hashtag|
|
||||
redis.publish("timeline:hashtag:#{hashtag}", payload)
|
||||
redis.publish("timeline:hashtag:#{hashtag}:local", payload) if status.local?
|
||||
pipeline.publish("timeline:hashtag:#{hashtag}", payload)
|
||||
pipeline.publish("timeline:hashtag:#{hashtag}:local", payload) if status.local?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class Ed25519KeyValidator < ActiveModel::EachValidator
|
|||
|
||||
key = Base64.decode64(value)
|
||||
|
||||
record.errors[attribute] << I18n.t('crypto.errors.invalid_key') unless verified?(key)
|
||||
record.errors.add(attribute, I18n.t('crypto.errors.invalid_key')) unless verified?(key)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,7 +8,7 @@ class Ed25519SignatureValidator < ActiveModel::EachValidator
|
|||
signature = Base64.decode64(value)
|
||||
message = option_to_value(record, :message)
|
||||
|
||||
record.errors[attribute] << I18n.t('crypto.errors.invalid_signature') unless verified?(verify_key, signature, message)
|
||||
record.errors.add(attribute, I18n.t('crypto.errors.invalid_signature')) unless verified?(verify_key, signature, message)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -5,7 +5,7 @@ RSS::Builder.build do |doc|
|
|||
doc.image(full_asset_url(@account.avatar.url(:original)), display_name(@account), params[:tag].present? ? short_account_tag_url(@account, params[:tag]) : short_account_url(@account))
|
||||
doc.last_build_date(@statuses.first.created_at) if @statuses.any?
|
||||
doc.icon(full_asset_url(@account.avatar.url(:original)))
|
||||
doc.generator("Mastodon v#{Mastodon::Version.to_s}")
|
||||
doc.generator("Mastodon v#{Mastodon::Version}")
|
||||
|
||||
@statuses.each do |status|
|
||||
doc.item do |item|
|
||||
|
@ -18,12 +18,12 @@ RSS::Builder.build do |doc|
|
|||
item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
|
||||
end
|
||||
|
||||
status.ordered_media_attachments.each do |media|
|
||||
item.media_content(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size) do |media_content|
|
||||
media_content.medium(media.gifv? ? 'image' : media.type.to_s)
|
||||
status.ordered_media_attachments.each do |media_attachment|
|
||||
item.media_content(full_asset_url(media_attachment.file.url(:original, false)), media_attachment.file.content_type, media_attachment.file.size) do |media_content|
|
||||
media_content.medium(media_attachment.gifv? ? 'image' : media_attachment.type.to_s)
|
||||
media_content.rating(status.sensitive? ? 'adult' : 'nonadult')
|
||||
media_content.description(media.description) if media.description.present?
|
||||
media_content.thumbnail(media.thumbnail.url(:original, false)) if media.thumbnail?
|
||||
media_content.description(media_attachment.description) if media_attachment.description.present?
|
||||
media_content.thumbnail(media_attachment.thumbnail.url(:original, false)) if media_attachment.thumbnail?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ RSS::Builder.build do |doc|
|
|||
doc.description(I18n.t('rss.descriptions.tag', hashtag: @tag.display_name))
|
||||
doc.link(tag_url(@tag))
|
||||
doc.last_build_date(@statuses.first.created_at) if @statuses.any?
|
||||
doc.generator("Mastodon v#{Mastodon::Version.to_s}")
|
||||
doc.generator("Mastodon v#{Mastodon::Version}")
|
||||
|
||||
@statuses.each do |status|
|
||||
doc.item do |item|
|
||||
|
@ -16,12 +16,12 @@ RSS::Builder.build do |doc|
|
|||
item.enclosure(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size)
|
||||
end
|
||||
|
||||
status.ordered_media_attachments.each do |media|
|
||||
item.media_content(full_asset_url(media.file.url(:original, false)), media.file.content_type, media.file.size) do |media_content|
|
||||
media_content.medium(media.gifv? ? 'image' : media.type.to_s)
|
||||
status.ordered_media_attachments.each do |media_attachment|
|
||||
item.media_content(full_asset_url(media_attachment.file.url(:original, false)), media_attachment.file.content_type, media_attachment.file.size) do |media_content|
|
||||
media_content.medium(media_attachment.gifv? ? 'image' : media_attachment.type.to_s)
|
||||
media_content.rating(status.sensitive? ? 'adult' : 'nonadult')
|
||||
media_content.description(media.description) if media.description.present?
|
||||
media_content.thumbnail(media.thumbnail.url(:original, false)) if media.thumbnail?
|
||||
media_content.description(media_attachment.description) if media_attachment.description.present?
|
||||
media_content.thumbnail(media_attachment.thumbnail.url(:original, false)) if media_attachment.thumbnail?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
%tbody
|
||||
%tr
|
||||
%td
|
||||
= image_tag full_pack_url('media/images/mailer/icon_warning.png'), alt: ''
|
||||
= image_tag full_pack_url('media/images/mailer/icon_flag.png'), alt: ''
|
||||
|
||||
%h1= t 'user_mailer.appeal_rejected.title'
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ doc << Ox::Element.new('XRD').tap do |xrd|
|
|||
end
|
||||
end
|
||||
|
||||
('<?xml version="1.0" encoding="UTF-8"?>' + Ox.dump(doc, effort: :tolerant)).force_encoding('UTF-8')
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>#{Ox.dump(doc, effort: :tolerant)}".force_encoding('UTF-8')
|
||||
|
|
|
@ -20,7 +20,7 @@ class Scheduler::FollowRecommendationsScheduler
|
|||
|
||||
Trends.available_locales.each do |locale|
|
||||
recommendations = if AccountSummary.safe.filtered.localized(locale).exists? # We can skip the work if no accounts with that language exist
|
||||
FollowRecommendation.localized(locale).order(rank: :desc).limit(SET_SIZE).map { |recommendation| [recommendation.account_id, recommendation.rank] }
|
||||
FollowRecommendation.localized(locale).order(rank: :desc).limit(SET_SIZE).map { |recommendation| [recommendation.rank, recommendation.account_id] }
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
@ -33,14 +33,14 @@ class Scheduler::FollowRecommendationsScheduler
|
|||
|
||||
# Language-specific results should be above language-agnostic ones,
|
||||
# otherwise language-agnostic ones will always overshadow them
|
||||
recommendations.map! { |(account_id, rank)| [account_id, rank + max_fallback_rank] }
|
||||
recommendations.map! { |(rank, account_id)| [rank + max_fallback_rank, account_id] }
|
||||
|
||||
added = 0
|
||||
|
||||
fallback_recommendations.each do |recommendation|
|
||||
next if recommendations.any? { |(account_id, _)| account_id == recommendation.account_id }
|
||||
next if recommendations.any? { |(_, account_id)| account_id == recommendation.account_id }
|
||||
|
||||
recommendations << [recommendation.account_id, recommendation.rank]
|
||||
recommendations << [recommendation.rank, recommendation.account_id]
|
||||
added += 1
|
||||
|
||||
break if added >= missing
|
||||
|
@ -49,10 +49,7 @@ class Scheduler::FollowRecommendationsScheduler
|
|||
|
||||
redis.multi do |multi|
|
||||
multi.del(key(locale))
|
||||
|
||||
recommendations.each do |(account_id, rank)|
|
||||
multi.zadd(key(locale), rank, account_id)
|
||||
end
|
||||
multi.zadd(key(locale), recommendations)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue