]> cat aescling's git repositories - mastodon.git/commitdiff
Merge branch 'master' into glitch-soc/merge-upstream
authorThibaut Girka <thib@sitedethib.com>
Sun, 10 May 2020 13:15:39 +0000 (15:15 +0200)
committerThibaut Girka <thib@sitedethib.com>
Sun, 10 May 2020 14:19:56 +0000 (16:19 +0200)
Conflicts:
- `Gemfile.lock`:
  Not a real conflict, just a glitch-soc-only dependency too close to a
  dependency that got updated upstream. Updated as well.
- `app/models/status.rb`:
  Not a real conflict, just a change too close to glitch-soc-changed code
  for optionally showing boosts in public timelines.
  Applied upstream changes.
- `app/views/layouts/application.html.haml`:
  Upstream a new, static CSS file, conflict due to glitch-soc's theming
  system, include the file regardless of the theme.
- `config/initializers/content_security_policy.rb`:
  Upstream dropped 'unsafe-inline' from the 'style-src' directive, but
  both files are very different. Removed 'unsafe-inline' as well.

17 files changed:
1  2 
.env.production.sample
Gemfile
Gemfile.lock
app/controllers/accounts_controller.rb
app/controllers/auth/sessions_controller.rb
app/controllers/settings/identity_proofs_controller.rb
app/javascript/styles/mastodon/components.scss
app/models/status.rb
app/views/layouts/application.html.haml
config/initializers/content_security_policy.rb
config/locales/en.yml
config/routes.rb
db/schema.rb
package.json
spec/models/status_spec.rb
streaming/index.js
yarn.lock

Simple merge
diff --cc Gemfile
Simple merge
diff --cc Gemfile.lock
index 7525911ffbcc69da42d4ec8de19ebb76b3140769,3484253bb8a36915220ca5da9dc1a932c34db4fe..99e5bf33f328dbb3385fafa84a9b87d6192519be
@@@ -490,8 -490,7 +490,8 @@@ GE
        link_header (~> 0.0, >= 0.0.8)
      rdf-normalize (0.4.0)
        rdf (~> 3.1)
-     redis (4.1.3)
 +    redcarpet (3.5.0)
+     redis (4.1.4)
      redis-actionpack (5.2.0)
        actionpack (>= 5, < 7)
        redis-rack (>= 2.1.0, < 3)
index eac9dde6f28bb27357285feb3842bff0c07839fd,e95909447ce73381e475840f19dbaec1e539221f..c36561b862a3d3208b622c1a8bec099081d81af5
@@@ -113,12 -111,15 +113,19 @@@ class Auth::SessionsController < Devise
      render :two_factor
    end
  
+   def require_no_authentication
+     super
+     # Delete flash message that isn't entirely useful and may be confusing in
+     # most cases because /web doesn't display/clear flash messages.
+     flash.delete(:alert) if flash[:alert] == I18n.t('devise.failure.already_authenticated')
+   end
    private
  
 +  def set_pack
 +    use_pack 'auth'
 +  end
 +
    def set_instance_presenter
      @instance_presenter = InstancePresenter.new
    end
index e84c1aca611d642777aa5b98f08510c131433c8d,3a90b7c4df04117b6228478c6c579a905a4e7ff6..b217b3c3becf7aa00118e081107c0ab7cdea32af
@@@ -40,12 -37,14 +38,18 @@@ class Settings::IdentityProofsControlle
      end
    end
  
+   def destroy
+     @proof = current_account.identity_proofs.find(params[:id])
+     @proof.destroy!
+     redirect_to settings_identity_proofs_path, success: I18n.t('identity_proofs.removed')
+   end
    private
  
 +  def check_enabled
 +    not_found unless Setting.enable_keybase
 +  end
 +
    def check_required_params
      redirect_to settings_identity_proofs_path unless [:provider, :provider_username, :username, :token].all? { |k| params[k].present? }
    end
index 34fa00912587f71d0a7ba79136db59059f5fd973,a1babf85e305560ac733d5f07a945838d73f55d3..341f7209068748f7bf67c0dc8a3a1094ad7d2df5
@@@ -297,52 -281,10 +289,52 @@@ class Status < ApplicationRecor
        where(language: nil).or where(language: account.chosen_languages)
      end
  
 +    def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false)
 +      # direct timeline is mix of direct message from_me and to_me.
 +      # 2 queries are executed with pagination.
 +      # constant expression using arel_table is required for partial index
 +
 +      # _from_me part does not require any timeline filters
 +      query_from_me = where(account_id: account.id)
 +                      .where(Status.arel_table[:visibility].eq(3))
 +                      .limit(limit)
 +                      .order('statuses.id DESC')
 +
 +      # _to_me part requires mute and block filter.
 +      # FIXME: may we check mutes.hide_notifications?
 +      query_to_me = Status
 +                    .joins(:mentions)
 +                    .merge(Mention.where(account_id: account.id))
 +                    .where(Status.arel_table[:visibility].eq(3))
 +                    .limit(limit)
 +                    .order('mentions.status_id DESC')
 +                    .not_excluded_by_account(account)
 +
 +      if max_id.present?
 +        query_from_me = query_from_me.where('statuses.id < ?', max_id)
 +        query_to_me = query_to_me.where('mentions.status_id < ?', max_id)
 +      end
 +
 +      if since_id.present?
 +        query_from_me = query_from_me.where('statuses.id > ?', since_id)
 +        query_to_me = query_to_me.where('mentions.status_id > ?', since_id)
 +      end
 +
 +      if cache_ids
 +        # returns array of cache_ids object that have id and updated_at
 +        (query_from_me.cache_ids.to_a + query_to_me.cache_ids.to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
 +      else
 +        # returns ActiveRecord.Relation
 +        items = (query_from_me.select(:id).to_a + query_to_me.select(:id).to_a).uniq(&:id).sort_by(&:id).reverse.take(limit)
 +        Status.where(id: items.map(&:id))
 +      end
 +    end
 +
      def as_public_timeline(account = nil, local_only = false)
 -      query = timeline_scope(local_only).without_replies
 +      query = timeline_scope(local_only)
 +      query = query.without_replies unless Setting.show_replies_in_public_timelines
  
-       apply_timeline_filters(query, account, local_only)
+       apply_timeline_filters(query, account, [:local, true].include?(local_only))
      end
  
      def as_tag_timeline(tag, account = nil, local_only = false)
  
      private
  
-     def timeline_scope(local_only = false)
-       starting_scope = local_only ? Status.local : Status
+     def timeline_scope(scope = false)
+       starting_scope = case scope
+                        when :local, true
+                          Status.local
+                        when :remote
+                          Status.remote
+                        else
+                          Status
+                        end
 -
 -      starting_scope
 -        .with_public_visibility
 -        .without_reblogs
 +      starting_scope = starting_scope.with_public_visibility
 +      if Setting.show_reblogs_in_public_timelines
 +        starting_scope
 +      else
 +        starting_scope.without_reblogs
 +      end
      end
  
      def apply_timeline_filters(query, account, local_only)
index 99ab3729e0f1adb63fc0cfa771606486b5ae3f43,39fa0678fdcb12ad75b6e5ac1d906f9e3eed096d..92edaea3c14ab50db6fa4f48b44366cba3bd3d08
  
      %title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp.html_safe, title], ' - ') : title
  
 -    = stylesheet_pack_tag 'common', media: 'all'
 -    = stylesheet_pack_tag current_theme, media: 'all'
 -    = javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
 -    = javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
 +    = javascript_pack_tag "locales", integrity: true, crossorigin: 'anonymous'
 +    - if @theme
 +      - if @theme[:supported_locales].include? I18n.locale.to_s
 +        = javascript_pack_tag "locales/#{@theme[:flavour]}/#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
 +      - elsif @theme[:supported_locales].include? 'en'
 +        = javascript_pack_tag "locales/#{@theme[:flavour]}/en", integrity: true, crossorigin: 'anonymous'
      = csrf_meta_tags
  
+     = stylesheet_link_tag '/inert.css', skip_pipeline: true, media: 'all', id: 'inert-style'
 +    = yield :header_tags
 +
 +    -#  These must come after :header_tags to ensure our initial state has been defined.
 +    = render partial: 'layouts/theme', object: @core
 +    = render partial: 'layouts/theme', object: @theme
 +
      - if Setting.custom_css.present?
        = stylesheet_link_tag custom_css_path, media: 'all'
  
index d1e6701e23c7e59b76682164432b4a0932673e9a,7dcc028ab6ae76abff8e0102c2f82594566654cc..a76db6fe554d7dabacfde2fb34e197bcdbc460f2
@@@ -2,45 -2,43 +2,45 @@@
  # For further information see the following documentation
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
  
 -def host_to_url(str)
 -  "http#{Rails.configuration.x.use_https ? 's' : ''}://#{str}" unless str.blank?
 -end
 -
 -base_host = Rails.configuration.x.web_domain
 -
 -assets_host   = Rails.configuration.action_controller.asset_host
 -assets_host ||= host_to_url(base_host)
 -
 -media_host   = host_to_url(ENV['S3_ALIAS_HOST'])
 -media_host ||= host_to_url(ENV['S3_CLOUDFRONT_HOST'])
 -media_host ||= host_to_url(ENV['S3_HOSTNAME']) if ENV['S3_ENABLED'] == 'true'
 -media_host ||= assets_host
 -
 -Rails.application.config.content_security_policy do |p|
 -  p.base_uri        :none
 -  p.default_src     :none
 -  p.frame_ancestors :none
 -  p.font_src        :self, assets_host
 -  p.img_src         :self, :https, :data, :blob, assets_host
 -  p.style_src       :self, assets_host
 -  p.media_src       :self, :https, :data, assets_host
 -  p.frame_src       :self, :https
 -  p.manifest_src    :self, assets_host
 -
 -  if Rails.env.development?
 -    webpacker_urls = %w(ws http).map { |protocol| "#{protocol}#{Webpacker.dev_server.https? ? 's' : ''}://#{Webpacker.dev_server.host_with_port}" }
 -
 -    p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url, *webpacker_urls
 -    p.script_src  :self, :unsafe_inline, :unsafe_eval, assets_host
 -    p.child_src   :self, :blob, assets_host
 -    p.worker_src  :self, :blob, assets_host
 +if Rails.env.production?
 +  assets_host = Rails.configuration.action_controller.asset_host || "https://#{ENV['WEB_DOMAIN'] || ENV['LOCAL_DOMAIN']}"
 +  data_hosts = [assets_host]
 +
 +  if ENV['S3_ENABLED'] == 'true'
 +    attachments_host = "https://#{ENV['S3_ALIAS_HOST'] || ENV['S3_CLOUDFRONT_HOST'] || ENV['S3_HOSTNAME'] || "s3-#{ENV['S3_REGION'] || 'us-east-1'}.amazonaws.com"}"
 +    attachments_host = "https://#{Addressable::URI.parse(attachments_host).host}"
 +  elsif ENV['SWIFT_ENABLED'] == 'true'
 +    attachments_host = ENV['SWIFT_OBJECT_URL']
 +    attachments_host = "https://#{Addressable::URI.parse(attachments_host).host}"
    else
 -    p.connect_src :self, :data, :blob, assets_host, media_host, Rails.configuration.x.streaming_api_base_url
 -    p.script_src  :self, assets_host
 -    p.child_src   :self, :blob, assets_host
 -    p.worker_src  :self, :blob, assets_host
 +    attachments_host = nil
 +  end
 +
 +  data_hosts << attachments_host unless attachments_host.nil?
 +
 +  if ENV['PAPERCLIP_ROOT_URL']
 +    url = Addressable::URI.parse(assets_host) + ENV['PAPERCLIP_ROOT_URL']
 +    data_hosts << "https://#{url.host}"
 +  end
 +
 +  data_hosts.concat(ENV['EXTRA_DATA_HOSTS'].split('|')) if ENV['EXTRA_DATA_HOSTS']
 +
 +  data_hosts.uniq!
 +
 +  Rails.application.config.content_security_policy do |p|
 +    p.base_uri        :none
 +    p.default_src     :none
 +    p.frame_ancestors :none
 +    p.script_src      :self, assets_host
 +    p.font_src        :self, assets_host
 +    p.img_src         :self, :data, :blob, *data_hosts
-     p.style_src       :self, :unsafe_inline, assets_host
++    p.style_src       :self, assets_host
 +    p.media_src       :self, :data, *data_hosts
 +    p.frame_src       :self, :https
 +    p.child_src       :self, :blob, assets_host
 +    p.worker_src      :self, :blob, assets_host
 +    p.connect_src     :self, :blob, :data, Rails.configuration.x.streaming_api_base_url, *data_hosts
 +    p.manifest_src    :self, assets_host
    end
  end
  
Simple merge
Simple merge
diff --cc db/schema.rb
Simple merge
diff --cc package.json
Simple merge
Simple merge
Simple merge
diff --cc yarn.lock
Simple merge