diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-03-16 23:12:59 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2023-03-16 23:12:59 +0100 |
commit | 193250556cb4e6b1b3e2f9bd1ac023b290176fd4 (patch) | |
tree | 3bd6148ff028b8fe089cae9d805a7e587eaeec11 /app/controllers | |
parent | f5daa20f2a90098c9d689c5ec9d95ce9887b3a33 (diff) | |
parent | 681dcd3fa35e886a21853ca829ff1be7f220e83a (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `README.md`: Upstream changed their README, we have our own. Kept ours. - `app/helpers/application_helper.rb`: Minor code style fix upstream, on a line that is different in glitch-soc due to the different theming system. Applied the code style fix to our own code. - `app/views/settings/preferences/appearance/show.html.haml`: Code style fix on a line next to lines exclusive to glitch-soc. Applied upstream changes. - `yarn.lock`: Upstream updated a dependency textually close to a glitch-soc-only dependency. Updated the dependency like upstream did.
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/api/v1/instances/translation_languages_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/backups_controller.rb | 27 | ||||
-rw-r--r-- | app/controllers/concerns/signature_verification.rb | 2 |
3 files changed, 51 insertions, 1 deletions
diff --git a/app/controllers/api/v1/instances/translation_languages_controller.rb b/app/controllers/api/v1/instances/translation_languages_controller.rb new file mode 100644 index 000000000..3910a499e --- /dev/null +++ b/app/controllers/api/v1/instances/translation_languages_controller.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class Api::V1::Instances::TranslationLanguagesController < Api::BaseController + skip_before_action :require_authenticated_user!, unless: :whitelist_mode? + + before_action :set_languages + + def show + expires_in 1.day, public: true + render json: @languages + end + + private + + def set_languages + if TranslationService.configured? + @languages = Rails.cache.fetch('translation_service/languages', expires_in: 7.days, race_condition_ttl: 1.hour) { TranslationService.configured.languages } + @languages['und'] = @languages.delete(nil) if @languages.key?(nil) + else + @languages = {} + end + end +end diff --git a/app/controllers/backups_controller.rb b/app/controllers/backups_controller.rb new file mode 100644 index 000000000..2f4b400b8 --- /dev/null +++ b/app/controllers/backups_controller.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class BackupsController < ApplicationController + include RoutingHelper + + skip_before_action :require_functional! + + before_action :authenticate_user! + before_action :set_backup + + def download + case Paperclip::Attachment.default_options[:storage] + when :s3 + redirect_to @backup.dump.expiring_url(10) + when :fog + redirect_to @backup.dump.expiring_url(Time.now.utc + 10) + when :filesystem + redirect_to full_asset_url(@backup.dump.url) + end + end + + private + + def set_backup + @backup = current_user.backups.find(params[:id]) + end +end diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index b0a087d53..931725943 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -138,7 +138,7 @@ module SignatureVerification end def signed_headers - signature_params.fetch('headers', signature_algorithm == 'hs2019' ? '(created)' : 'date').downcase.split(' ') + signature_params.fetch('headers', signature_algorithm == 'hs2019' ? '(created)' : 'date').downcase.split end def verify_signature_strength! |