mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Compare commits
4 commits
d41f02eb94
...
88232bc88c
Author | SHA1 | Date | |
---|---|---|---|
|
88232bc88c | ||
|
a50c8e951f | ||
|
2c1e75727d | ||
|
d1b6f1c531 |
29 changed files with 126 additions and 184 deletions
|
@ -57,11 +57,6 @@ Style/FormatStringToken:
|
|||
- 'config/initializers/devise.rb'
|
||||
- 'lib/paperclip/color_extractor.rb'
|
||||
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Style/HashTransformValues:
|
||||
Exclude:
|
||||
|
|
|
@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
|
|||
|
||||
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
|
||||
type: NotificationWithStatusType;
|
||||
status: ApiStatusJSON;
|
||||
status_id: string;
|
||||
}
|
||||
|
||||
interface NotificationWithStatusJSON extends BaseNotificationJSON {
|
||||
|
|
|
@ -49,22 +49,15 @@ export const FilteredNotificationsBanner: React.FC = () => {
|
|||
<span>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.pending_requests'
|
||||
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
|
||||
values={{ count: policy.summary.pending_requests_count }}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className='filtered-notifications-banner__badge'>
|
||||
<div className='filtered-notifications-banner__badge__badge'>
|
||||
{toCappedNumber(policy.summary.pending_notifications_count)}
|
||||
</div>
|
||||
<FormattedMessage
|
||||
id='filtered_notifications_banner.mentions'
|
||||
defaultMessage='{count, plural, one {mention} other {mentions}}'
|
||||
values={{ count: policy.summary.pending_notifications_count }}
|
||||
/>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -300,8 +300,7 @@
|
|||
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
|
||||
"filter_modal.select_filter.title": "Filter this post",
|
||||
"filter_modal.title.status": "Filter a post",
|
||||
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}",
|
||||
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
|
||||
"filtered_notifications_banner.title": "Filtered notifications",
|
||||
"firehose.all": "All",
|
||||
"firehose.local": "This server",
|
||||
|
|
|
@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
|
|||
case 'mention':
|
||||
case 'poll':
|
||||
case 'update': {
|
||||
const { status, ...groupWithoutStatus } = group;
|
||||
const { status_id: statusId, ...groupWithoutStatus } = group;
|
||||
return {
|
||||
statusId: status.id,
|
||||
statusId,
|
||||
sampleAccountIds,
|
||||
...groupWithoutStatus,
|
||||
};
|
||||
|
|
|
@ -10170,20 +10170,6 @@ noscript {
|
|||
}
|
||||
}
|
||||
|
||||
&__badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: var(--background-border-color);
|
||||
color: $darker-text-color;
|
||||
padding: 4px;
|
||||
padding-inline-end: 8px;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
word-break: keep-all;
|
||||
|
||||
&__badge {
|
||||
background: $ui-button-background-color;
|
||||
color: $white;
|
||||
|
@ -10191,7 +10177,6 @@ noscript {
|
|||
padding: 2px 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notification-request {
|
||||
display: flex;
|
||||
|
|
|
@ -15,9 +15,9 @@ class ActivityPub::Activity::Block < ActivityPub::Activity
|
|||
UnfollowService.new.call(target_account, @account) if target_account.following?(@account)
|
||||
RejectFollowService.new.call(target_account, @account) if target_account.requested?(@account)
|
||||
|
||||
unless delete_arrived_first?(@json['id'])
|
||||
return if delete_arrived_first?(@json['id'])
|
||||
|
||||
BlockWorker.perform_async(@account.id, target_account.id)
|
||||
@account.block!(target_account, uri: @json['id'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -318,12 +318,10 @@ class Request
|
|||
end
|
||||
end
|
||||
|
||||
if outer_e
|
||||
raise outer_e
|
||||
else
|
||||
raise outer_e if outer_e
|
||||
|
||||
raise SocketError, "No address for #{host}"
|
||||
end
|
||||
end
|
||||
|
||||
alias new open
|
||||
|
||||
|
|
|
@ -58,13 +58,11 @@ class RequestPool
|
|||
|
||||
close
|
||||
|
||||
if @fresh || retries.positive?
|
||||
raise
|
||||
else
|
||||
raise if @fresh || retries.positive?
|
||||
|
||||
@http_client = http_client
|
||||
retries += 1
|
||||
retry
|
||||
end
|
||||
rescue
|
||||
# If this connection raises errors of any kind, it's
|
||||
# better if it gets reaped as soon as possible
|
||||
|
|
|
@ -84,22 +84,18 @@ class Webfinger
|
|||
|
||||
def body_from_host_meta
|
||||
host_meta_request.perform do |res|
|
||||
if res.code == 200
|
||||
raise Webfinger::Error, "Request for #{@uri} returned HTTP #{res.code}" unless res.code == 200
|
||||
|
||||
body_from_webfinger(url_from_template(res.body_with_limit), false)
|
||||
else
|
||||
raise Webfinger::Error, "Request for #{@uri} returned HTTP #{res.code}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def url_from_template(str)
|
||||
link = Nokogiri::XML(str).at_xpath('//xmlns:Link[@rel="lrdd"]')
|
||||
|
||||
if link.present?
|
||||
raise Webfinger::Error, "Request for #{@uri} returned host-meta without link to Webfinger" if link.blank?
|
||||
|
||||
link['template'].gsub('{uri}', @uri)
|
||||
else
|
||||
raise Webfinger::Error, "Request for #{@uri} returned host-meta without link to Webfinger"
|
||||
end
|
||||
rescue Nokogiri::XML::XPath::SyntaxError
|
||||
raise Webfinger::Error, "Invalid XML encountered in host-meta for #{@uri}"
|
||||
end
|
||||
|
|
|
@ -54,11 +54,9 @@ class WebfingerResource
|
|||
end
|
||||
|
||||
def username_from_acct
|
||||
if domain_matches_local?
|
||||
raise ActiveRecord::RecordNotFound unless domain_matches_local?
|
||||
|
||||
local_username
|
||||
else
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
end
|
||||
|
||||
def split_acct
|
||||
|
|
|
@ -38,11 +38,11 @@ module Account::Counters
|
|||
result = updated_account_stat(key, value.to_i)
|
||||
|
||||
# Reload account_stat if it was loaded, taking into account newly-created unsaved records
|
||||
if association(:account_stat).loaded?
|
||||
return unless association(:account_stat).loaded?
|
||||
|
||||
account_stat.id = result.first['id'] if account_stat.new_record?
|
||||
account_stat.reload
|
||||
end
|
||||
end
|
||||
|
||||
def account_stat
|
||||
super || build_account_stat
|
||||
|
|
|
@ -8,10 +8,10 @@ module User::LdapAuthenticable
|
|||
ldap = Net::LDAP.new(ldap_options)
|
||||
filter = format(Devise.ldap_search_filter, uid: Devise.ldap_uid, mail: Devise.ldap_mail, email: Net::LDAP::Filter.escape(params[:email]))
|
||||
|
||||
if (user_info = ldap.bind_as(base: Devise.ldap_base, filter: filter, password: params[:password]))
|
||||
return unless (user_info = ldap.bind_as(base: Devise.ldap_base, filter: filter, password: params[:password]))
|
||||
|
||||
ldap_get_user(user_info.first)
|
||||
end
|
||||
end
|
||||
|
||||
def ldap_get_user(attributes = {})
|
||||
safe_username = attributes[Devise.ldap_uid.to_sym].first
|
||||
|
|
|
@ -178,9 +178,9 @@ class Tag < ApplicationRecord
|
|||
end
|
||||
|
||||
def validate_display_name_change
|
||||
unless HashtagNormalizer.new.normalize(display_name).casecmp(name.mb_chars).zero?
|
||||
return if HashtagNormalizer.new.normalize(display_name).casecmp(name.mb_chars).zero?
|
||||
|
||||
errors.add(:display_name,
|
||||
I18n.t('tags.does_not_match_previous_name'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -433,7 +433,8 @@ class User < ApplicationRecord
|
|||
|
||||
yield
|
||||
|
||||
if new_user
|
||||
return unless new_user
|
||||
|
||||
# Avoid extremely unlikely race condition when approving and confirming
|
||||
# the user at the same time
|
||||
reload unless approved?
|
||||
|
@ -444,7 +445,6 @@ class User < ApplicationRecord
|
|||
notify_staff_about_pending_account!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def sign_up_from_ip_requires_approval?
|
||||
sign_up_ip.present? && IpBlock.severity_sign_up_requires_approval.exists?(['ip >>= ?', sign_up_ip.to_s])
|
||||
|
|
|
@ -139,11 +139,11 @@ class FanOutOnWriteService < BaseService
|
|||
redis.publish('timeline:public', anonymous_payload)
|
||||
redis.publish(@status.local? ? 'timeline:public:local' : 'timeline:public:remote', anonymous_payload)
|
||||
|
||||
if @status.with_media?
|
||||
return unless @status.with_media?
|
||||
|
||||
redis.publish('timeline:public:media', anonymous_payload)
|
||||
redis.publish(@status.local? ? 'timeline:public:local:media' : 'timeline:public:remote:media', anonymous_payload)
|
||||
end
|
||||
end
|
||||
|
||||
def deliver_to_conversation!
|
||||
AccountConversation.add_status(@account, @status) unless update?
|
||||
|
|
|
@ -98,7 +98,8 @@ class PostStatusService < BaseService
|
|||
def schedule_status!
|
||||
status_for_validation = @account.statuses.build(status_attributes)
|
||||
|
||||
if status_for_validation.valid?
|
||||
raise ActiveRecord::RecordInvalid unless status_for_validation.valid?
|
||||
|
||||
# Marking the status as destroyed is necessary to prevent the status from being
|
||||
# persisted when the associated media attachments get updated when creating the
|
||||
# scheduled status.
|
||||
|
@ -110,9 +111,6 @@ class PostStatusService < BaseService
|
|||
ApplicationRecord.transaction do
|
||||
@status = @account.scheduled_statuses.create!(scheduled_status_attributes)
|
||||
end
|
||||
else
|
||||
raise ActiveRecord::RecordInvalid
|
||||
end
|
||||
end
|
||||
|
||||
def postprocess_status!
|
||||
|
|
|
@ -31,10 +31,10 @@ class ProcessHashtagsService < BaseService
|
|||
|
||||
removed_tags = @previous_tags - @current_tags
|
||||
|
||||
unless removed_tags.empty?
|
||||
return if removed_tags.empty?
|
||||
|
||||
@account.featured_tags.where(tag_id: removed_tags.map(&:id)).find_each do |featured_tag|
|
||||
featured_tag.decrement(@status.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -123,11 +123,11 @@ class MoveWorker
|
|||
end
|
||||
|
||||
def add_account_note_if_needed!(account, id)
|
||||
unless AccountNote.exists?(account: account, target_account: @target_account)
|
||||
return if AccountNote.exists?(account: account, target_account: @target_account)
|
||||
|
||||
text = I18n.with_locale(account.user&.locale.presence || I18n.default_locale) do
|
||||
I18n.t(id, acct: @source_account.acct)
|
||||
end
|
||||
AccountNote.create!(account: account, target_account: @target_account, comment: text)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,10 +20,7 @@ class RedownloadAvatarWorker
|
|||
rescue Mastodon::UnexpectedResponseError => e
|
||||
response = e.response
|
||||
|
||||
if response_error_unsalvageable?(response)
|
||||
raise e unless response_error_unsalvageable?(response)
|
||||
# Give up
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,10 +20,7 @@ class RedownloadHeaderWorker
|
|||
rescue Mastodon::UnexpectedResponseError => e
|
||||
response = e.response
|
||||
|
||||
if response_error_unsalvageable?(response)
|
||||
raise e unless response_error_unsalvageable?(response)
|
||||
# Give up
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,10 +20,7 @@ class RedownloadMediaWorker
|
|||
rescue Mastodon::UnexpectedResponseError => e
|
||||
response = e.response
|
||||
|
||||
if response_error_unsalvageable?(response)
|
||||
raise e unless response_error_unsalvageable?(response)
|
||||
# Give up
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,10 +15,7 @@ class RemoteAccountRefreshWorker
|
|||
rescue Mastodon::UnexpectedResponseError => e
|
||||
response = e.response
|
||||
|
||||
if response_error_unsalvageable?(response)
|
||||
raise e unless response_error_unsalvageable?(response)
|
||||
# Give up
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,11 +13,9 @@ module Devise
|
|||
def authenticate!
|
||||
resource = mapping.to.authenticate_with_ldap(params[scope])
|
||||
|
||||
if resource && !resource.otp_required_for_login?
|
||||
fail(:invalid) unless resource && !resource.otp_required_for_login? # rubocop:disable Style/SignalException -- method is from Warden::Strategies::Base
|
||||
|
||||
success!(resource)
|
||||
else
|
||||
fail(:invalid) # rubocop:disable Style/SignalException -- method is from Warden::Strategies::Base
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -12,11 +12,9 @@ module Devise
|
|||
def authenticate!
|
||||
resource = mapping.to.authenticate_with_pam(params[scope])
|
||||
|
||||
if resource && !resource.otp_required_for_login?
|
||||
fail(:invalid) unless resource && !resource.otp_required_for_login? # rubocop:disable Style/SignalException -- method is from Warden::Strategies::Base
|
||||
|
||||
success!(resource)
|
||||
else
|
||||
fail(:invalid) # rubocop:disable Style/SignalException -- method is from Warden::Strategies::Base
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -320,11 +320,11 @@ module Mastodon::CLI
|
|||
|
||||
say("Visited #{processed} accounts, removed #{culled}#{dry_run_mode_suffix}", :green)
|
||||
|
||||
unless skip_domains.empty?
|
||||
return if skip_domains.empty?
|
||||
|
||||
say('The following domains were not available during the check:', :yellow)
|
||||
skip_domains.each { |domain| say(" #{domain}") }
|
||||
end
|
||||
end
|
||||
|
||||
option :all, type: :boolean
|
||||
option :domain
|
||||
|
|
|
@ -146,7 +146,8 @@ module Mastodon::CLI
|
|||
end
|
||||
end
|
||||
|
||||
if db_table_exists?(:severed_relationships)
|
||||
return unless db_table_exists?(:severed_relationships)
|
||||
|
||||
SeveredRelationship.where(local_account_id: other_account.id).reorder(nil).find_each do |record|
|
||||
record.update_attribute(:local_account_id, id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
|
@ -160,7 +161,6 @@ module Mastodon::CLI
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class User < ApplicationRecord
|
||||
belongs_to :account, inverse_of: :user
|
||||
|
@ -331,7 +331,8 @@ module Mastodon::CLI
|
|||
end
|
||||
|
||||
def deduplicate_users_process_remember_token
|
||||
if migrator_version < 2022_01_18_183010
|
||||
return unless migrator_version < 2022_01_18_183010
|
||||
|
||||
duplicate_record_ids_without_nulls(:users, 'remember_token').each do |row|
|
||||
users = User.where(id: row['ids'].split(',')).order(updated_at: :desc).to_a.drop(1)
|
||||
say "Unsetting remember token for those accounts: #{users.map { |user| user.account.acct }.join(', ')}", :yellow
|
||||
|
@ -341,7 +342,6 @@ module Mastodon::CLI
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def deduplicate_users_process_password_token
|
||||
duplicate_record_ids_without_nulls(:users, 'reset_password_token').each do |row|
|
||||
|
|
|
@ -58,7 +58,8 @@ module Mastodon::CLI
|
|||
say("Visited #{processed} accounts and removed profile media totaling #{number_to_human_size(aggregate)}#{dry_run_mode_suffix}", :green, true)
|
||||
end
|
||||
|
||||
unless options[:prune_profiles] || options[:remove_headers]
|
||||
return if options[:prune_profiles] || options[:remove_headers]
|
||||
|
||||
processed, aggregate = parallelize_with_progress(MediaAttachment.cached.remote.where(created_at: ..time_ago)) do |media_attachment|
|
||||
next if media_attachment.file.blank?
|
||||
|
||||
|
@ -75,7 +76,6 @@ module Mastodon::CLI
|
|||
|
||||
say("Removed #{processed} media attachments (approx. #{number_to_human_size(aggregate)})#{dry_run_mode_suffix}", :green, true)
|
||||
end
|
||||
end
|
||||
|
||||
option :start_after
|
||||
option :prefix
|
||||
|
|
|
@ -56,13 +56,11 @@ namespace :repo do
|
|||
loop do
|
||||
response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/#{REPOSITORY_NAME}/pulls/#{pull_request_number}")
|
||||
|
||||
if response.code == 403
|
||||
break unless response.code == 403
|
||||
|
||||
sleep_for = (response.headers['X-RateLimit-Reset'].to_i - Time.now.to_i).abs
|
||||
puts "Sleeping for #{sleep_for} seconds to get over rate limit"
|
||||
sleep sleep_for
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
pull_request = Oj.load(response.to_s)
|
||||
|
|
Loading…
Reference in a new issue