]> cat aescling's git repositories - mastodon.git/commitdiff
Merge branch 'master' into glitch-soc/merge-upstream
authorThibaut Girka <thib@sitedethib.com>
Tue, 23 Jul 2019 08:17:06 +0000 (10:17 +0200)
committerThibaut Girka <thib@sitedethib.com>
Tue, 23 Jul 2019 08:51:07 +0000 (10:51 +0200)
Conflicts:
- app/controllers/application_controller.rb
- app/controllers/auth/confirmations_controller.rb
- app/controllers/auth/sessions_controller.rb
- app/controllers/settings/deletes_controller.rb
- app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb

26 files changed:
1  2 
Gemfile
Gemfile.lock
app/controllers/about_controller.rb
app/controllers/accounts_controller.rb
app/controllers/application_controller.rb
app/controllers/auth/confirmations_controller.rb
app/controllers/auth/registrations_controller.rb
app/controllers/auth/sessions_controller.rb
app/controllers/oauth/authorized_applications_controller.rb
app/controllers/settings/deletes_controller.rb
app/controllers/settings/sessions_controller.rb
app/controllers/settings/two_factor_authentication/confirmations_controller.rb
app/controllers/settings/two_factor_authentication/recovery_codes_controller.rb
app/controllers/settings/two_factor_authentications_controller.rb
app/controllers/statuses_controller.rb
app/javascript/packs/public.js
app/javascript/styles/mastodon/admin.scss
app/lib/formatter.rb
app/models/concerns/account_associations.rb
app/models/user.rb
config/locales/en.yml
config/routes.rb
db/schema.rb
package.json
spec/controllers/application_controller_spec.rb
yarn.lock

diff --cc Gemfile
Simple merge
diff --cc Gemfile.lock
Simple merge
Simple merge
index 95e0d624f4331eb76ef0e03e977e5f5521eb20d2,41ce1a0ca22bbc3718c9945ee1912b5bcdcc2db7..4a6b96982f3e890eb0b227636704b6af770fa20d
@@@ -180,62 -111,15 +181,24 @@@ class ApplicationController < ActionCon
      @current_session = SessionActivation.find_by(session_id: cookies.signed['_session_id']) if cookies.signed['_session_id'].present?
    end
  
 -  def current_theme
 -    return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme
 -    current_user.setting_theme
 +  def current_flavour
 +    return Setting.flavour unless Themes.instance.flavours.include? current_user&.setting_flavour
 +    current_user.setting_flavour
 +  end
 +
 +  def current_skin
 +    return Setting.skin unless Themes.instance.skins_for(current_flavour).include? current_user&.setting_skin
 +    current_user.setting_skin
    end
  
-   def cache_collection(raw, klass)
-     return raw unless klass.respond_to?(:with_includes)
-     raw                    = raw.cache_ids.to_a if raw.is_a?(ActiveRecord::Relation)
-     cached_keys_with_value = Rails.cache.read_multi(*raw).transform_keys(&:id)
-     uncached_ids           = raw.map(&:id) - cached_keys_with_value.keys
-     klass.reload_stale_associations!(cached_keys_with_value.values) if klass.respond_to?(:reload_stale_associations!)
-     unless uncached_ids.empty?
-       uncached = klass.where(id: uncached_ids).with_includes.each_with_object({}) { |item, h| h[item.id] = item }
-       uncached.each_value do |item|
-         Rails.cache.write(item, item)
-       end
-     end
-     raw.map { |item| cached_keys_with_value[item.id] || uncached[item.id] }.compact
-   end
    def respond_with_error(code)
      respond_to do |format|
        format.any  { head code }
 -      format.html { render "errors/#{code}", layout: 'error', status: code }
 +
 +      format.html do
-         set_locale
 +        use_pack 'error'
 +        render "errors/#{code}", layout: 'error', status: code
 +      end
      end
    end
-   def render_cached_json(cache_key, **options)
-     options[:expires_in] ||= 3.minutes
-     cache_public           = options.key?(:public) ? options.delete(:public) : true
-     content_type           = options.delete(:content_type) || 'application/json'
-     data = Rails.cache.fetch(cache_key, { raw: true }.merge(options)) do
-       yield.to_json
-     end
-     expires_in options[:expires_in], public: cache_public
-     render json: data, content_type: content_type
-   end
-   def set_cache_headers
-     response.headers['Vary'] = public_fetch_mode? ? 'Accept' : 'Accept, Signature'
-   end
  end
index eade82e367844fc276490e0a0e2a6011c42830a5,0d7c6e7c2d34a1729eef50ea85ed4b3b1ff347f3..1d6e4ec197caee981f47dd7eb987ef4a715dc325
@@@ -4,31 -4,11 +4,16 @@@ class Auth::ConfirmationsController < D
    layout 'auth'
  
    before_action :set_body_classes
-   before_action :set_user, only: [:finish_signup]
 +  before_action :set_pack
  
-   def finish_signup
-     return unless request.patch? && params[:user]
-     if @user.update(user_params)
-       @user.skip_reconfirmation!
-       bypass_sign_in(@user)
-       redirect_to root_path, notice: I18n.t('devise.confirmations.send_instructions')
-     else
-       @show_errors = true
-     end
-   end
+   skip_before_action :require_functional!
  
    private
  
-   def set_user
-     @user = current_user
-   end
 +  def set_pack
 +    use_pack 'auth'
 +  end
 +
    def set_body_classes
      @body_classes = 'lighter'
    end
index 332f4d7a7efc402f7bc1672affe0ff6809ce8f85,7e6dbf19e84cf39e0c93a931b35dbacaf136702d..7ecbaf19301dfe80acc251667378ff8eb8268f08
@@@ -6,9 -6,10 +6,11 @@@ class Auth::SessionsController < Devise
    layout 'auth'
  
    skip_before_action :require_no_authentication, only: [:create]
-   skip_before_action :check_user_permissions, only: [:destroy]
+   skip_before_action :require_functional!
    prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create]
 +  prepend_before_action :set_pack
    before_action :set_instance_presenter, only: [:new]
    before_action :set_body_classes
  
index 4e45445df44ed945de20d675f1e6061c5b9a7c26,fb8389034b9b20cffeab89b0579000db992bdf7e..c5ccece134719ca5d6cb7022c7f0a3d459decb81
@@@ -5,9 -5,10 +5,11 @@@ class Oauth::AuthorizedApplicationsCont
  
    before_action :store_current_location
    before_action :authenticate_resource_owner!
 +  before_action :set_pack
    before_action :set_body_classes
  
+   skip_before_action :require_functional!
    include Localized
  
    def destroy
index 4c112147114b9ac93b67db990c7cd54d1707cb14,97fe4d3281f66d097e38ad79737bc8c3527e3a77..20dcc2dbd6a4b95021c017ba612c6a8647c3111d
@@@ -1,8 -1,13 +1,11 @@@
  # frozen_string_literal: true
  
  class Settings::DeletesController < Settings::BaseController
 -  layout 'admin'
  
 -  before_action :check_enabled_deletion
 -  before_action :authenticate_user!
 +  prepend_before_action :check_enabled_deletion
+   before_action :require_not_suspended!
+   skip_before_action :require_functional!
  
    def show
      @confirmation = Form::DeleteConfirmation.new
index 363b32e17d3803acf5c0e7321298662b6a491216,3145e092da7b14177d34e46d901ea392cd0b232c..1708d71d798c42b9fb02405d9eb99dba60e8c80d
@@@ -3,8 -3,13 +3,10 @@@
  module Settings
    module TwoFactorAuthentication
      class ConfirmationsController < BaseController
 -      layout 'admin'
 -
 -      before_action :authenticate_user!
        before_action :ensure_otp_secret
  
+       skip_before_action :require_functional!
        def new
          prepare_two_factor_form
        end
index 0555d61dbf431f077ffcaf8de2b8f2f74dd6bc1d,09a759860e9c39e90648ddf57cf55b2951fc207f..56763e10cce89ae1a698a701293d05e39c4e8f8f
@@@ -3,6 -3,12 +3,8 @@@
  module Settings
    module TwoFactorAuthentication
      class RecoveryCodesController < BaseController
 -      layout 'admin'
 -
 -      before_action :authenticate_user!
 -
+       skip_before_action :require_functional!
        def create
          @recovery_codes = current_user.generate_otp_backup_codes!
          current_user.save!
index 8c7737e9dc9f33337b43ff3dcfdb5eca2b3d0319,6904076e424207a957847e0debed631cc4752896..e632d39cf82660b836599c506860aef55321587f
@@@ -2,8 -2,13 +2,10 @@@
  
  module Settings
    class TwoFactorAuthenticationsController < BaseController
 -    layout 'admin'
 -
 -    before_action :authenticate_user!
      before_action :verify_otp_required, only: [:create]
  
+     skip_before_action :require_functional!
      def show
        @confirmation = Form::TwoFactorConfirmation.new
      end
index 69441d315027e6ff992abb0c2d76b27ac248eafe,b58622a8d87a7b918cbda6596d33a416e90df8e7..6aea119e37b241ecbfd774ed8c1403877ef7ef09
@@@ -91,7 -114,130 +97,10 @@@ function main() 
      if (parallaxComponents.length > 0 ) {
        new Rellax('.parallax', { speed: -1 });
      }
+     delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
+     delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
    });
 -
 -  delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
 -    if (button !== 0) {
 -      return true;
 -    }
 -    window.location.href = target.href;
 -    return false;
 -  });
 -
 -  delegate(document, '.status__content__spoiler-link', 'click', function() {
 -    const contentEl = this.parentNode.parentNode.querySelector('.e-content');
 -
 -    if (contentEl.style.display === 'block') {
 -      contentEl.style.display = 'none';
 -      this.parentNode.style.marginBottom = 0;
 -    } else {
 -      contentEl.style.display = 'block';
 -      this.parentNode.style.marginBottom = null;
 -    }
 -
 -    return false;
 -  });
 -
 -  delegate(document, '.modal-button', 'click', e => {
 -    e.preventDefault();
 -
 -    let href;
 -
 -    if (e.target.nodeName !== 'A') {
 -      href = e.target.parentNode.href;
 -    } else {
 -      href = e.target.href;
 -    }
 -
 -    window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
 -  });
 -
 -  delegate(document, '#account_display_name', 'input', ({ target }) => {
 -    const name = document.querySelector('.card .display-name strong');
 -    if (name) {
 -      if (target.value) {
 -        name.innerHTML = emojify(escapeTextContentForBrowser(target.value));
 -      } else {
 -        name.textContent = document.querySelector('#default_account_display_name').textContent;
 -      }
 -    }
 -  });
 -
 -  delegate(document, '#account_avatar', 'change', ({ target }) => {
 -    const avatar = document.querySelector('.card .avatar img');
 -    const [file] = target.files || [];
 -    const url = file ? URL.createObjectURL(file) : avatar.dataset.originalSrc;
 -
 -    avatar.src = url;
 -  });
 -
 -  const getProfileAvatarAnimationHandler = (swapTo) => {
 -    //animate avatar gifs on the profile page when moused over
 -    return ({ target }) => {
 -      const swapSrc = target.getAttribute(swapTo);
 -      //only change the img source if autoplay is off and the image src is actually different
 -      if(target.getAttribute('data-autoplay') !== 'true' && target.src !== swapSrc) {
 -        target.src = swapSrc;
 -      }
 -    };
 -  };
 -
 -  delegate(document, 'img#profile_page_avatar', 'mouseover', getProfileAvatarAnimationHandler('data-original'));
 -
 -  delegate(document, 'img#profile_page_avatar', 'mouseout', getProfileAvatarAnimationHandler('data-static'));
 -
 -  delegate(document, '#account_header', 'change', ({ target }) => {
 -    const header = document.querySelector('.card .card__img img');
 -    const [file] = target.files || [];
 -    const url = file ? URL.createObjectURL(file) : header.dataset.originalSrc;
 -
 -    header.src = url;
 -  });
 -
 -  delegate(document, '#account_locked', 'change', ({ target }) => {
 -    const lock = document.querySelector('.card .display-name i');
 -
 -    if (target.checked) {
 -      lock.style.display = 'inline';
 -    } else {
 -      lock.style.display = 'none';
 -    }
 -  });
 -
 -  delegate(document, '.input-copy input', 'click', ({ target }) => {
 -    target.focus();
 -    target.select();
 -    target.setSelectionRange(0, target.value.length);
 -  });
 -
 -  delegate(document, '.input-copy button', 'click', ({ target }) => {
 -    const input = target.parentNode.querySelector('.input-copy__wrapper input');
 -
 -    const oldReadOnly = input.readonly;
 -
 -    input.readonly = false;
 -    input.focus();
 -    input.select();
 -    input.setSelectionRange(0, input.value.length);
 -
 -    try {
 -      if (document.execCommand('copy')) {
 -        input.blur();
 -        target.parentNode.classList.add('copied');
 -
 -        setTimeout(() => {
 -          target.parentNode.classList.remove('copied');
 -        }, 700);
 -      }
 -    } catch (err) {
 -      console.error(err);
 -    }
 -
 -    input.readonly = oldReadOnly;
 -  });
  }
  
  loadPolyfills().then(main).catch(error => {
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc db/schema.rb
Simple merge
diff --cc package.json
index a56cc75eaeeffb01d4e9dbc697b105f464ad7b18,58d5948175c5f3a30597010cbf4ac531b15e4110..aa9d809f1f6ef43dff87638b49621f9db37ed4c5
@@@ -72,9 -71,8 +72,9 @@@
      "@babel/preset-env": "^7.4.5",
      "@babel/preset-react": "^7.0.0",
      "@babel/runtime": "^7.5.4",
-     "@clusterws/cws": "^0.14.0",
+     "@clusterws/cws": "^0.15.0",
      "array-includes": "^3.0.3",
 +    "atrament": "^0.2.3",
      "autoprefixer": "^9.6.0",
      "axios": "^0.19.0",
      "babel-loader": "^8.0.6",
diff --cc yarn.lock
Simple merge