Merge commit '3a4d3e9d4b573c400eec1743471d54cdccae50a5' into glitch-soc/merge-upstream
This commit is contained in:
21
app/controllers/api/v1/instances/languages_controller.rb
Normal file
21
app/controllers/api/v1/instances/languages_controller.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Instances::LanguagesController < Api::BaseController
|
||||
skip_before_action :require_authenticated_user!, unless: :limited_federation_mode?
|
||||
skip_around_action :set_locale
|
||||
|
||||
before_action :set_languages
|
||||
|
||||
vary_by ''
|
||||
|
||||
def show
|
||||
cache_even_if_authenticated!
|
||||
render json: @languages, each_serializer: REST::LanguageSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_languages
|
||||
@languages = LanguagesHelper::SUPPORTED_LOCALES.keys.map { |code| LanguagePresenter.new(code) }
|
||||
end
|
||||
end
|
@ -13,4 +13,30 @@ ready(() => {
|
||||
console.error(error);
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
document.querySelectorAll('.timer-button').forEach(button => {
|
||||
let counter = 30;
|
||||
|
||||
const container = document.createElement('span');
|
||||
|
||||
const updateCounter = () => {
|
||||
container.innerText = ` (${counter})`;
|
||||
};
|
||||
|
||||
updateCounter();
|
||||
|
||||
const countdown = setInterval(() => {
|
||||
counter--;
|
||||
|
||||
if (counter === 0) {
|
||||
button.disabled = false;
|
||||
button.removeChild(container);
|
||||
clearInterval(countdown);
|
||||
} else {
|
||||
updateCounter();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
button.appendChild(container);
|
||||
});
|
||||
});
|
||||
|
@ -346,7 +346,7 @@ class Request
|
||||
end
|
||||
|
||||
def private_address_exceptions
|
||||
@private_address_exceptions = (ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(',').map { |addr| IPAddr.new(addr) }
|
||||
@private_address_exceptions = (ENV['ALLOWED_PRIVATE_ADDRESSES'] || '').split(/(?:\s*,\s*|\s+)/).map { |addr| IPAddr.new(addr) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
20
app/presenters/language_presenter.rb
Normal file
20
app/presenters/language_presenter.rb
Normal file
@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class LanguagePresenter < ActiveModelSerializers::Model
|
||||
attributes :code, :name, :native_name
|
||||
|
||||
def initialize(code)
|
||||
super()
|
||||
|
||||
@code = code
|
||||
@item = LanguagesHelper::SUPPORTED_LOCALES[code]
|
||||
end
|
||||
|
||||
def name
|
||||
@item[0]
|
||||
end
|
||||
|
||||
def native_name
|
||||
@item[1]
|
||||
end
|
||||
end
|
5
app/serializers/rest/language_serializer.rb
Normal file
5
app/serializers/rest/language_serializer.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::LanguageSerializer < ActiveModel::Serializer
|
||||
attributes :code, :name
|
||||
end
|
@ -61,9 +61,13 @@ class FetchLinkCardService < BaseService
|
||||
end
|
||||
|
||||
def attach_card
|
||||
@status.preview_cards << @card
|
||||
Rails.cache.delete(@status)
|
||||
Trends.links.register(@status)
|
||||
with_redis_lock("attach_card:#{@status.id}") do
|
||||
return if @status.preview_cards.any?
|
||||
|
||||
@status.preview_cards << @card
|
||||
Rails.cache.delete(@status)
|
||||
Trends.links.register(@status)
|
||||
end
|
||||
end
|
||||
|
||||
def parse_urls
|
||||
|
@ -17,6 +17,6 @@
|
||||
= f.input :email, required: true, hint: false, input_html: { 'aria-label': t('simple_form.labels.defaults.email'), autocomplete: 'off' }
|
||||
|
||||
.actions
|
||||
= f.submit t('auth.resend_confirmation'), class: 'button'
|
||||
= f.button :button, t('auth.resend_confirmation'), type: :submit, class: 'button timer-button', disabled: true
|
||||
|
||||
.form-footer= render 'auth/shared/links'
|
||||
|
@ -4,7 +4,7 @@ class Scheduler::FollowRecommendationsScheduler
|
||||
include Sidekiq::Worker
|
||||
include Redisable
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
# The maximum number of accounts that can be requested in one page from the
|
||||
# API is 80, and the suggestions API does not allow pagination. This number
|
||||
|
@ -4,7 +4,7 @@ class Scheduler::IndexingScheduler
|
||||
include Sidekiq::Worker
|
||||
include Redisable
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
IMPORT_BATCH_SIZE = 1000
|
||||
SCAN_BATCH_SIZE = 10 * IMPORT_BATCH_SIZE
|
||||
@ -16,9 +16,7 @@ class Scheduler::IndexingScheduler
|
||||
with_redis do |redis|
|
||||
redis.sscan_each("chewy:queue:#{type.name}", count: SCAN_BATCH_SIZE).each_slice(IMPORT_BATCH_SIZE) do |ids|
|
||||
type.import!(ids)
|
||||
redis.pipelined do |pipeline|
|
||||
pipeline.srem("chewy:queue:#{type.name}", ids)
|
||||
end
|
||||
redis.srem("chewy:queue:#{type.name}", ids)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Scheduler::InstanceRefreshScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
Instance.refresh
|
||||
|
@ -6,7 +6,7 @@ class Scheduler::IpCleanupScheduler
|
||||
IP_RETENTION_PERIOD = ENV.fetch('IP_RETENTION_PERIOD', 1.year).to_i.seconds.freeze
|
||||
SESSION_RETENTION_PERIOD = ENV.fetch('SESSION_RETENTION_PERIOD', 1.year).to_i.seconds.freeze
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
clean_ip_columns!
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Scheduler::PgheroScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
PgHero.capture_space_stats
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Scheduler::ScheduledStatusesScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
publish_scheduled_statuses!
|
||||
|
@ -16,7 +16,7 @@ class Scheduler::SuspendedUserCleanupScheduler
|
||||
# has the capacity for it.
|
||||
MAX_DELETIONS_PER_JOB = 10
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
return if Sidekiq::Queue.new('pull').size > MAX_PULL_SIZE
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Scheduler::UserCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
clean_unconfirmed_accounts!
|
||||
|
@ -3,7 +3,7 @@
|
||||
class Scheduler::VacuumScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0, lock: :until_executed
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
vacuum_operations.each do |operation|
|
||||
|
Reference in New Issue
Block a user